Sei sulla pagina 1di 161

M.Sc.

(IT) 3rd Semester MSIT-3A Linux Internals (LI)

Assignment - TA Each question carries TEN marks 1. Write an interactive shell script to perform basic operations like addition, subtraction, multiplication and division. [ Hint : use case statement ] 2. Prepare a survey report on the history of Linux. Cover the major mile stones from its start to till date.

History of Linux
The History of Linux began in 1991 with the commencement of a personal project by a Finnish student, Linus Torvalds, to create a new operating system kernel. Since then the resulting Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to its state in 2009 of over 370 megabytes of source under the GNU General Public License.[1

Events leading to creation


The Unix operating system was conceived and implemented by Ken Thompson and Dennis Ritchie (both of AT&T Bell Laboratories) in 1969 and first released in 1970. Its availability and portability caused it to be widely adopted, copied and modified by academic institutions and businesses. Its design became influential to authors of other systems.[citation needed] In 1983, Richard Stallman started the GNU project with the goal of creating a free UNIX-like operating system.[2] As part of this work, he wrote the GNU General Public License (GPL). By the early 1990s there was almost enough available software to create a full operating system. However, the GNU kernel, called Hurd, failed to attract enough attention from developers leaving GNU incomplete. Another free operating system project, initially released in 1977, was the Berkeley Software Distribution (BSD). This was developed by UC Berkeley from the 6th edition of Unix from AT&T. Since

BSD contained Unix code that AT&T owned, AT&T filed a lawsuit (USL v. BSDi) in the early 1990s against the University of California. This strongly limited the development and adoption of BSD.[3][4] In 1985, Intel released the 80386, the first x86 microprocessor with 32-bit instruction set and MMU with paging.[5] In 1986, Maurice J. Bach, of AT&T Bell Labs, published The Design of the UNIX Operating System.[6] This definitive description principally covered the System V Release 2 kernel, with some new features from Release 3 and BSD. MINIX, a Unix-like system intended for academic use, was released by Andrew S. Tanenbaum in 1987. While source code for the system was available, modification and redistribution were restricted. In addition, MINIX's 16-bitdesign was not well adapted to the 32-bit features of the increasingly cheap and popular Intel 386 architecture for personal computers. These factors and the lack of a widely adopted, free kernel provided the impetus for Torvalds's starting his project. He has stated that if either the GNU or 386BSD kernels were available at the time, he likely would not have written his own.[7][8]

The creation of Linux


Linus Torvalds in 2002

In 1991, in Helsinki, Linus Torvalds began a project that later became the Linux kernel. It was initially a terminal emulator, which Torvalds used to access the large UNIX servers of the university. He wrote the program specifically for the hardware he was using and independent of an operating system because he wanted to use the functions of his new PC with an 80386 processor. Development was done on MINIX using the GNU C compiler, which is still the main choice for compiling Linux today (although the code can be built with other compilers, such as the Intel C Compiler).[citation needed] As Torvalds wrote in his book Just for Fun,[9] he eventually realized that he had written an operating system kernel. On 25 August 1991, he announced this system in a Usenet posting to the newsgroup "comp.os.minix.":[10] Hello everybody out there using minix I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things).

I've currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I'll get something practical within a few months, and I'd like to know what features most people would want. Any suggestions are welcome, but I won't promise I'll implement them :-) Linus (torvalds@kruuna.helsinki.fi) PS. Yes it's free of any minix code, and it has a multi-threaded fs. It is NOT portable (uses 386 task switching etc), and it probably never will support anything other than AT-harddisks, as that's all I have :-(. Linus Torvalds [11]

The name
Floppy discs holding a very early version of Linux

Linus Torvalds had wanted to call his invention Freax, a portmanteau of "freak", "free", and "x" (as an allusion to Unix). During the start of his work on the system, he stored the files under the name "Freax" for about half of a year. Torvalds had already considered the name "Linux," but initially dismissed it as too egotistical.[9] In order to facilitate development, the files were uploaded to the FTP server (ftp.funet.fi) of FUNET in September 1991. Ari Lemmke, Torvald's coworker at the Helsinki University of Technology (HUT) who was one of the volunteer administrators for the FTP server at the time, did not think that "Freax" was a good name. So, he named the project "Linux" on the server without consulting Torvalds.[9] Later, however, Torvalds consented to "Linux". To demonstrate how the word "Linux" should be pronounced (English pronunciation: /lnks/ LIN-ks), Torvalds included an audio guide ( [edit]Linux listen (helpinfo)) with the kernel source code.[12]

under the GNU GPL

Torvalds first published the Linux kernel under its own licence, which had a restriction on commercial activity. The software to use with the kernel was software developed as part of the GNU project licensed under the GNU General Public License, a free software license. The first release of the Linux kernel, Linux 0.01, included a binary of GNU's Bash shell.[13] In the "Notes for linux release 0.01", Torvalds lists the GNU software that is required to run Linux:[13] Sadly, a kernel by itself gets you nowhere. To get a working system you need a shell, compilers, a library etc. These are separate parts and may be under a stricter (or even looser) copyright. Most of the tools used with linux are GNU software and are under the GNU copyleft. These tools aren't in the distribution ask me (or GNU) for more info.[13]

In 1992, he suggested releasing the kernel under the GNU General Public License. He first announced this decision in the release notes of version 0.12.[14] In the middle of December 1992 he published version 0.99 using the GNU GPL.[15] Linux and GNU developers worked to integrate GNU components with Linux to make a fully functional and free operating system.[16] Torvalds has stated, making Linux GPL'd was definitely the best thing I ever did.[17] [edit]GNU/Linux

naming controversy

For more details on this topic, see GNU/Linux naming controversy. The designation "Linux" was initially used by Torvalds only for the Linux kernel. The kernel was, however, frequently used together with other software, especially that of the GNU project. This quickly became the most popular adoption of GNU software. In June 1994 in GNU's bulletin, Linux was referred to as a "free UNIX clone", and the Debian project began calling its product Debian GNU/Linux. In May 1996, Richard Stallman published the editor Emacs19.31, in which the type of system was renamed from Linux to Lignux. This spelling was intended to refer specifically to the combination of GNU and Linux, but this was soon abandoned in favor of "GNU/Linux".[18] This name garnered varying reactions. The GNU and Debian projects use the name, although most people simply use the term "Linux" to refer to the combination.[19] [edit]Official Main article: Tux Torvalds announced in 1996 that there would be a mascot for Linux, a penguin. This was due the fact when they were about to select the mascot, Torvalds did mention he was bitten by a Little Penguin on a visit to the National Zoo & Aquarium, Canberra, Australia. Larry Ewing provided the original draft of today's well known mascot based on this description. The name Tux was suggested by James Hughes as derivative of Torvalds' UniX.[9] [edit]New

mascot

development

[edit]Kernel There are many other well-known maintainers for the Linux kernel beside Torvalds such as Alan Cox and Marcelo Tosatti. Cox maintained version 2.2 of the kernel until it was discontinued at the end of 2003. Likewise, Tosatti maintained version 2.4 of the kernel until the middle of 2006. Andrew Morton steers the development and administration of the 2.6 kernel, which was released on 18 December 2003 in its first stable incarnation. Also the older branches are still constantly improved.

[edit]Community The largest part of the work on Linux is performed by the community: the thousands of programmers around the world that use Linux and send their suggested improvements to the maintainers. Various companies have also helped not only with the development of the Kernels, but also with the writing of the body of auxiliary software, which is distributed with Linux. It is released both by organized projects such as Debian, and by projects connected directly with companies such as Fedora and openSUSE. The members of the respective projects meet at various conferences and fairs, in order to exchange ideas. One of the largest of these fairs is the LinuxTag in Germany (currently in Berlin), where about 10,000 people assemble annually, in order to discuss Linux and the projects associated with it. [edit]Open

Source Development Lab and Linux Foundation

The Open Source Development Lab (OSDL) was created in the year 2000, and is an independent nonprofit organization which pursues the goal of optimizing Linux for employment in data centers and in the carrier range. It served as sponsored working premises for Linus Torvalds and also for Andrew Morton (until the middle of 2006 when Morton transferred to Google). Torvalds works full-time on behalf of OSDL, developing the Linux Kernels. On January 22, 2007, OSDL and the Free Standards Group merged to form The Linux Foundation, narrowing their respective focuses to that of promoting GNU/Linux in competition with Microsoft Windows.
[20]

[edit]Companies Despite being open-source, a few companies profit from Linux. These companies, most of which are also members of the Open Source Development Lab, invest substantial resources into the advancement and development of Linux, in order to make it suited for various application areas. This includes hardware donations for driver developers, cash donations for people who develop Linux software, and the employment of Linux programmers at the company. Some examples are IBM and HP, which use Linux on their own servers, and Red Hat, which maintains its own distribution. Likewise Nokia supports Linux by the development and LGPL licensing of Qt, which makes the development of KDE possible, and by employing some of the X and KDE developers. [edit]Controversy

over Linux

Linux has been surrounded by controversy repeatedly since its inception. [edit]"Linux

is obsolete"

Main article: TanenbaumTorvalds debate

In 1992 Andrew S. Tanenbaum, recognized computer scientist and author of the Minix microkernel system, wrote a Usenet article on the newsgroup comp.os.minix with the title "Linux is obsolete",[21] which marked the beginning of a famous debate about the structure of the then-recent Linux kernel. Among the most significant criticisms were that: The kernel was monolithic and thus old-fashioned. The lack of portability, due to the use of exclusive features of the Intel 386 processor. "Writing a

new operating system that is closely tied to any particular piece of hardware, especially a weird one like the Intel line, is basically wrong."[22] There was no strict control of the source code by any individual person.[23] Linux employed a set of features which were useless (Tanenbaum believed that multithreaded file

systems were simply a "performance hack").[24] Tanenbaum's prediction that Linux would become outdated within a few years and replaced by GNU Hurd (which he considered to be more modern) proved incorrect. Linux has been ported to all major platforms and its open development model has led to an exemplary pace of development. In contrast, GNU Hurd has not yet reached the level of stability that would allow it to be used on a production server.
[25]

His dismissal of the Intel line of 386 processors as 'weird' has also proven short-sighted, as

the x86 series of processors and the Intel Corporation would later become near ubiquitous in personal computers. [edit]Samizdat In his unpublished book Samizdat, Kenneth Brown claims that Torvalds illegally copied code from MINIX. These claims have been refuted by Tanenbaum:[26] He [Kenneth Brown] wanted to go on about the ownership issue, but he was also trying to avoid telling me what his real purpose was, so he didn't phrase his questions very well. Finally he asked me if I thought Linus wrote Linux. I said that to the best of my knowledge, Linus wrote the whole kernel himself, but after it was released, other people began improving the kernel, which was very primitive initially, and adding new software to the system--essentially the same development model as MINIX. Then he began to focus on this, with questions like: "Didn't he steal pieces of MINIX without permission." I told him that MINIX had clearly had a huge influence on Linux in many ways, from the layout of the file system to the names in the source tree, but I didn't think Linus had used any of my code. The book's claims, methodology and references were seriously questioned and in the end it was never released and was delisted from the distributor's site. [edit]Competition

from Microsoft

Although Torvalds has said that Microsoft's feeling threatened by Linux in the past was of no consequence to him, the Microsoft and Linux camps had a number of antagonistic interactions between

1997 and 2001. This became quite clear for the first time in 1998, when the first Halloween document was brought to light by Eric S. Raymond. This was a short essay by a Microsoft developer that sought to lay out the threats posed to Microsoft by free software and identified strategies to counter these perceived threats. However the Free Software Foundation issued a statement that Microsoft's production of proprietary software is bad for software users because it denies users "their rightful freedom."[27] Competition entered a new phase in the beginning of 2004, when Microsoft published results from customer case studies evaluating the use of Windows vs. Linux under the name Get the Facts on its own web page. Based on inquiries, research analysts, and some Microsoft sponsored investigations, the case studies claimed that enterprise use of Linux on servers compared unfavorably to the use of Windows in terms of reliability, security, and total cost of ownership.[28] In response, commercial Linux distributors produced their own studies, surveys and testimonials to counter Microsoft's campaign. Novell's web-based campaign at the end of 2004 was entitled Unbending the truth and sought to outline the advantages as well as dispelling the widely publicized legal liabilities of Linux deployment (particularly in light of the SCO v IBM case). Novell particularly referenced the Microsoft studies in many points. IBM also published a series of studies under the title The Linux at IBM competitive advantage to again parry Microsoft's campaign. Red Hat had a campaign called Truth Happens aimed at letting the performance of the product speak for itself, rather than advertising the product by studies.[citation needed] In the autumn of 2006, Novell and Microsoft announced an agreement to co-operate on software interoperability and patent protection.[29] This included an agreement that customers of either Novell or Microsoft may not be sued by the other company for patent infringement. This patent protection was also expanded to non-free software developers. The last part was criticized because it only included noncommercial developers. In July 2009, Microsoft submitted 22,000 lines of source code to the Linux kernel under the GPLV2 license, which were subsequently accepted. Although this has been referred to as "an historic move" and as a possible bellwether of an improvement in Microsoft's corporate attitudes toward Linux and opensource software, the decision was not altogether altruistic, as it promised to lead to significant competitive advantages for Microsoft and avoided legal action against Microsoft. Microsoft was actually compelled to make the code contribution when Vyatta principal engineer and Linux contributor Stephen Hemminger discovered that Microsoft had incorporated a Hyper-V network driver, with GPL-licenced open source components, statically linked to closed-source binaries in contravention of the GPL licence. Microsoft contributed the drivers to rectify the licence violation, although the company attempted to portray it as a charitable act, rather than one to avoid legal action against it. In the past Microsoft had termed Linux a "cancer" and "communist".[30][31][32][33][34]

[edit]SCO Main article: SCO-Linux controversies In March 2003, the SCO Group accused IBM of violating their copyright on UNIX by transferring code from UNIX to Linux. SCO claims ownership of the copyrights on UNIX and a lawsuit was filed against IBM. Red Hat has countersued and SCO has since filed other related lawsuits. At the same time as their lawsuit, SCO began selling Linux licenses to users who did not want to risk a possible complaint on the part of SCO. Since Novell also claims the copyrights to UNIX, it filed suit against SCO. SCO has since filed for bankruptcy.[35] [edit]Trademark

rights

In 1994 and 1995, several people from different countries attempted to register the name "Linux" as a trademark. Thereupon requests for royalty payments were issued to several Linux companies, a step with which many developers and users of Linux did not agree. Linus Torvalds clamped down on these companies with help from Linux International and was granted the trademark to the name, which he transferred to Linux International. Protection of the trademark was later administered by a dedicated foundation, the non-profit Linux Mark Institute. In 2000, Linus Torvalds specified the basic rules for the assignment of the licenses. This means that anyone who offers a product or a service with the name Linux must possess a license for it, which can be obtained through a unique purchase. In June 2005, a new controversy developed over the use of royalties generated from the use of the Linux trademark. The Linux Mark Institute, which represents Linus Torvalds' rights, announced a price increase from 500 to 5,000 dollars for the use of the name. This step was justified as being needed to cover the rising costs of trademark protection. In response to this increase, the community became displeased, which is why Linus Torvalds made an announcement on 21 August 2005, in order to dissolve the misunderstandings. In an e-mail he described the current situation as well as the background in detail and also dealt with the question of who had to pay license costs: [...] And lets repeat: somebody who doesnt want to _protect_ that name would never do this. You can call anything "MyLinux", but the downside is that you may have somebody else who _did_ protect himself come along and send you a cease-and-desist letter. Or, if the name ends up showing up in a trademark search that LMI needs to do every once in a while just to protect the trademark (another legal requirement for trademarks), LMI itself might have to send you a cease-and-desist-or-sublicense it letter. At which point you either rename it to something else, or you sublicense it. See? Its all about whether _you_ need the protection or not, not about whether LMI wants the money or not. [...] Finally, just to make it clear: not only do I not get a cent of the trademark money, but even LMI (who actually administers the mark) has so far historically always lost money on it. Thats not a way to sustain a

trademark, so theyre trying to at least become self-sufficient, but so far I can tell that lawyers fees to _give_ that protection that commercial companies want have been higher than the license fees. Even pro bono lawyers charge for the time of their costs and paralegals etc. Linus Torvalds [36] The Linux Mark Institute has since begun to offer a free, perpetual worldwide sublicense.[37]

3. Write a shell script to reverse the arguments passed as parameters. For ex: sh demo one two three, three two one then output should be

4. Compare and contrast different shells available in Linux

Different Kinds of Shells


The great-grandfather of all shells is /bin/sh, called simply sh or the Bourne Shell, named after its developer, Steven Bourne. When it was first introduced in the mid1970s, this was almost a godsend as it allowed interaction with the operating system. This is the "standard" shell that you will find on every version in UNIX (at least all those I have seen). Although many changes have been made to UNIX, sh has remained basically unchanged. All the capabilities of "the shell" I've talked about so far apply to sh. Anything I've talked about that sh can do, the others can do as well. So rather than going on about what sh can do (which I already did), I am going to talk about the characteristics of some other shells.

Later, I am going to talk about the C-Shell, which kind of throws a monkey wrench into this entire discussion. Although the concepts are much the same between the C-Shell and other shells, the constructs are often quite different. On the other hand, the other shells are extensions of the Bourne Shell, so the syntax and constructs are basically the same. Be careful here. This is one case in which I have noticed that the various versions of Linux are different. Not every shell is in every version. Therefore, the shells I am going to talk about may not be in your distribution. Have no fear! If there is a feature that you really like, you can either take the source code from one of the other shells and add it or you can find the different shells all over the Internet, which is much easier. Linux includes several different shells and we will get into the specific of many of them as we move along. In addition, many different shells are available as either public domain, shareware, or commercial products that you can install on Linux. As I mentioned earlier, environment variables are set up for you as you are logging in or you can set them up later. Depending on the shell you use, the files used and where they are located is going to be different. Some variables are made available to everyone on the system and are accessed through a common file. Others reside in the user's home directory. Normally, the files residing in a users home directory can be modified. However, a system administrator may wish to prevent users from doing so. Often, menus are set up in these files to either make things easier for the user or to prevent the user from getting to the command line. (Often users never need to get that far.) In other cases, environment variables that shouldn't be changed need to be set up for the user. One convention I will be using here is how I refer to the different shells. Often, I will say "the bash" or just "bash" to refer to the Bourne-Again Shell as a concept and not the program /bin/bash. I will use "bash" to refer to the "Bourne Shell" as an abstract entity and not specifically to the program /bin/sh. Why the Bourne-Again Shell? Well, this shell is compatible with the Bourne Shell, but has many of the same features as both the Korn Shell (ksh) and C-Shell (csh). This is especially important to me as I flail violently when I don't have a Korn Shell. Most of the issues I am going to address here are detailed in the appropriate manpages and other documents. Why cover them here? Well, in keeping with one basic premise of this book, I want to show you the relationships involved. In addition, many of the things we are going to look at are not emphasized as much as they should be. Often, users will go for months or years without learning the magic that these shells can do. Only one oddity really needs to be addressed: the behavior of the different shells when moving through symbolic links. As I mentioned before, symbolic links are simply pointers to files or directories elsewhere on the system. If you change directories into symbolic links, your "location" on the disk is different than what you might think. In

some cases, the shell understands the distinction and hides from you the fact that you are somewhere else. This is where the problem lies. Although the concept of a symbolic link exists in most versions of UNIX, it is a relatively new aspect. As a result, not all applications and programs behave in the same way. Let's take the directory /usr/spool as an example. Because it contains a lot of administrative information, it is a useful and commonly accessed directory. It is actually a symbolic link to /var/spool. If we are using ash as our shell, when we do a cd /usr/spool and then pwd, the system responds with: /var/spool. This is where we are "physically" located, despite the fact that we did a cd /usr/spool. If we do a cd .. (to move up to our parent directory), we are now located in /var. All this seems logical. This is also the behavior of csh and sh on some systems. If we use bash, things are different. This time, when we do a cd /usr/spool and then pwd, the system responds with /usr/spools. This is where we are "logically". If we now do a cd .., we are located in /usr. Which of these is the "correct" behavior? Well, I would say both. There is nothing to define what the "correct" behavior is. Depending on your preference, either is correct. I tend to prefer the behavior of ksh. However, the behavior of ash is also valid.

What is a Shell?
The term "shell" sometimes confuses beginners. When referred to by Linux users, the term "shell" means using the command line interface. It is important to know that using a shell is similar to use the DOS prompt. Linux also has a GUI (Graphical User Interface - pronounced gew-eee that is similar to Windows. Using the shell is often frustrating for beginners because you must know the commands, what they do, and the proper way to enter them. This means using the correct syntax. The Linux OS is controlled by the kernel, which is the heart of entire system. However, the kernel can only understand machine code. This is why a shell must be used. The shell interprets commands given by the user and translates them into machine code that the kernel can understand.

Types of Shells
There are several different types of shells available. Each shell has its own pro's and con's, but each shell can perform the same basic tasks. The main difference between them is the prompt, and how they interpret commands. The table below shows the most common shells and their attributes.

Shell Name

Ash

Bourne

Bash (Bourne Again)


Brian Fox/Chet Ramey

Korn

C-shell

T-shell

Zsh

Author Binary Default

Kenneth Almquist ash sh $

Eric Gisin ksh $ csh %

William Joy tcsh %

Paul Falstad zsh

bash $

Prompt

The most common shell used by default on Linux systems is bash. In bash, the default prompt for a user is a $ sign. Unless you are logged in as root in which case it the # sign. As you can see by the output below, the root (administrator) is logged in and the # sign is displayed [which I have labeled red].

[root@roswell root]# ll total 12372 -rw-r--r-1 root root 1600 -rwxr--r-1 nobody nobody 10044856 RELEASE_20-Linux-i686-glibc-2.1.tar.gz drwx-----2 root root 4096 -rw-r--r-1 root root 20135 -rw-r--r-1 root root 3934 -rw-r--r-1 root root 734 -rwxr--r-1 nobody nobody 2448372 -rw-r--r-1 root root 109773 [root@roswell root]#

Jul 22 18:01 anaconda-ks.cfg Jul 30 07:03 Cpanel-7.1.0Jul Jul Jul Jul Jul Jul 4 22 22 27 26 27 2003 18:00 18:00 06:17 22:50 05:08 cpdist install.log install.log.syslog smb.conf snort-2.gz squid.conf

Notice the prompt changes when weaponx (standard user) is logged in. It is now a standard $ sign, which I have labeled in green.

[weaponx@roswell weaponx]$ ll total 4 -rw-rw-r-1 weaponx weaponx [weaponx@roswell weaponx]$

203 Jul 31 04:39 overflow.c

Switching Shells
Upon installation, you are prompted as to what shells you want installed. You can also specify a shell for each user. Let's say that weaponx wants to switch from the bash shell (bash) to the bourne shell (sh). Notice the output below:

[weaponx@roswell weaponx]$ sh sh-2.05b$


Now that weaponx is using the boune shell, lets see how this shell interprets the long listing command.

sh-2.05b$ ll sh: ll: command not found sh-2.05b$


Ah, it didn't work! If we use the same command in the bourne again shell (bash), we get a different output.

sh-2.05b$ bash [weaponx@roswell weaponx]$ ll total 4 -rw-rw-r-1 weaponx weaponx

203 Jul 31 04:39 overflow.c

[weaponx@roswell weaponx]$
That is just a simple example of how different shells handle commands. Note that some shells will not perform certain extended commands. Using bash is your best bet. It is the most common, and rather easy to learn once you get the hang of it. If you would like to see a list of common bash commands click here.

Using the Bash Shell


If you don't know what a shell is, click here. Using a shell for the first time can be difficult; especially to native Windows users. The best way to become comfortable with a shell is by practice. Initially, I hated using a shell. I thought the idea of typing in commands was monotonous. Now I live by the shell! Below you will find several examples of how to navigate through Linux using the bash shell.

Changing Directories
Changing directories is a rather simple process; most people remember it from the days of DOS. Using the cd command, you can navigate through the entire directory tree. Extended commands permit users to skip multiple files directories. Notice the output below:

[weaponx@roswell weaponx]$ ls overflow.c [weaponx@roswell weaponx]$ cd / [weaponx@roswell /]$ ls bin boot dev etc export home sbin tmp usr var [weaponx@roswell /]$

initrd

lib

misc

mnt

opt

proc

root

Notice that cd followed by

/ takes us to the main directory. We can get back to our home directory buy

using the cd command followed by the full path.

[weaponx@roswell /]$ ls bin boot dev etc export home initrd sbin tmp usr var [weaponx@roswell /]$ cd /home/weaponx/ [weaponx@roswell weaponx]$ ls overflow.c [weaponx@roswell weaponx]$

lib

misc

mnt

opt

proc

root

Create, Delete, and Move


Initially, you will want to create, copy paste, and delete files. Upon logging in, your shell will start in the /home directory. Below I am logged in as the user weaponx. You can always check what directory you are currently working in by using the pwd command. Short for Print Working Directory. Do not get this command confused with the passwd, the command for changing your password.

[weaponx@roswell weaponx]$ pwd /home/weaponx [weaponx@roswell weaponx]$

Using the ls command, the only file in the home directory is the overflow.c file.

[weaponx@roswell weaponx]$ ls overflow.c [weaponx@roswell weaponx]$

Red Hat and other distros of Linux will color code the output to help users distinguish between files, folders, and zip files. This is very handy when you have a directory full of files and other folders. Moving on, let's say that we want to created a .txt file named hello. Using the touch command this is very simple.

[weaponx@roswell weaponx]$ touch hello.txt [weaponx@roswell weaponx]$ ls hello.txt overflow.c [weaponx@roswell weaponx]$

As you can see the file was created. That might even be faster than doing a right-mouse click and selecting new text document. Although the file has been created, it blank. To edit the file, you must use an editor such as vim. Now, let's say we don't want that file anymore and we want to delete it. This can be done using the rm command.

[weaponx@roswell weaponx]$ rm hello.txt [weaponx@roswell weaponx]$ ls overflow.c [weaponx@roswell weaponx]$

Easy enough right? However, there is no "un-delete" or "restore" command in Linux. Be careful what you delete! NOTE: NEVER EXECUTE THIS COMMAND, rm -rf / Doing so will delete the entire filesystem without asking any questions! Don't be tricked by advanced users trying to play a trick on you... Now let's re-create the file (for practice) and create another folder named files. After that, we'll move the hello.txt file into the files folder. Use the mkdir to create directories, and the mv command to move files.

[weaponx@roswell weaponx]$ touch hello.txt [weaponx@roswell weaponx]$ mkdir files [weaponx@roswell weaponx]$ ls files hello.txt overflow.c [weaponx@roswell weaponx]$ mv hello.txt files [weaponx@roswell weaponx]$ ls files overflow.c [weaponx@roswell weaponx]$ cd files [weaponx@roswell files]$ ls hello.txt [weaponx@roswell files]$

Let look closely at the usage of the mv command. mv is followed by the file name, then the destination directory. More specifically, like this: mv filename destination

[weaponx@roswell weaponx]$ mv hello.txt files

Linking Files
There will be times when you will want to create "links" without moving files. This works like creating a shortcut to your desktop. You can do this using the ln command. See the output below:

[weaponx@roswell [weaponx@roswell hello.txt [weaponx@roswell [weaponx@roswell files hello.txt [weaponx@roswell

files]$ ln hello.txt /home/weaponx/ files]$ ls files]$ cd .. weaponx]$ ls overflow.c weaponx]$

Walking through it again, the usage is rather simple. ln is followed by the file name, then the destination. More specifically, like this: ln filename destination

[weaponx@roswell files]$ ln hello.txt /home/weaponx/


The result is simple, it creates a link to the hello.txt files located in the files directory. However, when using the rm command, only the link will be removed. The original file will still reside in the "files" directory.

. 5. Write a shell script that takes directory name as an argument and displays the count of empty files, ordinary files and directories.

M.Sc.(IT) 3rd Semester

MSIT-3A

Linux Internals (LI)

Assignment - TB PART - A 1. Enlist the important features at Linux operation environment.

The Linux Operating System


Linux is a powerful, non-proprietary, standards-based operating system that is currently the fastest growing computer operating system on the planet. Linux offers speed, performance, stability, and reliability that rivals (or surpasses) that of commercial operating systems costing hundreds or thousands of dollars. Linux contains all the features required of modern desktop PCs, corporate file servers, firewalls, routers, and Internet servers. Its install base is conservatively estimated at over 10,000,000, and is growing at a rate of approximately 3% per week. In fact, Linux market share surged by 212 percent in 1998, and it is the only non-proprietary operating system that is currently demonstrating positive growth. Since it is made available under the GNU Public License as an open source product, Linux may be downloaded free of charge via the Internet, or purchased for a small fee on CD-ROM. Although Linux was originally designed to operate only on Intel-based PCs, portable and modular coding has allowed it to become increasingly hardware independent. Today, Linux operates on an impressive and growing list ofhardware platforms. On the low-end, it powers IBM's Watchpad, G.Mate's Yopy and Sharp's Zaurus Personal Data Assistants. On the highend, it is used in a growing number of supercomputing environments. Avalon, a supercomputer developed at the Los Alamos National Laboratory, operates under the Linux operating system and was recently rated among the 500 fastest computers in the world. NASA uses parallel Linux clusters as part of theirBeowulf supercomputer. In 1998, Cranfield University (UK) replaced its Cray supercomputer with a Linux-based system of networked Pentium II PCs

it calls the Borg. Stanford University uses Linux to power the World's Smallest Web Server. Linux is also finding its way into embedded devices that are used in a growing number of modern electronic devices. The TiVO digital video recorder is based on Linux, and Linux is even finding its way into modern high definition television sets. The fast and powerful Google Internet Search Engine is Linux powered. Linux even runs on Apple Power Macintosh and iMac computers! With the downturn in the economy, Linux is proving itself valuable in nonproprietary network routers that offer performance with a cost/benefit ratio unmatched by proprietary routers, such as those by Cisco Systems. The number of Linux devices is growing at a very healthy rate!

Why Run Linux?


Much of the success of Linux is due not only to its outstanding performance, but also by the fact that it is a non-commercial, non-proprietary, open source product. Much like the Internet, Linux brings with it a freedom and openness that has not been seen in the computer industry in many years. No longer are large, domineering companies like Microsoft dictating what users can and cannot do with their computers. No longer are computer users being treated as pawns in Microsoft's unethical (and illegal) practices of predatory capitalism. No longer are computer users the slaves of greed, aggregate wealth, or the whims of a single, domineering software company whose only concern is the "bottom line". With Linux, there is no "bottom line". Instead, success is measured by performance and design excellence. A survey conducted of Information Technology executives attending last December's Giga Emerging Technology Scene conference concluded that 58 percent of computer users are ready to drop Windows for Linux. The survey also painted Microsoft as the software vendor least trusted to deliver on its promises, and Linux as the platform to which computer users would most likely move. Today, Linux is receiving strong support from forward-thinking computer industry giants such as Netscape, AOL, Intel, IBM, HP, Dell, Sun, Oracle, Informix, Sybase, Compaq, Silicon Graphics Inc., and Novell, as well as many smaller companies who have traditionally aligned themselves with Microsoft in

the past. These actions, and the trend it suggests, are an indication that a growing number of companies see a brighter future for Linux than they do for Microsoft Windows. Amerada Hess Corporation, a $6.6 billion oil company, recently replaced an IBM SP2 supercomputer with a 32-node cluster of PCs running Linux. Amerada Hess decided against using Windows NT because it would have required them to re-write an application containing three million lines of code, an effort that was judged to be impractical. The United States Postal Service bases its optical character recognition system for reading mail nationwide on 6,000 computers running Linux. Linux was also found to be powerful and reliable enough to power a supercomputer at the Los Alamos National Laboratory. (Would you trust a nuclear lab that used Microsoft Windows to control its equipment?) And then there's the issue of cost. Linux may be downloaded for free via the Internet or purchased for a small fee on CD-ROM. Proprietary operating systems such as Microsoft Windows can be extremely expensive, not just initially, but also over time if the cost of software upgrades, hardware upgrades, and lost time and productivity due to crashes and viruses are also taken into account. In fact, migrating to Windows 2000 is seen by The Gartner Group as a "money losing proposition". The Group's report concluded that the cost of moving to Windows 2000 could be as much as $3,100 per PC, making it difficult for companies to achieve any return on their investment for at least three years. A few of the growing number of articles demonstrating the superiority of Linux over other operating systems include:

The K12 Linux Project Using Linux in Business Will You Be Cracked Next? What Alternatives Are There To Microsoft? Operating Systems Comparison Chart The Last Dinosaur and the Tarpits of Doom Replacing Windows NT Server with Linux The Internet Operating System Counter CNN - How Linux Got So Dang Hot The Penguin That Roared Why Linux Quite Appropriately Scares the Bejesus Out Of Microsoft

Why People Don't Hate Linux

Another TechWeb report stated the following about Linux: "It's in everyone's best interest for Linux to succeed [except Microsoft] because it can only represent growth of market opportunity for anyone who makes enterprise software for Intel, and for many companies, including Intel, it also represents a hedge against NT." Several Linux Certification Programs are already in existence to provide training and evaluate the knowledge of Linux professionals.

Linux In The Corporate World


The following links detail some of the many advantages of using Linux over Microsoft Windows in the corporate world:

IBM Software for Linux E*Trade Switches To Linux Forbes.com: Wall Street Embraces Linux Oracle's Whole Business To Run On Linux DreamWorks Feature Linux and Animation International Trucks Turns to Linux Linux in Business

Linux Supercomputing Links


The following links describe the use of Linux in high-end supercomputing environments:

Beowulf Project at CESDIS Avalon Duke University's Linux-based Distributed Parallel Supercomputer Loki - Commodity Parallel Processing Grendel: The Clemson Beowulf Workstation UC Irvine Aeneas Supercomputer

Linux Routing
The following links demonstrate the use of Linux in network routing applications, and in some cases, its superiority to proprietary Cisco hardware and IOS firmware:

Linux Advanced Routing and Traffic Control GNU Zebra Routing Software 802.1Q VLAN Implementation for Linux Linux VLAN + Cisco HOWTO ImageStream Internet Solutions, Inc. - Cisco Comparison Linux Embedded Appliance Firewall FREESCO (Free ciSCO) Linux-based Routing floppyfw: A Linux-based Static Router/Firewall SearchEnterpriseLinux: Linux Routers - Part 1 SearchEnterpriseLinux: Linux Routers - Part 2 Extreme Networks puts Linux to work in routing switch

Linux In Consumer Products


Linux doesn't just run on desktop PCs and servers. It is also found in a growing number of consumer products, automobiles, and media players:

Audio/Video entertainment devices with Linux inside Mobile-phones and Internet-phones with Linux inside Linux-based tablets and webpads Linux-based Cool Devices Other Smart Devices with Linux Inside Linux PDA Quick Reference Guide LynuxWorks (Embedded Linux) MontaVista Software Linux Devices The Embedded Linux Consortium

Linux Links
More news and information on Linux in general may be found through the following links:

Linux Links news.google.com NewsNow userlocal.com kernel.org Linux Powered.com Linux.com JustLinux LinuxPlanet Screaming Penguin Linux On-Line Linux Weekly News LinuxWorld LinuxToday Linux Resource Exchange Debian Weekly News www.tux.org Slashdot.Org LinuxHQ Linux.org.uk Focus On Linux Linux Documentation Project Linux Games Linux International Linux Central Linuxberg LinuxFocus Linux Journal Magazine Humorix: All Linux Humor Linux Magazine: Open Source. Open Standards

Linux Vendors and Distributors


Who says you can't make money with a free software? :-)

IBM Hewlett-Packard Red Hat Software SuSE Linux Debian Linux Slackware Linux (My personal favorite for the past 15 years!) Penguin Computing

Linux Screen Shots


Interested in how the screen of a computer running Linux appears? The following links show screen shots of several different window managers operating under Linux:

Enlightenment KDE Screenshots GNOME Screenshots Ice Window Manager Screen Shots

Windows NT? Windows XP? Vista? No Thanks!


Has Microsoft or the Microsoft-biased trade journals persuaded you into believing that Windows NT, Windows 2000, or Windows XP actually make better networking environment than veteran OSs such as Unix or Novell Netware?Guess again! This small sampling of articles show how Microsoft's claims just aren't true, and that some who believed the hype and switched to Windows are now sorry they ever did:

Windows 2000 Security (Including Demonstrations!) Windows 2000 Bugs (February, 2000) Probing Into C2 Security Claims: Is NT As Secure As Microsoft Has Said It Is?

The NT Files BBC News: Windows To Lose Crown Within Five Years BugNet: Windows NT -- Spawn of the Devil? Windows NT Hits Wall Street The Hard and True Facts About NT's BSOD Broken Hardware Mythology Known NT Exploits 'Real' Designers Reject Windows NT Huge US Department of Labor Computer Crash: Was it NT? Unix Growth Still Outpaces Win NT Intelligent Virus Surfaces on NT ServersI

What About Windows 95/98?


Are "Blue Screens of Death" (BSODs) a trademark of quality and reliability? Are system crashes and cryptic error messages that make no logical sense considered "user friendly"?

Bugs, crashes, viruses, security holes, "Illegal Operations", and poor performance have become generally accepted attributes of Microsoft operating systems. In 2000, the number of computer viruses was estimated at being 50,000, the majority of which affected only computers running Microsoft operating systems. By September 2001, these viruses caused 10.7 billion U.S. dollars in damage. The total reported number of Linux viruses for the same period: Just one. Is the solution to this problem solved by increased use of virus protection software? No, it isn't. The answer is a well-designed computing environment that is immune to viruses and the damage they inflict on people and businesses. The following links discuss some of these issues in further detail, and offer assistance to those who continue to use Microsoft products:

What's So Bad About Microsoft? Internet Explorer Bugs (Including Demonstrations!) CERT Recommends Anything But Internet Explorer Cut Internet Explorer from Windows 98 With Your Own Bare Hands Microsoft Financial Fraud Locking Windows' Backdoors A Flaw Worse Than Melissa Bug Finder Exposes MS Again Windows 95 Problems Inside The Windows 95 Registration Wizard Dirty Little Secrets About Windows 95 Windows 98 Gripes Microsoft Code Has No Bugs (that Microsoft cares about) ActiveX Viruses ActiveX (or how to put nuclear bombs in web pages)

Microsoft DNA: What Does It Really Stand For? BugNet: Windows 98 Special Report

"Windows is an utter kludge, the ultimate tar baby, sucking you in, making things harder and harder, until you are hopelessly snagged and stuck, exhausted from fighting with it, resigned to despair. It is an inscrutable, god-awful mess, a disaster waiting to happen, a bonehead botch-job jammed with you-can't-get-there-from-here idiocy. They could train soldiers to kill by forcing them to struggle with this. It's bizarre that so many of us routinely put up with the crashes, the snarls, the unintuitive workarounds, the billions of hours wasted fumbling with broken systems, nursing along this crippled basket-case of an OS. Where is the outrage over so many lost hours of torment and unproductivity?" PAUL SOMERSON, PC Computing

Microsoft: An Illegal Monopoly


The United States Department of Justice has made clear its Conclusions of Law and Final Order regarding Microsoft's violation of the Sherman Antitrust Act. Additional lawsuits against Microsoft are expected to mount over timeantitrust issues as the US Justice Department indicates on its web page.

Wendy Goldman Rohm's new book entitled: The Microsoft File: The Secret Case Against Bill Gates (ISBN: 0-8129-2716-8), provides an inside look at Microsoft Corporation and the unethical, underhanded, and possibly illegal tactics used by the company to thwart competition and stifle innovation at the

expense of consumers. Further information, as well as reviews of this new book are available through amazon.com. Wendy Goldman Rohm has also authored an article entitled, "Is Microsoft Trampling on First Amendment Rights?", that may be read on-line. James Gleick published an article in the New York Times Magazine that discusses The Microsoft Monopoly. In this article, Gleick documents Microsoft's anti-competitive practices in detail, along with choice quotes from Gates, Ballmer, and other high technology executives both inside and outside the company. A recent article entitled, GE, Microsoft Bring Bigotry To Life discusses the recent move by MSNBC to hire a bigoted talk show host for airing on a weekly basis. (MSNBC is co-owned by General Electric/NBC and Microsoft.)

Microsoft's Halloween Documents


Further evidence of Microsoft's sinister, underhanded, and predatory business tactics were made clear recently through several documents leaked to sources outside of Microsoft several years ago. These documents have become known as The Halloween Documents, and indicate exactly how seriously Microsoft takes the threat from Linux and other open-source projects, and reveal in detail the dirty tricks Microsoft (at the expense of consumers) is willing to use to stop them. On the bright side, these documents also reveal just how much Microsoft engineers were shocked by the performance of Linux after having installed it on a 100 MHz Pentium-based PC

2. Specify any two commands for finding files.

Linux: Finding and Locating files with find command part # 1


by NI XC RA FT on JULY 22, 2005 14 CO MMEN TS

Many newcomers find it difficult use the find command at shell prompt under Linux / *BSD or Solairs UNIX oses. Find is nifty tool on remote server where UNIX admin can find out lot of information too. Desktop users may find handy GNOME Search tool as a utility for finding files on system. Find command can perform a search based on a variety of search constraints. It searches through one or more directory tree(s) of a filesystem, locating files based on some user-specified criteria. By default, find returns all files below the current working directory. Further, find allows the user to specify an action to be taken on each matched file. Thus, it is an extremely powerful program for applying actions to many files. It also supports regexp matching.

GNOME Search Tool GUI Program


GNOME Search Tool is a utility for finding files on your system. To perform a basic search, you can type a filename or a partial filename, with or without wildcards. You can start this program from menus or by typing following command at shell prompt:
$ gnome-search-tool &

Internally GNOME Search Tool uses the find, grep, and locate UNIX commands. The case sensitivity of the search depends on your operating system. For example, on Linux, the find, grep, and locate commands support the -i option, so all searches are case-insensitive.

(click to enlarge)

Find command syntax


find {search-path} {file-names-to-search} {action-to-take} Where, search-path : Define search path (default current directory). For example search in /home file-names-to-search : Name of the file you wish to find. For example all c files (*.c)

directory.

action-to-take : Action can be print file name, delete files etc. Default action is print file

names.

Find command examples


Let us try out some examples.

Finding files and printing their full name


You wish to find out all *.c (all c source code) files located under /home directory, enter:
$ find /home -name "*.c"

You would like to find httpd.conf file location:


$ find / -name httpd.conf

Finding all files owned by a user


Find out all files owned by user vivek:
# find / -user vivek

Find out all *.sh owned by user vivek:


# find / -user vivek -name "*.sh"

Finding files according to date and time


Files not accessed in a time period It is useful to find out files that have or have not been accessed within a specified number of days. Following command prints all files not accessed in the last 7 days:
# find /home -atime +7

-atime +7: All files that were last accessed more than 7 days ago -atime 7: All files that were last accessed exactly 7 days ago -atime -7: All files that were last accessed less than7 days ago

Finding files modified within a specified time Display list of all files in /home directory that were not last modified less than then days ago.
# find /home -mtime -7

Finding newer (more recently) modified files


Use -newer option to find out if file was modified more recently than given file.
# find /etc/apache-perl -newer /etc/apache-perl/httpd.conf

Finding the most recent version of file


It is common practice before modifying the file is copied to somewhere in system. For example whenever I modify web server httpd.conf file I first make backup. Now I don't remember whether I had modified the /backup.conf/httpd.conf or /etc/apache-perl/httpd.conf. You can use the find command as follows (tip you can also use ls -l command):
find / -name httpd.conf -newer /etc/apache-perl/httpd.conf

Locate command
The locate command is often the simplest and quickest way to find the locations of files and directories on Linux and other Unix-like operating systems. For example, the following command uses the star wildcard to display all files on the system that have the .c filename extension:
# locate "*.c"

3. Differentiate between a process and a thread Threads vs Processes in Linux

up vote 32 down vote favorite 24 share [fb] share [tw] I've recently heard a few people say that in Linux, it is almost always better to use processes instead of threads, since Linux is very efficient in handling processes, and because there are so

many problems (such as locking) associated with threads. However, I am suspicious, because it seems like threads could give a pretty big performance gain in some situations.

So my question is, when faced with a situation that threads and processes could both handle pretty well, should I use processes or threads? For example, if I were writing a web server, should I use processes or threads (or a combination)?

linux performance multithreading processes link|improve this question asked Apr 30 '09 at 15:26

user17918 216156 Is there a difference with Linux 2.4? mouviciel Apr 30 '09 at 15:40 1 The difference between processes and threads under Linux 2.4 is that threads share more parts of their state (address space, file handles etc) than processes, which usually don't. The NPTL under Linux 2.6 makes this a bit clearer by giving them "thread groups" which are a bit like "processes" in win32 and Solaris. MarkR Apr 30 '09 at 20:34 Yes, NPTL is nice: it makes things like kill, exec, etc. work as you would expect in a threaded program (the old LinuxThreads behaviors make sense given the implementation, but were icky). OTOH a "thread group" is just a collection of "threads", and doesn't really take up resources itself, so it's a ton lighter-weight than a NT or Solaris process. ephemient Apr 30 '09 at 21:48 httpd.apache.org/docs/2.0/mod/worker.html is the default for apache webserver. its a multi process multi thread configuration. neal aise Jun 27 '10 at 1:29 feedback 11 Answersactiveoldestvotes up vote 36

down vote Linux uses a 1-1 threading model, with (to the kernel) no distinction between processes and threads -- everything is simply a runnable task. *

On Linux, the system call clone clones a task, with a configurable level of sharing, among which are:

CLONE_FILES: share the same file descriptor table (instead of creating a copy) CLONE_PARENT: don't set up a parent-child relationship between the new task and the old (otherwise, child's getppid() = parent's getpid()) CLONE_VM: share the same memory space (instead of creating a COW copy) fork() calls clone(least sharing) and pthread_create() calls clone(most sharing). **

forking costs a tiny bit more than pthread_createing because of copying tables and creating COW mappings for memory, but the Linux kernel developers have tried (and succeeded) at minimizing those costs.

Switching between tasks, if they share the same memory space and various tables, will be a tiny bit cheaper than if they aren't shared, because the data may already be loaded in cache. However, switching tasks is still very fast even if nothing is shared -- this is something else that Linux kernel developers try to ensure (and succeed at ensuring).

In fact, if you are on a multi-processor system, not sharing may actually be a performance boon: if each task is running on a different processor, synchronizing shared memory is expensive.

* Simplified. CLONE_THREAD causes signals delivery to be shared (which needs CLONE_SIGHAND, which shares the signal handler table).

** Simplified. There exist both SYS_fork and SYS_clone syscalls, but in the kernel, the sys_fork and sys_clone are both very thin wrappers around the same do_fork function, which itself is a thin wrapper around copy_process. Yes, the terms process, thread, and task are used rather interchangeably in the Linux kernel...

link|improve this answer answered Apr 30 '09 at 20:59

ephemient 46.3k349131 Very informative, thanks! Raj Sep 22 at 3:19 feedback

up vote 19 down vote Linux (and indeed Unix) gives you a third option.

Option 1 - processes Create a standalone executable which handles some part (or all parts) of your application, and invoke it separately for each process, e.g. the program runs copies of itself to delegate tasks to.

Option 2 - threads Create a standalone executable which starts up with a single thread and create additional threads to do some tasks

Option 3 - fork

Only available under Linux/Unix, this is a bit different. A forked process really is its own process with its own address space - there is nothing that the child can do (normally) to affect its parent's or siblings address space (unlike a thread) - so you get added robustness.

However, the memory pages are not copied, they are copy-on-write, so less memory is usually used than you might imagine.

Consider a web server program which consists of two steps:

Read configuration and runtime data Serve page requests If you used threads, step 1 would be done once, and step 2 done in multiple threads. If you used "traditional" processes, steps 1 and 2 would need to be repeated for each process, and the memory to store the configuration and runtime data duplicated. If you used fork(), then you can do step 1 once, and then fork(), leaving the runtime data and configuration in memory, untouched, not copied.

So there are really three choices.

link|improve this answer answered Apr 30 '09 at 20:41

MarkR 23.5k12751 feedback up vote 16 down vote

That depends on a lot of factors. Processes are more heavy-weight than threads, and have a higher startup and shutdown cost. Interprocess communication (IPC) is also harder and slower than interthread communication.

Conversely, processes are safer and more secure than threads, because each process runs in its own virtual address space. If one process crashes or has a buffer overrun, it does not affect any other process at all, whereas if a thread crashes, it takes down all of the other threads in the process, and if a thread has a buffer overrun, it opens up a security hole in all of the threads.

So, if your application's modules can run mostly independently with little communication, you should probably use processes if you can afford the startup and shutdown costs. The performance hit of IPC will be minimal, and you'll be slightly safer against bugs and security holes. If you need every bit of performance you can get or have a lot of shared data (such as complex data structures), go with threads.

link|improve this answer answered Apr 30 '09 at 15:37

Adam Rosenfield 80.9k11121217 1 Adam's answer would serve well as an executive briefing. For more detail, MarkR and ephemient provide good explanations. A very detailed explanation with examples may be found at cs.cf.ac.uk/Dave/C/node29.html but it does appear to be a bit dated in parts. CyberED Jan 6 '10 at 0:07 feedback up vote 6 down vote Others have discussed the considerations.

Perhaps the important difference is that in Windows processes are heavy and expensive compared to threads, and in Linux the difference is much smaller, so the equation balances at a different point.

link|improve this answer answered Apr 30 '09 at 17:50

dmckee 29.2k24288 feedback up vote 4 down vote The decision between thread/process depends a little bit on what you will be using it to. One of the benefits with a process is that it has a PID and can be killed without also terminating the parent.

For a real world example of a web server, apache 1.3 used to only support multiple processes, but in in 2.0 they added an abstraction so that you can swtch between either. Comments seems to agree that processes are more robust but threads can give a little bit better performance (except for windows where performance for processes sucks and you only want to use threads).

link|improve this answer answered Apr 30 '09 at 16:04

hlovdal 5,2241027

feedback up vote 2 down vote I'd have to agree with what you've been hearing. When we benchmark our cluster (xhpl and such), we always get significantly better performance with processes over threads. </anecdote>

link|improve this answer answered Apr 30 '09 at 15:37

eduffy 10.3k21538 feedback up vote 2 down vote How tightly coupled are your tasks?

If they can live independently of each other, then use processes. If they rely on each other, then use threads. That way you can kill and restart a bad process without interfering with the operation of the other tasks.

link|improve this answer answered Apr 30 '09 at 16:17

Robert

3,50831638 feedback up vote 2 down vote To complicate matters further, there is such a thing as thread-local storage, and Unix shared memory.

Thread-local storage allows each thread to have a separate instance of global objects. The only time I've used it was when constructing an emulation environment on linux/windows, for application code that ran in an RTOS. In the RTOS each task was a process with it's own address space, in the emulation environment, each task was a thread (with a shared address space). By using TLS for things like singletons, we were able to have a separate instance for each thread, just like under the 'real' RTOS environment.

Shared memory can (obviously) give you the performance benefits of having multiple processes access the same memory, but at the cost/risk of having to synchronize the processes properly. One way to do that is have one process create a data structure in shared memory, and then send a handle to that structure via traditional inter-process communication (like a named pipe).

link|improve this answer answered Apr 30 '09 at 21:33

KeyserSoze 1,6111715 I used thread-local storage for a some statistics gathering, the last time I was writing a threaded networks program: each thread wrote to its own counters, no locks needed, and only when messaged would each thread combine its stats into the global totals. But yeah, TLS is not very commonly used or necessary. Shared memory, on the other hand... in addition to efficiently

sending data, you can also share POSIX semaphores between processes by placing them in shared memory. It's pretty amazing. ephemient Apr 30 '09 at 21:57 feedback up vote 2 down vote Once upon a time there was Unix and in this good old Unix there was lots of overhead for processes, so what some clever people did was to create threads, which would share the same address space with the parent process and they only needed a reduced context switch, which would make the context switch more efficient.

In a contemporary Linux (2.6.x) there is not much difference in performance between a context switch of a process compared to a thread (only the MMU stuff is additional for the thread). There is the issue with the shared address space, which means that a faulty pointer in a thread can corrupt memory of the parent process or another thread within the same address space.

A process is protected by the MMU, so a faulty pointer will just cause a signal 11 and no corruption.

I would in general use processes (not much context switch overhead in Linux, but memory protection due to MMU), but pthreads if I would need a real-time scheduler class, which is a different cup of tea all together.

Why do you think threads are have such a big performance gain on Linux? Do you have any data for this, or is it just a myth?

link|improve this answer answered May 18 '09 at 15:56

robert.berger 66443 Yes, I do have some data. I ran a test that creates 100,000 processes and a test that creates 100,000 threads. The thread version ran about 9x faster (17.38 seconds for processes, 1.93 for threads). Now this does only test creation time, but for short-lived tasks, creation time can be key. user17918 May 19 '09 at 15:37 @user17918 - Is it possible for you to share the code used by you to calculate above mentioned timings .. codingfreak Mar 30 at 12:57 feedback up vote 1 down vote If you need to share resources, you really should use threads.

Also consider the fact that context switches between threads are much less expensive than context switches between processes.

I see no reason to explicitly go with separate processes unless you have a good reason to do so (security, proven performance tests, etc...)

link|improve this answer edited Apr 30 '09 at 15:44

ephemient 46.3k349131 answered Apr 30 '09 at 15:37

Yuval Adam 26.2k1070163 I do have the rep to edit, but I don't quite agree. Context switches between processes on Linux is almost as cheap as context switches between threads. ephemient Apr 30 '09 at 15:44 feedback up vote 1 down vote For most cases i would prefer processes over threads. threads can be useful when you have a relatively smaller task (process overhead >> time taken by each divided task unit) and there is a need of memory sharing between them. Think a large array. Also (offtopic), note that if your CPU utilization is 100 percent or close to it, there is going to be no benefit out of multithreading or processing. (in fact it will worsen)

. 4. What are meta charecters ? Give examples.


Definition: metacharacter: A character that is used to carry a special meaning, such as a caret (^, beginning of line), a dollar sign ($, end of line), or an asterisk (*, match any character). To use one of these characters without special meaning, you must either precede it with a backslash () or enclose it within quotation marks. Bypassing the special meaning of a metacharacter is called escaping or quoting the character.

9.2. Metacharacters, Listed by Linux Program


Some metacharacters are valid for one program but not for another. Those that are available to a given program are marked by a bullet ( ) in the following table. Notes are provided after the table, and full descriptions of metacharacters are in the following section.
Symb e se aw gre egre vi ol d d k p p
.

Action

Match any character (can match newline in gawk).

* ^ $ \ [] \(\) \n {} \{\} \<\> + ? | ()

Match zero or more preceding. Match beginning of line or string. Match end of line or string. Escape character following. Match one from a list or range. Store pattern for later replay. Reuse matched text stored in nth \( \). Match a range of instances. Match a range of instances. Match word's beginning or end. Match one or more preceding. Match zero or one preceding. Separate choices to match. Group expressions to match.

On some Linux systems, grep is a link to egrep, so whenever you run grep you actually get egrep behavior. In ed, vi, and sed, when you perform a search-and-replace (substitute) operation, the metacharacters in this table apply to the pattern you are searching for but not to the string replacing it. In awk, {} is specified in the POSIX standard and is supported by gawk if you run it with the -Wre-interval option. In ed, vi, and sed, the following additional metacharacters are valid only in a replacement pattern:

Symb e ol x
\ \n & ~ \e \E \l \L \u \U

se e d d

Action Escape character following. Reuse matched text stored in nth \( \). Reuse previous search pattern. Reuse previous replacement pattern. Turn off previous \L or \U. Turn off previous /L or /U. Change single following character to lowercase.

Change following characters to lowercase until /E encountered.


Change single following character to uppercase.

Change following characters to uppercase until \E encountered.

5. How do you mount a shared file system ?

mount(8) - Linux man page


Name
mount - mount a filesystem

Synopsis
mount [-lhV]

mount -a [-fFnrsvw] [-t vfstype] [-O optlist] mount [-fnrsvw] [-o option[,option]...] device|dir mount [-fnrsvw] [-t vfstype] [-o options] device dir

Description
All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the filesystem found on some device to the big file tree. Conversely, theumount(8) command will detach it again. The standard form of the mount command, is mount -t type device dir This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir. The previous contents (if any) and owner and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device. The listing and help. Three forms of invocation do not actually mount anything: mount -h prints a help message mount -V prints a version string mount [-l] [-t type] lists all mounted filesystems (of type type). The option -l adds the labels in this listing. See below. The device indication. Most devices are indicated by a file name (of a block special device), like /dev/sda1, but there are other possibilities. For example, in the case of an NFS mount, devicemay look like knuth.cwi.nl:/dir. It is possible to indicate a block special device using its volume LABEL or UUID (see the -L and -U options below). The recommended setup is to use LABEL=<label> or UUID=<uuid> tags rather than /dev/disk/by-{label,uuid} udev symlinks in the /etc/fstab file. The tags are more readable, robust and portable. The mount(8) command internally uses udev symlinks, so use the symlinks in /etc/fstab is not advantage over LABEL=/UUID=. For more details see libblkid(3).

The proc filesystem is not associated with a special device, and when mounting it, an arbitrary keyword, such as proc can be used instead of a device specification. (The customary choice none is less fortunate: the error message 'none busy' from umount can be confusing.) The /etc/fstab, /etc/mtab and /proc/mounts files. The file /etc/fstab (see fstab(5)), may contain lines describing what devices are usually mounted where, using which options. The command mount -a [-t type] [-O optlist] (usually given in a bootscript) causes all filesystems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated, except for those whose line contains the noauto keyword. Adding the -F option will make mount fork, so that the filesystems are mounted simultaneously. When mounting a filesystem mentioned in fstab or mtab, it suffices to give only the device, or only the mount point. The programs mount and umount maintain a list of currently mounted filesystems in the file /etc/mtab. If no arguments are given to mount, this list is printed. The mount program does not read the /etc/fstab file if device (or LABEL/UUID) and dir are specified. For example: mount /dev/foo /dir If you want to override mount options from /etc/fstab you have to use: mount device|dir -o <options> and then the mount options from command line will be appended to the list of options from /etc/fstab. The usual behaviour is that the last option wins if there is more duplicated options. When the proc filesystem is mounted (say at /proc), the files /etc/mtab and /proc/mounts have very similar contents. The former has somewhat more information, such as the mount options used, but is not necessarily up-to-date (cf. the -n option below). It is possible to replace /etc/mtab by a symbolic link to /proc/mounts, and especially when you have very large numbers of mounts things will be much faster with that symlink, but some information is lost that way, and in particular using the "user" option will fail. The non-superuser mounts. Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, anybody can mount the corresponding system. Thus, given a line /dev/cdrom /cd iso9660 ro,user,noauto,unhide

any user can mount the iso9660 filesystem found on his CDROM using the command mount /dev/cdrom or mount /cd For more details, see fstab(5). Only the user that mounted a filesystem can unmount it again. If any user should be able to unmount, then use users instead of user in thefstab line. The owner option is similar to the user option, with the restriction that the user must be the owner of the special file. This may be useful e.g. for /dev/fd if a login script makes the console user owner of this device. The group option is similar, with the restriction that the user must be member of the group of the special file. The bind mounts. Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is mount --bind olddir newdir or shortoption mount -B olddir newdir or fstab entry is: /olddir /newdir none bind After this call the same contents is accessible in two places. One can also remount a single file (on a single file). This call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using mount --rbind olddir newdir or shortoption mount -R olddir newdir Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example: mount --bind olddir newdir mount -o remount,ro newdir The move operation.

Since Linux 2.5.1 it is possible to atomically move a mounted tree to another place. The call is mount --move olddir newdir or shortoption mount -M olddir newdir This will cause the contents which previously appeared under olddir to be accessed under newdir. The physical location of the files is not changed. The shared subtrees operations. Since Linux 2.6.15 it is possible to mark a mount and its submounts as shared, private, slave or unbindable. A shared mount provides ability to create mirrors of thatmount such that mounts and umounts within any of the mirrors propagate to the other mirror. A slave mount receives propagation from its master, but any not vice-versa. A private mount carries no propagation abilities. A unbindable mount is a private mount which cannot cloned through a bind operation. Detailed semantics is documented inDocumentation/sharedsubtree.txt file in the kernel source tree.
mount mount mount mount --make-shared mountpoint --make-slave mountpoint --make-private mountpoint --make-unbindable mountpoint

The following commands allows one to recursively change the type of all the mounts under a given mountpoint.
mount mount mount mount --make-rshared mountpoint --make-rslave mountpoint --make-rprivate mountpoint --make-runbindable mountpoint

Command Line Options


The full set of mount options used by an invocation of mount is determined by first extracting the mount options for the filesystem from the fstab table, then applying any options specified by the o argument, and finally applying a -r or -w option, when present. Command line options available for the mount command: -V, --version Output version. -h, --help Print a help message. -v, --verbose Verbose mode.

-a, --all Mount all filesystems (of the given types) mentioned in fstab. -F, --fork (Used in conjunction with -a.) Fork off a new incarnation of mount for each device. This will do the mounts on different devices or different NFS servers in parallel. This has the advantage that it is faster; also NFS timeouts go in parallel. A disadvantage is that the mounts are done in undefined order. Thus, you cannot use this option if youwant to mount both /usr and /usr/spool. -f, --fake Causes everything to be done except for the actual system call; if it's not obvious, this ''fakes'' mounting the filesystem. This option is useful in conjunction with the -v flag to determine what the mount command is trying to do. It can also be used to add entries for devices that were mounted earlier with the -n option. The -f option checks for existing record in /etc/mtab and fails when the record already exists (with regular non-fake mount, this check is done by kernel). -i, --internal-only Don't call the /sbin/mount.<filesystem> helper even if it exists. -l Add the labels in the mount output. Mount must have permission to read the disk device (e.g. be suid root) for this to work. One can set such a label for ext2, ext3 or ext4 using the e2label(8) utility, or for XFS using xfs_admin(8), or for reiserfs using reiserfstune(8). -n, --no-mtab Mount without writing in /etc/mtab. This is necessary for example when /etc is on a read-only filesystem. --no-canonicalize Don't canonicalize paths. The mount command canonicalizes all paths (from command line or fstab) and stores canonicalized paths to the /etc/mtab file. This option can be used together with the -f flag for already canonicalized absolut paths. -p, --pass-fd num In case of a loop mount with encryption, read the passphrase from file descriptor num instead of from the terminal. -s Tolerate sloppy mount options rather than failing. This will ignore mount options not supported by a filesystem type. Not all filesystems support this option. This option exists for support of the Linux autofsbased automounter. -r, --read-only

Mount the filesystem read-only. A synonym is -o ro. Note that, depending on the filesystem type, state and kernel behavior, the system may still write to the device. For example, Ext3 or ext4 will replay its journal if the filesystem is dirty. To prevent this kind of write access, you may want to mount ext3 or ext4 filesystem with "ro,noload" mount options or set the block device to read-only mode, see command blockdev(8). -w, --rw Mount the filesystem read/write. This is the default. A synonym is -o rw. -L label Mount the partition that has the specified label. -U uuid Mount the partition that has the specified uuid. These two options require the file /proc/partitions (present since Linux 2.1.116) to exist. -t, --types vfstype The argument following the -t is used to indicate the filesystem type. The filesystem types which are currently supported include: adfs, affs, autofs, cifs, coda, coherent,cramfs, debugfs, devpts, efs, ext, ext2, ext3, ext4, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, ro mfs, squashfs,smbfs, sysv, tmpfs, ubifs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs. Note that coherent, sysv and xenix are equivalent and that xenix and coherent will be removed at some point in the future - use sysv instead. Since kernel version 2.1.21 the types ext and xiafs do not exist anymore. Earlier, usbfs was known as usbdevfs. Note, the real list of all supported filesystems depends on your kernel. The programs mount and umount support filesystem subtypes. The subtype is defined by '.subtype' suffix. For example 'fuse.sshfs'. It's recommended to use subtype notation rather than add any prefix to the mount source (for example 'sshfs#example.com' is depreacated). For most types all the mount program has to do is issue a simple mount(2) system call, and no detailed knowledge of the filesystem type is required. For a few types however (like nfs, nfs4, cifs, smbfs, ncpfs) ad hoc code is necessary. The nfs, nfs4, cifs, smbfs, and ncpfs filesystems have a separate mount program. In order to make it possible to treat all types in a uniform way, mount will execute the program /sbin/mount.TYPE (if that exists) when called with type TYPE. Since various versions of thesmbmount program have different calling conventions, /sbin/mount.smbfs may have to be a shell script that sets up the desired call. If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. Mount uses the blkid or volume_id library for guessing the filesystem type; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc and nfs). If /etc/filesystems ends in a line with a single * only, mount will read/proc/filesystems afterwards. The auto type may be useful for user-mounted floppies. Creating a file /etc/filesystems can be useful to change the probe order (e.g., to try vfat before msdos or ext3 before ext2) or if you use

a kernel module autoloader. Warning: the probing uses a heuristic (the presence of appropriate 'magic'), and could recognize the wrong filesystem type, possibly with catastrophic consequences. If your data is valuable, don't ask mount to guess. More than one type may be specified in a comma separated list. The list of filesystem types can be prefixed with no to specify the filesystem types on which no action should be taken. (This can be meaningful with the -a option.) For example, the command: mount -a -t nomsdos,ext mounts all filesystems except those of type msdos and ext. -O, --test-opts opts Used in conjunction with -a, to limit the set of filesystems to which the -a is applied. Like -t in this regard except that it is useless except in the context of -a. For example, the command: mount -a -O no_netdev mounts all filesystems except those which have the option _netdev specified in the options field in the /etc/fstab file. It is different from -t in that each option is matched exactly; a leading no at the beginning of one option does not negate the rest. The -t and -O options are cumulative in effect; that is, the command mount -a -t ext2 -O _netdev mounts all ext2 filesystems with the _netdev option, not all filesystems that are either ext2 or have the _netdev option specified. -o, --options opts Options are specified with a -o flag followed by a comma separated string of options. For example: mount LABEL=mydisk -o noatime,nouser For more details, see FILESYSTEM INDEPENDENT MOUNT OPTIONS and FILESYSTEM SPECIFIC MOUNT OPTIONS sections. -B, --bind Remount a subtree somewhere else (so that its contents are available in both places). See above. -R, --rbind Remount a subtree and all possible submounts somewhere else (so that its contents are available in both places). See above.

-M, --move Move a subtree to some other place. See above.

Filesystem Independent Mount Options


Some of these options are only useful when they appear in the /etc/fstab file. Some of these options could be enabled or disabled by default in the system kernel. To check the current setting see the options in /proc/mounts. The following options apply to any filesystem that is being mounted (but not every filesystem actually honors them - e.g., the sync option today has effect only for ext2, ext3, fat, vfat and ufs): async All I/O to the filesystem should be done asynchronously. (See also the sync option.) atime Do not use noatime feature, then the inode access time is controlled by kernel defaults. See also the description for strictatime and reatime mount options. noatime Do not update inode access times on this filesystem (e.g, for faster access on the news spool to speed up news servers). auto Can be mounted with the -a option. noauto Can only be mounted explicitly (i.e., the -a option will not cause the filesystem to be mounted). context=context, fscontext=context, defcontext=context and rootcontext=context The context= option is useful when mounting filesystems that do not support extended attributes, such as a floppy or hard disk formatted with VFAT, or systems that are not normally running under SELinux, such as an ext3 formatted disk from a non-SELinux workstation. You can also use context= on filesystems you do not trust, such as a floppy. It also helps in compatibility with xattr-supporting filesystems on earlier 2.4.<x> kernel versions. Even where xattrs are supported, you can save time not having to label every file by assigning the entire disk one security context. A commonly used option for removable media is context=system_u:object_r:removable_t. Two other options are fscontext= and defcontext=, both of which are mutually exclusive of the context option. This means you can use fscontext and defcontext with each other, but neither can be used with context.

The fscontext= option works for all filesystems, regardless of their xattr support. The fscontext option sets the overarching filesystem label to a specific security context. This filesystem label is separate from the individual labels on the files. It represents the entire filesystem for certain kinds of permission checks, such as during mount orfile creation. Individual file labels are still obtained from the xattrs on the files themselves. The context option actually sets the aggregate context that fscontext provides, inaddition to supplying the same label for individual files. You can set the default security context for unlabeled files using defcontext= option. This overrides the value set for unlabeled files in the policy and requires a filesystem that supports xattr labeling. The rootcontext= option allows you to explicitly label the root inode of a FS being mounted before that FS or inode because visable to userspace. This was found to be useful for things like stateless linux. For more details, see selinux(8) defaults Use default options: rw, suid, dev, exec, auto, nouser, and async. dev Interpret character or block special devices on the filesystem. nodev Do not interpret character or block special devices on the file system. diratime Update directory inode access times on this filesystem. This is the default. nodiratime Do not update directory inode access times on this filesystem. dirsync All directory updates within the filesystem should be done synchronously. This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename. exec Permit execution of binaries. noexec Do not allow direct execution of any binaries on the mounted filesystem. (Until recently it was possible to run binaries anyway using a command like /lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.) group

Allow an ordinary (i.e., non-root) user to mount the filesystem if one of his groups matches the group of the device. This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line group,dev,suid). iversion Every time the inode is modified, the i_version field will be incremented. noiversion Do not increment the i_version inode field. mand Allow mandatory locks on this filesystem. See fcntl(2). nomand Do not allow mandatory locks on this filesystem. _netdev The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system). nofail Do not report errors for this device if it does not exist. relatime Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.) norelatime Do not use relatime feature. See also the strictatime mount option. strictatime Allows to explicitly requesting full atime updates. This makes it possible for kernel to defaults to relatime or noatime but still allow userspace to override it. For more details about the default system mount options see /proc/mounts. nostrictatime Use the kernel's default behaviour for inode access time updates. suid

Allow set-user-identifier or set-group-identifier bits to take effect. nosuid Do not allow set-user-identifier or set-group-identifier bits to take effect. (This seems safe, but is in fact rather unsafe if you have suidperl(1) installed.) owner Allow an ordinary (i.e., non-root) user to mount the filesystem if he is the owner of the device. This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line owner,dev,suid). remount Attempt to remount an already-mounted filesystem. This is commonly used to change the mount flags for a filesystem, especially to make a readonly filesystem writeable. It does not change device or mount point. The remount functionality follows the standard way how the mount command works with options from fstab. It means the mount command doesn't read fstab (or mtab) only when a device and dir are fully specified. mount -o remount,rw /dev/foo /dir After this call all old mount options are replaced and arbitrary stuff from fstab is ignored, except the loop= option which is internally generated and maintained by the mountcommand. mount -o remount,rw /dir After this call mount reads fstab (or mtab) and merges these options with options from command line ( -o ). ro Mount the filesystem read-only. _rnetdev Like _netdev, except "fsck -a" checks this filesystem during rc.sysinit. rw Mount the filesystem read-write. sync All I/O to the filesystem should be done synchronously. In case of media with limited number of write cycles (e.g. some flash drives) "sync" may cause life-cycle shortening. user

Allow an ordinary user to mount the filesystem. The name of the mounting user is written to mtab so that he can unmount the filesystem again. This option implies the optionsnoexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid). nouser Forbid an ordinary (i.e., non-root) user to mount the filesystem. This is the default. users Allow every user to mount and unmount the filesystem. This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).

Filesystem Specific Mount Options


The following options apply only to certain filesystems. We sort them by filesystem. They all follow the o flag. What options are supported depends a bit on the running kernel. More info may be found in the kernel source subdirectory Documentation/filesystems.

Mount options for adfs


uid=value and gid=value Set the owner and group of the files in the filesystem (default: uid=gid=0). ownmask=value and othmask=value Set the permission mask for ADFS 'owner' permissions and 'other' permissions, respectively (default: 0700 and 0077, respectively). See also/usr/src/linux/Documentation/filesystems/adfs.txt.

Mount options for affs


uid=value and gid=value Set the owner and group of the root of the filesystem (default: uid=gid=0, but with option uid or gid without specified value, the uid and gid of the current process are taken). setuid=value and setgid=value Set the owner and group of all files. mode=value Set the mode of all files to value & 0777 disregarding the original permissions. Add search permission to directories that have read permission. The value is given in octal. protect Do not allow any changes to the protection bits on the filesystem.

usemp Set uid and gid of the root of the filesystem to the uid and gid of the mount point upon the first sync or umount, and then clear this option. Strange... verbose Print an informational message for each successful mount. prefix=string Prefix used before volume name, when following a link. volume=string Prefix (of length at most 30) used before '/' when following a symbolic link. reserved=value (Default: 2.) Number of unused blocks at the start of the device. root=value Give explicitly the location of the root block. bs=value Give blocksize. Allowed values are 512, 1024, 2048, 4096. grpquota|noquota|quota|usrquota These options are accepted but ignored. (However, quota utilities may react to such strings in /etc/fstab.)

Mount options for cifs


See the options section of the mount.cifs(8) man page (cifs-utils package must be installed).

Mount options for coherent


None.

Mount options for debugfs


The debugfs filesystem is a pseudo filesystem, traditionally mounted on /sys/kernel/debug. There are no mount options.

Mount options for devpts


The devpts filesystem is a pseudo filesystem, traditionally mounted on /dev/pts. In order to acquire a pseudo terminal, a process opens /dev/ptmx; the number of the pseudo terminal is then made available to the process and the pseudo terminal slave can be accessed as /dev/pts/<number>. uid=value and gid=value This sets the owner or the group of newly created PTYs to the specified values. When nothing is specified, they will be set to the UID and GID of the creating process. For example, if there is a tty group with GID 5, then gid=5 will cause newly created PTYs to belong to the tty group. mode=value Set the mode of newly created PTYs to the specified value. The default is 0600. A value of mode=620 and gid=5 makes "mesg y" the default on newly created PTYs. newinstance Create a private instance of devpts filesystem, such that indices of ptys allocated in this new instance are independent of indices created in other instances of devpts. All mounts of devpts without this newinstance option share the same set of pty indices (i.e legacy mode). Each mount of devpts with the newinstance option has a private set of pty indices. This option is mainly used to support containers in the linux kernel. It is implemented in linux kernel versions starting with 2.6.29. Further, this mount option is valid only if CONFIG_DEVPTS_MULTIPLE_INSTANCES is enabled in the kernel configuration. To use this option effectively, /dev/ptmx must be a symbolic link to pts/ptmx. See Documentation/filesystems/devpts.txt in the linux kernel source tree for details. ptmxmode=value Set the mode for the new ptmx device node in the devpts filesystem. With the support for multiple instances of devpts (see newinstance option above), each instance has a private ptmx node in the root of the devpts filesystem (typically/dev/pts/ptmx). For compatibility with older versions of the kernel, the default mode of the new ptmx node is 0000. ptmxmode=value specifies a more useful mode for the ptmx node and is highly recommended when the newinstance option is specified. This option is only implemented in linux kernel versions starting with 2.6.29. Further this option is valid only if CONFIG_DEVPTS_MULTIPLE_INSTANCES is enabled inthe kernel configuration.

Mount options for ext


None. Note that the 'ext' filesystem is obsolete. Don't use it. Since Linux version 2.1.21 extfs is no longer part of the kernel source.

Mount options for ext2


The 'ext2' filesystem is the standard Linux filesystem. Since Linux 2.5.46, for most mount options the default is determined by the filesystem superblock. Set them withtune2fs(8). acl|noacl Support POSIX Access Control Lists (or not). bsddf|minixdf Set the behaviour for the statfs system call. The minixdf behaviour is to return in the f_blocks field the total number of blocks of the filesystem, while the bsddf behaviour (which is the default) is to subtract the overhead blocks used by the ext2 filesystem and not available for file storage. Thus
% mount /k -o minixdf; df /k; umount /k Filesystem 1024-blocks Used Available Capacity Mounted on /dev/sda6 2630655 86954 2412169 3% /k % mount /k -o bsddf; df /k; umount /k Filesystem 1024-blocks Used Available Capacity Mounted on /dev/sda6 2543714 13 2412169 0% /k

(Note that this example shows that one can add command line options to the options given in /etc/fstab.) check={none|nocheck} No checking is done at mount time. This is the default. This is fast. It is wise to invoke e2fsck(8) every now and then, e.g. at boot time. debug Print debugging info upon each (re)mount. errors={continue|remount-ro|panic} Define the behaviour when an error is encountered. (Either ignore errors and just mark the filesystem erroneous and continue, or remount the filesystem read-only, or panic and halt the system.) The default is set in the filesystem superblock, and can be changed using tune2fs(8). grpid|bsdgroups and nogrpid|sysvgroups These options define what group id a newly created file gets. When grpid is set, it takes the group id of the directory in which it is created; otherwise (the default) it takes the fsgid of the current process, unless the directory has the setgid bit set, in which case it takes the gid from the parent directory, and also gets the setgid bit set if it is a directory itself. grpquota|noquota|quota|usrquota These options are accepted but ignored. nobh

Do not attach buffer_heads to file pagecache. (Since 2.5.49.) nouid32 Disables 32-bit UIDs and GIDs. This is for interoperability with older kernels which only store and expect 16-bit values. oldalloc or orlov Use old allocator or Orlov allocator for new inodes. Orlov is default. resgid=n and resuid=n The ext2 filesystem reserves a certain percentage of the available space (by default 5%, see mke2fs(8) and tune2fs(8)). These options determine who can use the reserved blocks. (Roughly: whoever has the specified uid, or belongs to the specified group.) sb=n Instead of block 1, use block n as superblock. This could be useful when the filesystem has been damaged. (Earlier, copies of the superblock would be made every 8192 blocks:in block 1, 8193, 16385, ... (and one got thousands of copies on a big filesystem). Since version 1.08, mke2fs has a -s (sparse superblock) option to reduce the number of backup superblocks, and since version 1.15 this is the default. Note that this may mean that ext2 filesystems created by a recent mke2fs cannot be mounted r/w under Linux2.0.*.) The block number here uses 1k units. Thus, if you want to use logical block 32768 on a filesystem with 4k blocks, use "sb=131072". user_xattr|nouser_xattr Support "user." extended attributes (or not).

Mount options for ext3


The ext3 filesystem is a version of the ext2 filesystem which has been enhanced with journalling. It supports the same options as ext2 as well as the following additions: journal=update Update the ext3 filesystem's journal to the current format. journal=inum When a journal already exists, this option is ignored. Otherwise, it specifies the number of the inode which will represent the ext3 filesystem's journal file; ext3 will create a new journal, overwriting the old contents of the file whose inode number is inum. journal_dev=devnum When the external journal device's major/minor numbers have changed, this option allows the user to specify the new journal location. The journal device is identified through its new major/minor numbers encoded in devnum. norecovery/noload

Don't load the journal on mounting. Note that if the filesystem was not unmounted cleanly, skipping the journal replay will lead to the filesystem containing inconsistencies that can lead to any number of problems. data={journal|ordered|writeback} Specifies the journalling mode for file data. Metadata is always journaled. To use modes other than ordered on the root filesystem, pass the mode to the kernel as boot parameter, e.g. rootflags=data=journal. journal All data is committed into the journal prior to being written into the main filesystem. ordered This is the default mode. All data is forced directly out to the main file system prior to its metadata being committed to the journal. writeback Data ordering is not preserved - data may be written into the main filesystem after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal filesystem integrity, however it can allow old data to appear in files after a crash and journal recovery. barrier=0 / barrier=1 This enables/disables barriers. barrier=0 disables it, barrier=1 enables it. Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. The ext3 filesystem does not enable write barriers by default. Be sure to enable barriers unless your disks are battery-backed one way or another. Otherwise you risk filesystem corruption in case of power failure. commit=nrsec Sync all data and metadata every nrsec seconds. The default value is 5 seconds. Zero means default. user_xattr Enable Extended User Attributes. See the attr(5) manual page. acl Enable POSIX Access Control Lists. See the acl(5) manual page.

Mount options for ext4


The ext4 filesystem is an an advanced level of the ext3 filesystem which incorporates scalability and reliability enhancements for supporting large filesystem.

The options journal_dev, noload, data, commit, orlov, oldalloc, [no]user_xattr [no]acl, bsddf, minixdf, debug, errors, data_err, grpid, bsdgroups, nogrpid sysvgroups, resgid, resuid, sb, quota, noquota, grpquota, usrquota and [no]bh are backwardly compatible with ext3 or ext2. journal_checksum Enable checksumming of the journal transactions. This will allow the recovery code in e2fsck and the kernel to detect corruption in the kernel. It is a compatible change and will be ignored by older kernels. journal_async_commit Commit block can be written to disk without waiting for descriptor blocks. If enabled older kernels cannot mount the device. This will enable journal=update Update the ext4 filesystem's journal to the current format. barrier=0 / barrier=1 / barrier / nobarrier This enables/disables the use of write barriers in the jbd code. barrier=0 disables, barrier=1 enables. This also requires an IO stack which can support barriers, and if jbd gets an error on a barrier write, it will disable again with a warning. Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. If your disks are battery-backed in one way or another, disabling barriers may safely improve performance. The mount options "barrier" and "nobarrier" can also be used to enable or disable barriers, for consistency with other ext4 mount options. The ext4 filesystem enables write barriers by default. inode_readahead=n This tuning parameter controls the maximum number of inode table blocks that ext4's inode table readahead algorithm will pre-read into the buffer cache. The default value is 32 blocks. stripe=n Number of filesystem blocks that mballoc will try to use for allocation size and alignment. For RAID5/6 systems this should be the number of data disks * RAID chunk size in filesystem blocks. delalloc Deferring block allocation until write-out time. nodelalloc Disable delayed allocation. Blocks are allocation when data is copied from user to page cache. max_batch_time=usec Maximum amount of time ext4 should wait for additional filesystem operations to be batch together with a synchronous write operation. Since a synchronous write operation is going to

force a commit and then a wait for the I/O complete, it doesn't cost much, and can be a huge throughput win, we wait for a small amount of time to see if any other transactions can piggyback on the synchronous write. The algorithm used is designed to automatically tune for the speed of the disk, by measuring the amount of time (on average) that it takes to finish committing a transaction. Call this time the "commit time". If the time that the transactoin has been running is less than the commit time, ext4 will try sleeping for the commit time to see if other operations will join the transaction. The commit time is capped by the max_batch_time, which defaults to 15000us (15ms). This optimization can be turned off entirely by setting max_batch_time to 0. min_batch_time=usec This parameter sets the commit time (as described above) to be at least min_batch_time. It defaults to zero microseconds. Increasing this parameter may improve the throughput of multithreaded, synchronous workloads on very fast disks, at the cost of increasing latency. journal_ioprio=prio The I/O priority (from 0 to 7, where 0 is the highest priorty) which should be used for I/O operations submitted by kjournald2 during a commit operation. This defaults to 3, which is a slightly higher priority than the default I/O priority. abort Simulate the effects of calling ext4_abort() for debugging purposes. This is normally used while remounting a filesystem which is already mounted. auto_da_alloc|noauto_da_alloc Many broken applications don't use fsync() when noauto_da_alloc replacing existing files via patterns such as fd = open("foo.new")/write(fd,..)/close(fd)/ rename("foo.new", "foo") or worse yet fd = open("foo", O_TRUNC)/write(fd,..)/close(fd). If auto_da_alloc is enabled, ext4 will detect the replace-via-rename and replace-via-truncate patterns and force that any delayed allocation blocks are allocated such that at the next journal commit, in the default data=ordered mode, the data blocks of the new file are forced to disk before the rename() operation is commited. This provides roughly the same level of guarantees as ext3, and avoids the "zero-length" problem that can happen when a system crashes before the delayed allocation blocks are forced to disk. discard/nodiscard Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done. nouid32

Disables 32-bit UIDs and GIDs. This is for interoperability with older kernels which only store and expect 16-bit values. resize Allows to resize filesystem to the end of the last existing block group, further resize has to be done with resize2fs either online, or offline. It can be used only with conjunction with remount. block_validity/noblock_validity This options allows to enables/disables the in-kernel facility for tracking filesystem metadata blocks within internal data structures. This allows multi- block allocator and other routines to quickly locate extents which might overlap with filesystem metadata blocks. This option is intended for debugging purposes and since it negatively affects the performance, it is off by default. dioread_lock/dioread_nolock Controls whether or not ext4 should use the DIO read locking. If the dioread_nolock option is specified ext4 will allocate uninitialized extent before buffer write and convert the extent to initialized after IO completes. This approach allows ext4 code to avoid using inode mutex, which improves scalability on high speed storages. However this does not work with nobh option and the mount will fail. Nor does it work with data journaling and dioread_nolock option will be ignored with kernel warning. Note that dioread_nolock code path is only used for extent-based files. Because of the restrictions this options comprises it is off by default (e.g. dioread_lock). i_version Enable 64-bit inode version support. This option is off by default.

Mount options for fat


(Note: fat is not a separate filesystem, but a common part of the msdos, umsdos and vfat filesystems.) blocksize={512|1024|2048} Set blocksize (default 512). This option is obsolete. uid=value and gid=value Set the owner and group of all files. (Default: the uid and gid of the current process.) umask=value Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal. dmask=value Set the umask applied to directories only. The default is the umask of the current process. The value is given in octal.

fmask=value Set the umask applied to regular files only. The default is the umask of the current process. The value is given in octal. allow_utime=value This option controls the permission check of mtime/atime. 20 If current process is in group of file's group ID, you can change timestamp. 2 Other users can change timestamp. The default is set from 'dmask' option. (If the directory is writable, utime(2) is also allowed. I.e. ~dmask & 022) Normally utime(2) checks current process is owner of the file, or it has CAP_FOWNER capability. But FAT filesystem doesn't have uid/gid on disk, so normal check is too unflexible. With this option you can relax it. check=value Three different levels of pickyness can be chosen: r[elaxed] Upper and lower case are accepted and equivalent, long name parts are truncated (e.g. verylongname.foobar becomes verylong.foo), leading and embedded spaces are acceptedin each name part (name and extension). n[ormal] Like "relaxed", but many special characters (*, ?, <, spaces, etc.) are rejected. This is the default. s[trict] Like "normal", but names may not contain long parts and special characters that are sometimes used on Linux, but are not accepted by MS-DOS are rejected. (+, =, spaces, etc.) codepage=value Sets the codepage for converting to shortname characters on FAT and VFAT filesystems. By default, codepage 437 is used. conv={b[inary]|t[ext]|a[uto]} The fat filesystem can perform CRLF<-->NL (MS-DOS text format to UNIX text format) conversion in the kernel. The following conversion modes are available:

binary no translation is performed. This is the default. text CRLF<-->NL translation is performed on all files. auto CRLF<-->NL translation is performed on all files that don't have a "well-known binary" extension. The list of known extensions can be found at the beginning offs/fat/misc.c (as of 2.0, the list is: exe, com, bin, app, sys, drv, ovl, ovr, obj, lib, dll, pif, arc, zip, lha, lzh, zoo, tar, z, arj, tz, taz, tzp, tpz, gz, tgz, deb, gif, bmp, tif, gl, jpg, pcx, tfm, vf, gf, pk, pxl, dvi). Programs that do computed lseeks won't like in-kernel text conversion. Several people have had their data ruined by this translation. Beware! For filesystems mounted in binary mode, a conversion tool (fromdos/todos) is available. This option is obsolete. cvf_format=module Forces the driver to use the CVF (Compressed Volume File) module cvf_module instead of autodetection. If the kernel supports kmod, the cvf_format=xxx option also controls on-demand CVF module loading. This option is obsolete. cvf_option=option Option passed to the CVF module. This option is obsolete. debug Turn on the debug flag. A version string and a list of filesystem parameters will be printed (these data are also printed if the parameters appear to be inconsistent). fat={12|16|32} Specify a 12, 16 or 32 bit fat. This overrides the automatic FAT type detection routine. Use with caution! iocharset=value Character set to use for converting between 8 bit characters and 16 bit Unicode characters. The default is iso8859-1. Long filenames are stored on disk in Unicode format. tz=UTC This option disables the conversion of timestamps between local time (as used by Windows on FAT) and UTC (which Linux uses internally). This is particularly useful when mounting devices (like digital cameras) that are set to UTC in order to avoid the pitfalls of local time.

quiet Turn on the quiet flag. Attempts to chown or chmod files do not return errors, although they fail. Use with caution! showexec If set, the execute permission bits of the file will be allowed only if the extension part of the name is .EXE, .COM, or .BAT. Not set by default. sys_immutable If set, ATTR_SYS attribute on FAT is handled as IMMUTABLE flag on Linux. Not set by default. flush If set, the filesystem will try to flush to disk more early than normal. Not set by default. usefree Use the "free clusters" value stored on FSINFO. It'll be used to determine number of free clusters without scanning disk. But it's not used by default, because recent Windows don't update it correctly in some case. If you are sure the "free clusters" on FSINFO is correct, by this option you can avoid scanning disk. dots, nodots, dotsOK=[yes|no] Various misguided attempts to force Unix or DOS conventions onto a FAT filesystem.

Mount options for hfs


creator=cccc, type=cccc Set the creator/type values as shown by the MacOS finder used for creating new files. Default values: '????'. uid=n, gid=n Set the owner and group of all files. (Default: the uid and gid of the current process.) dir_umask=n, file_umask=n, umask=n Set the umask used for all directories, all regular files, or all files and directories. Defaults to the umask of the current process. session=n Select the CDROM session to mount. Defaults to leaving that decision to the CDROM driver. This option will fail with anything but a CDROM as underlying device. part=n

Select partition number n from the device. Only makes sense for CDROMS. Defaults to not parsing the partition table at all. quiet Don't complain about invalid mount options.

Mount options for hpfs


uid=value and gid=value Set the owner and group of all files. (Default: the uid and gid of the current process.) umask=value Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal. case={lower|asis} Convert all files names to lower case, or leave them. (Default: case=lower.) conv={binary|text|auto} For conv=text, delete some random CRs (in particular, all followed by NL) when reading a file. For conv=auto, choose more or less at random between conv=binary andconv=text. For conv=binary, just read what is in the file. This is the default. nocheck Do not abort mounting when certain consistency checks fail.

Mount options for iso9660


ISO 9660 is a standard describing a filesystem structure to be used on CD-ROMs. (This filesystem type is also seen on some DVDs. See also the udf filesystem.) Normal iso9660 filenames appear in a 8.3 format (i.e., DOS-like restrictions on filename length), and in addition all characters are in upper case. Also there is no field for fileownership, protection, number of links, provision for block/character devices, etc. Rock Ridge is an extension to iso9660 that provides all of these unix like features. Basically there are extensions to each directory record that supply all of the additional information, and when Rock Ridge is in use, the filesystem is indistinguishable from a normal UNIX filesystem (except that it is read-only, of course). norock Disable the use of Rock Ridge extensions, even if available. Cf. map. nojoliet

Disable the use of Microsoft Joliet extensions, even if available. Cf. map. check={r[elaxed]|s[trict]} With check=relaxed, a filename is first converted to lower case before doing the lookup. This is probably only meaningful together with norock and map=normal. (Default: check=strict.) uid=value and gid=value Give all files in the filesystem the indicated user or group id, possibly overriding the information found in the Rock Ridge extensions. (Default: uid=0,gid=0.) map={n[ormal]|o[ff]|a[corn]} For non-Rock Ridge volumes, normal name translation maps upper to lower case ASCII, drops a trailing ';1', and converts ';' to '.'. With map=off no name translation is done. See norock. (Default: map=normal.) map=acorn is like map=normal but also apply Acorn extensions if present. mode=value For non-Rock Ridge volumes, give all files the indicated mode. (Default: read permission for everybody.) Since Linux 2.1.37 one no longer needs to specify the mode indecimal. (Octal is indicated by a leading 0.) unhide Also show hidden and associated files. (If the ordinary files and the associated or hidden files have the same filenames, this may make the ordinary files inaccessible.) block={512|1024|2048} Set the block size to the indicated value. (Default: block=1024.) conv={a[uto]|b[inary]|m[text]|t[ext]} (Default: conv=binary.) Since Linux 1.3.54 this option has no effect anymore. (And non-binary settings used to be very dangerous, possibly leading to silent data corruption.) cruft If the high byte of the file length contains other garbage, set this mount option to ignore the high order bits of the file length. This implies that a file cannot be larger than 16MB. session=x Select number of session on multisession CD. (Since 2.3.4.) sbsector=xxx Session begins from sector xxx. (Since 2.3.4.)

The following options are the same as for vfat and specifying them only makes sense when using discs encoded using Microsoft's Joliet extensions. iocharset=value Character set to use for converting 16 bit Unicode characters on CD to 8 bit characters. The default is iso8859-1. utf8 Convert 16 bit Unicode characters on CD to UTF-8.

Mount options for jfs


iocharset=name Character set to use for converting from Unicode to ASCII. The default is to do no conversion. Use iocharset=utf8 for UTF8 translations. This requires CONFIG_NLS_UTF8 to be set in the kernel .config file. resize=value Resize the volume to value blocks. JFS only supports growing a volume, not shrinking it. This option is only valid during a remount, when the volume is mounted read-write. The resize keyword with no value will grow the volume to the full size of the partition. nointegrity Do not write to the journal. The primary use of this option is to allow for higher performance when restoring a volume from backup media. The integrity of the volume is not guaranteed if the system abnormally abends. integrity Default. Commit metadata changes to the journal. Use this option to remount a volume where the nointegrity option was previously specified in order to restore normal behavior. errors={continue|remount-ro|panic} Define the behaviour when an error is encountered. (Either ignore errors and just mark the filesystem erroneous and continue, or remount the filesystem read-only, or panic and halt the system.) noquota|quota|usrquota|grpquota These options are accepted but ignored.

Mount options for minix


None.

Mount options for msdos


See mount options for fat. If the msdos filesystem detects an inconsistency, it reports an error and sets the file system read-only. The filesystem can be made writeable again by remounting it.

Mount options for ncpfs


Just like nfs, the ncpfs implementation expects a binary argument (a struct ncp_mount_data) to the mount system call. This argument is constructed by ncpmount(8) and the current version of mount (2.12) does not know anything about ncpfs.

Mount options for nfs and nfs4


See the options section of the nfs(5) man page (nfs-utils package must be installed). The nfs and nfs4 implementation expects a binary argument (a struct nfs_mount_data) to the mount system call. This argument is constructed by mount.nfs(8) and the current version of mount (2.13) does not know anything about nfs and nfs4.

Mount options for ntfs


iocharset=name Character set to use when returning file names. Unlike VFAT, NTFS suppresses names that contain unconvertible characters. Deprecated. nls=name New name for the option earlier called iocharset. utf8 Use UTF-8 for converting file names. uni_xlate={0|1|2} For 0 (or 'no' or 'false'), do not use escape sequences for unknown Unicode characters. For 1 (or 'yes' or 'true') or 2, use vfat-style 4-byte escape sequences starting with ":". Here 2 give a littleendian encoding and 1 a byteswapped bigendian encoding. posix=[0|1] If enabled (posix=1), the filesystem distinguishes between upper and lower case. The 8.3 alias names are presented as hard links instead of being suppressed. This option is obsolete. uid=value, gid=value and umask=value Set the file permission on the filesystem. The umask value is given in octal. By default, the files are owned by root and not readable by somebody else.

Mount options for proc


uid=value and gid=value These options are recognized, but have no effect as far as I can see.

Mount options for ramfs


Ramfs is a memory based filesystem. Mount it and you have it. Unmount it and it is gone. Present since Linux 2.3.99pre4. There are no mount options.

Mount options for reiserfs


Reiserfs is a journaling filesystem. conv Instructs version 3.6 reiserfs software to mount a version 3.5 filesystem, using the 3.6 format for newly created objects. This filesystem will no longer be compatible with reiserfs 3.5 tools. hash={rupasov|tea|r5|detect} Choose which hash function reiserfs will use to find files within directories. rupasov A hash invented by Yury Yu. Rupasov. It is fast and preserves locality, mapping lexicographically close file names to close hash values. This option should not be used, as it causes a high probability of hash collisions. tea A Davis-Meyer function implemented by Jeremy Fitzhardinge. It uses hash permuting bits in the name. It gets high randomness and, therefore, low probability of hash collisions at some CPU cost. This may be used if EHASHCOLLISION errors are experienced with the r5 hash. r5 A modified version of the rupasov hash. It is used by default and is the best choice unless the filesystem has huge directories and unusual file-name patterns. detect Instructs mount to detect which hash function is in use by examining the filesystem being mounted, and to write this information into the reiserfs superblock. This is only useful on the first mount of an old format filesystem. hashed_relocation Tunes the block allocator. This may provide performance improvements in some situations.

no_unhashed_relocation Tunes the block allocator. This may provide performance improvements in some situations. noborder Disable the border allocator algorithm invented by Yury Yu. Rupasov. This may provide performance improvements in some situations. nolog Disable journalling. This will provide slight performance improvements in some situations at the cost of losing reiserfs's fast recovery from crashes. Even with this option turned on, reiserfs still performs all journalling operations, save for actual writes into its journalling area. Implementation of nolog is a work in progress. notail By default, reiserfs stores small files and 'file tails' directly into its tree. This confuses some utilities such as lilo(8). This option is used to disable packing of files into the tree. replayonly Replay the transactions which are in the journal, but do not actually mount the filesystem. Mainly used by reiserfsck. resize=number A remount option which permits online expansion of reiserfs partitions. Instructs reiserfs to assume that the device has number blocks. This option is designed for use with devices which are under logical volume management (LVM). There is a special resizer utility which can be obtained from ftp://ftp.namesys.com/pub/reiserfsprogs. user_xattr Enable Extended User Attributes. See the attr(5) manual page. acl Enable POSIX Access Control Lists. See the acl(5) manual page. barrier=none / barrier=flush This enables/disables the use of write barriers in the journaling code. barrier=none disables it, barrier=flush enables it. Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. The reiserfs filesystem does not enable write barriers by default. Be sure to enable barriers unless your disks are batterybacked one way or another. Otherwise you risk filesystem corruption in case of power failure.

Mount options for romfs


None.

Mount options for squashfs


None.

Mount options for smbfs


Just like nfs, the smbfs implementation expects a binary argument (a struct smb_mount_data) to the mount system call. This argument is constructed by smbmount(8) and the current version of mount (2.12) does not know anything about smbfs.

Mount options for sysv


None.

Mount options for tmpfs


size=nbytes Override default maximum size of the filesystem. The size is given in bytes, and rounded up to entire pages. The default is half of the memory. The size parameter also accepts a suffix % to limit this tmpfs instance to that percentage of your physical RAM: the default, when neither size nor nr_blocks is specified, is size=50% nr_blocks= The same as size, but in blocks of PAGE_CACHE_SIZE nr_inodes= The maximum number of inodes for this instance. The default is half of the number of your physical RAM pages, or (on a machine with highmem) the number of lowmem RAM pages, whichever is the lower. The tmpfs mount options for sizing ( size, nr_blocks, and nr_inodes) accept a suffix k, m or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount. mode= Set initial permissions of the root directory. uid= The user id. gid= The group id. mpol=[default|prefer:Node|bind:NodeList|interleave|interleave:NodeList]

Set the NUMA memory allocation policy for all files in that instance (if the kernel CONFIG_NUMA is enabled) - which can be adjusted on the fly via 'mount -o remount ...' default prefers to allocate memory from the local node prefer:Node prefers to allocate memory from the given Node bind:NodeList allocates memory only from nodes in NodeList interleave prefers to allocate from each node in turn interleave:NodeList allocates from each node of NodeList in turn. The NodeList format is a comma-separated list of decimal numbers and ranges, a range being two hyphen-separated decimal numbers, the smallest and largest node numbers in the range. For example, mpol=bind:0-3,5,7,9-15 Note that trying to mount a tmpfs with an mpol option will fail if the running kernel does not support NUMA; and will fail if its nodelist specifies a node which is not online. If your system relies on that tmpfs being mounted, but from time to time runs a kernel built without NUMA capability (perhaps a safe recovery kernel), or with fewer nodes online, then it is advisable to omit the mpol option from automatic mount options. It can be added later, when the tmpfs is already mounted on MountPoint, by 'mount -o remount,mpol=Policy:NodeList MountPoint'.

Mount options for ubifs


UBIFS is a flash file system which works on top of UBI volumes. Note that atime is not supported and is always turned off. The device name may be specified as ubiX_Y UBI device number X, volume number Y ubiY UBI device number 0, volume number Y ubiX:NAME UBI device number X, volume with name NAME

ubi:NAME UBI device number 0, volume with name NAME Alternative ! separator may be used instead of :. The following mount options are available: bulk_read Enable bulk-read. VFS read-ahead is disabled because it slows down the file system. Bulk-Read is an internal optimization. Some flashes may read faster if the data are read at one go, rather than at several read requests. For example, OneNAND can do "read-while-load" if it reads more than one NAND page. no_bulk_read Do not bulk-read. This is the default. chk_data_crc Check data CRC-32 checksums. This is the default. no_chk_data_crc. Do not check data CRC-32 checksums. With this option, the filesystem does not check CRC-32 checksum for data, but it does check it for the internal indexing information. This option only affects reading, not writing. CRC-32 is always calculated when writing the data. compr={none|lzo|zlib} Select the default compressor which is used when new files are written. It is still possible to read compressed files if mounted with the none option.

Mount options for udf


udf is the "Universal Disk Format" filesystem defined by the Optical Storage Technology Association, and is often used for DVD-ROM. See also iso9660. gid= Set the default group. umask= Set the default umask. The value is given in octal. uid= Set the default user. unhide

Show otherwise hidden files. undelete Show deleted files in lists. nostrict Unset strict conformance. iocharset Set the NLS character set. bs= Set the block size. (May not work unless 2048.) novrs Skip volume sequence recognition. session= Set the CDROM session counting from 0. Default: last session. anchor= Override standard anchor location. Default: 256. volume= Override the VolumeDesc location. (unused) partition= Override the PartitionDesc location. (unused) lastblock= Set the last block of the filesystem. fileset= Override the fileset block location. (unused) rootdir= Override the root directory location. (unused)

Mount options for ufs


ufstype=value

UFS is a filesystem widely used in different operating systems. The problem are differences among implementations. Features of some implementations are undocumented, so its hard to recognize the type of ufs automatically. That's why the user must specify the type of ufs by mount option. Possible values are: old Old format of ufs, this is the default, read only. (Don't forget to give the -r option.) 44bsd For filesystems created by a BSD-like system (NetBSD,FreeBSD,OpenBSD). sun For filesystems created by SunOS or Solaris on Sparc. sunx86 For filesystems created by Solaris on x86. hp For filesystems created by HP-UX, read-only. nextstep For filesystems created by NeXTStep (on NeXT station) (currently read only). nextstep-cd For NextStep CDROMs (block_size == 2048), read-only. openstep For filesystems created by OpenStep (currently read only). The same filesystem type is also used by Mac OS X. onerror=value Set behaviour on error: panic If an error is encountered, cause a kernel panic. [lock|umount|repair] These mount options don't do anything at present; when an error is encountered only a console message is printed.

Mount options for umsdos


See mount options for msdos. The dotsOK option is explicitly killed by umsdos.

Mount options for vfat


First of all, the mount options for fat are recognized. The dotsOK option is explicitly killed by vfat. Furthermore, there are uni_xlate Translate unhandled Unicode characters to special escaped sequences. This lets you backup and restore filenames that are created with any Unicode characters. Without this option, a '?' is used when no translation is possible. The escape character is ':' because it is otherwise illegal on the vfat filesystem. The escape sequence that gets used, where u is the unicode character, is: ':', (u & 0x3f), ((u>>6) & 0x3f), (u>>12). posix Allow two files with names that only differ in case. This option is obsolete. nonumtail First try to make a short name without sequence number, before trying name~num.ext. utf8 UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the console. It can be be enabled for the filesystem with this option or disabled with utf8=0, utf8=no or utf8=false. If 'uni_xlate' gets set, UTF8 gets disabled. shortname={lower|win95|winnt|mixed} Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be preferred display. There are four modes: : lower Force the short name to lower case upon display; store a long name when the short name is not all upper case. This mode is the default. win95 Force the short name to upper case upon display; store a long name when the short name is not all upper case. winnt Display the shortname as is; store a long name when the short name is not all lower case or all upper case.

mixed Display the short name as is; store a long name when the short name is not all upper case.

Mount options for usbfs


devuid=uid and devgid=gid and devmode=mode Set the owner and group and mode of the device files in the usbfs filesystem (default: uid=gid=0, mode=0644). The mode is given in octal. busuid=uid and busgid=gid and busmode=mode Set the owner and group and mode of the bus directories in the usbfs filesystem (default: uid=gid=0, mode=0555). The mode is given in octal. listuid=uid and listgid=gid and listmode=mode Set the owner and group and mode of the file devices (default: uid=gid=0, mode=0444). The mode is given in octal.

Mount options for xenix


None.

Mount options for xfs


allocsize=size Sets the buffered I/O end-of-file preallocation size when doing delayed allocation writeout (default size is 64KiB). Valid values for this option are page size (typically 4KiB) through to 1GiB, inclusive, in power-of-2 increments. attr2|noattr2 The options enable/disable (default is enabled) an "opportunistic" improvement to be made in the way inline extended attributes are stored on-disk. When the new form is used for the first time (by setting or removing extended attributes) the on-disk superblock feature bit field will be updated to reflect this format being in use. barrier Enables the use of block layer write barriers for writes into the journal and unwritten extent conversion. This allows for drive level write caching to be enabled, for devices that support write barriers. dmapi Enable the DMAPI (Data Management API) event callouts. Use with the mtpt option.

grpid|bsdgroups and nogrpid|sysvgroups These options define what group ID a newly created file gets. When grpid is set, it takes the group ID of the directory in which it is created; otherwise (the default) it takes the fsgid of the current process, unless the directory has the setgid bit set, in which case it takes the gid from the parent directory, and also gets the setgid bit set if it is a directory itself. ihashsize=value Sets the number of hash buckets available for hashing the in-memory inodes of the specified mount point. If a value of zero is used, the value selected by the default algorithm will be displayed in /proc/mounts. ikeep|noikeep When inode clusters are emptied of inodes, keep them around on the disk (ikeep) - this is the traditional XFS behaviour and is still the default for now. Using the noikeep option, inode clusters are returned to the free space pool. inode64 Indicates that XFS is allowed to create inodes at any location in the filesystem, including those which will result in inode numbers occupying more than 32 bits of significance. This is provided for backwards compatibility, but causes problems for backup applications that cannot handle large inode numbers. largeio|nolargeio If nolargeio is specified, the optimal I/O reported in st_blksize by stat(2) will be as small as possible to allow user applications to avoid inefficient read/modify/write I/O. Iflargeio is specified, a filesystem that has a swidth specified will return the swidth value (in bytes) in st_blksize. If the filesystem does not have a swidth specified but does specify an allocsize then allocsize (in bytes) will be returned instead. If neither of these two options are specified, then filesystem will behave as if nolargeio was specified. logbufs=value Set the number of in-memory log buffers. Valid numbers range from 2-8 inclusive. The default value is 8 buffers for filesystems with a blocksize of 64KiB, 4 buffers for filesystems with a blocksize of 32KiB, 3 buffers for filesystems with a blocksize of 16KiB and 2 buffers for all other configurations. Increasing the number of buffers may increase performance on some workloads at the cost of the memory used for the additional log buffers and their associated control structures. logbsize=value Set the size of each in-memory log buffer. Size may be specified in bytes, or in kilobytes with a "k" suffix. Valid sizes for version 1 and version 2 logs are 16384 (16k) and 32768 (32k). Valid sizes for version 2 logs also include 65536 (64k), 131072 (128k) and 262144 (256k). The default value for machines with more than 32MiB of memory is 32768, machines with less memory use 16384 by default.

logdev=device and rtdev=device Use an external log (metadata journal) and/or real-time device. An XFS filesystem has up to three parts: a data section, a log section, and a real-time section. The real-time section is optional, and the log section can be separate from the data section or contained within it. Refer to xfs(5). mtpt=mountpoint Use with the dmapi option. The value specified here will be included in the DMAPI mount event, and should be the path of the actual mountpoint that is used. noalign Data allocations will not be aligned at stripe unit boundaries. noatime Access timestamps are not updated when a file is read. norecovery The filesystem will be mounted without running log recovery. If the filesystem was not cleanly unmounted, it is likely to be inconsistent when mounted in norecoverymode. Some files or directories may not be accessible because of this. Filesystems mounted norecovery must be mounted read-only or the mount will fail. nouuid Don't check for double mounted filesystems using the filesystem uuid. This is useful to mount LVM snapshot volumes. osyncisosync Make O_SYNC writes implement true O_SYNC. WITHOUT this option, Linux XFS behaves as if an osyncisdsync option is used, which will make writes to files opened with the O_SYNC flag set behave as if the O_DSYNC flag had been used instead. This can result in better performance without compromising data safety. However if this option is not in effect, timestamp updates from O_SYNC writes can be lost if the system crashes. If timestamp updates are critical, use the osyncisosync option. uquota|usrquota|uqnoenforce|quota User disk quota accounting enabled, and limits (optionally) enforced. Refer to xfs_quota(8) for further details. gquota|grpquota|gqnoenforce Group disk quota accounting enabled and limits (optionally) enforced. Refer to xfs_quota(8) for further details. pquota|prjquota|pqnoenforce

Project disk quota accounting enabled and limits (optionally) enforced. Refer to xfs_quota(8) for further details. sunit=value and swidth=value Used to specify the stripe unit and width for a RAID device or a stripe volume. value must be specified in 512-byte block units. If this option is not specified and the filesystem was made on a stripe volume or the stripe width or unit were specified for the RAID device at mkfs time, then the mount system call will restore the value from the superblock. For filesystems that are made directly on RAID devices, these options can be used to override the information in the superblock if the underlying disk layout changes after the filesystem has been created. The swidth option is required if the sunit option has been specified, and must be a multiple of the sunit value. swalloc Data allocations will be rounded up to stripe width boundaries when the current end of file is being extended and the file size is larger than the stripe width size.

Mount options for xiafs


None. Although nothing is wrong with xiafs, it is not used much, and is not maintained. Probably one shouldn't use it. Since Linux version 2.1.21 xiafs is no longer part of the kernel source.

The Loop Device


One further possible type is a mount via the loop device. For example, the command
mount /tmp/fdimage /mnt -t vfat -o loop=/dev/loop3

will set up the loop device /dev/loop3 to correspond to the file /tmp/fdimage, and then mount this device on /mnt. This type of mount knows about four options, namely loop, offset, sizelimit and encryption, that are really options to losetup(8). (These options can be used in addition to those specific to the filesystem type.) If no explicit loop device is mentioned (but just an option '-o loop' is given), then mount will try to find some unused loop device and use that. Since Linux 2.6.25 is supported auto-destruction of loop devices and then any loop device allocated by mount will be freed by umount independently on /etc/mtab. You can also free a loop device by hand, using 'losetup -d' or 'umount -d'.

Return Codes
mount has the following return codes (the bits can be ORed): 0 success

1 incorrect invocation or permissions 2 system error (out of memory, cannot fork, no more loop devices) 4 internal mount bug 8 user interrupt 16 problems writing or locking /etc/mtab 32 mount failure 64 some mount succeeded

Notes
The syntax of external mount helpers is: /sbin/mount.<suffix> spec dir [-sfnv] [-o options] [-t type.subtype] where the <type> is filesystem type and -sfnvo options have same meaning like standard mount options. The -t option is used for filesystems with subtypes support (for example /sbin/mount.fuse -t fuse.sshfs).

Files
/etc/fstab filesystem table /etc/mtab table of mounted filesystems /etc/mtab~ lock file

/etc/mtab.tmp temporary file /etc/filesystems a list of filesystem types to try

See Also
mount(2), umount(2), fstab(5), umount(8), swapon(8), nfs(5), xfs(5), e2label(8), xfs_admin(8), moun td(8), nfsd(8), mke2fs(8), tune2fs(8), losetup(8)

Bugs
It is possible for a corrupted filesystem to cause a crash. Some Linux filesystems don't support -o sync and -o dirsync (the ext2, ext3, fat and vfat filesystems do support synchronous updates (a la BSD) when mounted with the syncoption). The -o remount may not be able to change mount parameters (all ext2fs-specific parameters, except sb, are changeable with a remount, for example, but you can't change gidor umask for the fatfs). Mount by label or uuid will work only if your devices have the names listed in /proc/partitions. In particular, it may well fail if the kernel was compiled with devfs but devfs is not mounted. It is possible that files /etc/mtab and /proc/mounts don't match. The first file is based only on the mount command options, but the content of the second file also depends on the kernel and others settings (e.g. remote NFS server. In particular case the mount command may reports unreliable information about a NFS mount point and the /proc/mounts fileusually contains more reliable information.) Checking files on NFS filesystem referenced by file descriptors (i.e. the fcntl and ioctl families of functions) may lead to inconsistent result due to the lack of consistency checkin kernel even if noac is used.

History
A mount command existed in Version 5 AT&T UNIX.

Availability
The mount command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.

6. Mention any four fdisk interactive commands.

sfdisk(8) - Linux man page


Name
sfdisk - Partition table manipulator for Linux

Synopsis
sfdisk [options] device sfdisk -s [partition]

Description
sfdisk has four (main) uses: list the size of a partition, list the partitions on a device, check the partitions on a device, and - very dangerous - repartition a device. sfdisk doesn't understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted(8).

List Sizes
sfdisk -s partition gives the size of partition in blocks. This may be useful in connection with programs like mkswap(8) or so. Here partition is usually something like /dev/hda1 or/dev/sdb12, but may also be an entire disk, like /dev/xda.
% sfdisk -s /dev/hda9 81599 %

If the partition argument is omitted, sfdisk will list the sizes of all disks, and the total:
% sfdisk -s /dev/hda: 208896 /dev/hdb: 1025136 /dev/hdc: 1031063 /dev/sda: 8877895 /dev/sdb: 1758927 total: 12901917 blocks %

List Partitions
The second type of invocation: sfdisk -l [options] device will list the partitions on this device. If the device argument is omitted, the partitions on all hard disks are listed.
% sfdisk -l /dev/hdc Disk /dev/hdc: 16 heads, 63 sectors, 2045 cylinders Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/hdc1 0+ 406 407205096+ 83 Linux native /dev/hdc2 407 813 407 205128 83 Linux native /dev/hdc3 814 2044 1231 620424 83 Linux native /dev/hdc4 0 0 0 0 Empty %

The trailing - and + signs indicate that rounding has taken place, and that the actual value is slightly less (more). To see the exact values, ask for a listing with sectors as unit.

Check partitions
The third type of invocation: sfdisk -V device will apply various consistency checks to the partition tables on device. It prints 'OK' or complains. The -V option can be used together with -l. In a shell script one might use sfdisk -V -q device which only returns a status.

Create partitions
The fourth type of invocation: sfdisk device will cause sfdisk to read the specification for the desired partitioning of device from its standard input, and then to change the partition tables on that disk. Thus, it is possible to use sfdisk from a shell script. When sfdisk determines that its standard input is a terminal, it will be conversational; otherwise it will abort on any error. BE EXTREMELY CAREFUL - ONE TYPING MISTAKE AND ALL YOUR DATA IS LOST As a precaution, one can save the sectors changed by sfdisk:
% sfdisk /dev/hdd -O hdd-partition-sectors.save ... %

Then, if you discover that you did something stupid before anything else has been written to disk, it may be possible to recover the old situation with
% sfdisk /dev/hdd -I hdd-partition-sectors.save %

(This is not the same as saving the old partition table: a readable version of the old partition table can be saved using the -d option. However, if you create logical partitions, the sectors describing them are located somewhere on disk, possibly on sectors that were not part of the partition table before. Thus, the information the -O option saves is not a binary version of the output of -d.) There are many options.

Options
-v or --version Print version number of sfdisk and exit immediately. -? or --help Print a usage message and exit immediately. -T or --list-types Print the recognized types (system Id's). -s or --show-size List the size of a partition.

-g or --show-geometry List the kernel's idea of the geometry of the indicated disk(s). -G or --show-pt-geometry List the geometry of the indicated disks guessed by looking at the partition table. -l or --list List the partitions of a device. -d Dump the partitions of a device in a format useful as input to sfdisk. For example,
% sfdisk -d /dev/hda > hda.out % sfdisk /dev/hda < hda.out

will correct the bad last extended partition that the OS/2 fdisk creates. -V or --verify Test whether partitions seem correct. (See above.) -i or --increment Number cylinders etc. starting from 1 instead of 0. -N number Change only the single partition indicated. For example:
% sfdisk /dev/hdb -N5 ,,,* %

will make the fifth partition on /dev/hdb bootable ('active') and change nothing else. (Probably this fifth partition is called /dev/hdb5, but you are free to call it something else, like '/my_equipment/disks/2/5' or so). -A number Make the indicated partition(s) active, and all others inactive. -c or --id number [Id] If no Id argument given: print the partition Id of the indicated partition. If an Id argument is present: change the type (Id) of the indicated partition to the given value. This option has the two very long forms --print-id and --change-id. For example:
% sfdisk --print-id /dev/hdb 5 6 % sfdisk --change-id /dev/hdb 5 83 OK

first reports that /dev/hdb5 has Id 6, and then changes that into 83. -uS or -uB or -uC or -uM

Accept or report in units of sectors (blocks, cylinders, megabytes, respectively). The default is cylinders, at least when the geometry is known. -x or --show-extended Also list non-primary extended partitions on output, and expect descriptors for them on input. -C cylinders Specify the number of cylinders, possibly overriding what the kernel thinks. -H heads Specify the number of heads, possibly overriding what the kernel thinks. -S sectors Specify the number of sectors, possibly overriding what the kernel thinks. -f or --force Do what I say, even if it is stupid. -q or --quiet Suppress warning messages. -L or --Linux Do not complain about things irrelevant for Linux. -D or --DOS For DOS-compatibility: waste a little space. (More precisely: if a partition cannot contain sector 0, e.g. because that is the MBR of the device, or contains the partition table of an extended partition, then sfdisk would make it start the next sector. However, when this option is given it skips to the start of the next track, wasting for example 33 sectors (in case of 34 sectors/track), just like certain versions of DOS do.) Certain Disk Managers and boot loaders (such as OSBS, but not LILO or the OS/2 Boot Manager) also live in this empty space, so maybe you want this option if you use one. -E or --DOS-extended Take the starting sector numbers of "inner" extended partitions to be relative to the starting cylinder boundary of the outer one, (like some versions of DOS do) rather than to the starting sector (like Linux does). (The fact that there is a difference here means that one should always let extended partitions start at cylinder boundaries if DOS and Linux should interpret the partition table in the same way. Of course one can only know where cylinder boundaries are when one knows what geometry DOS will use for this disk.) --IBM or --leave-last

Certain IBM diagnostic programs assume that they can use the last cylinder on a disk for disktesting purposes. If you think you might ever run such programs, use this option to tell sfdisk that it should not allocate the last cylinder. Sometimes the last cylinder contains a bad sector table. -n Go through all the motions, but do not actually write to disk. -R Only execute the BLKRRPART ioctl (to make the kernel re-read the partition table). This can be useful for checking in advance that the final BLKRRPART will be successful, and also when you changed the partition table 'by hand' (e.g., using dd from a backup). If the kernel complains ('device busy for revalidation (usage = 2)') then something still uses the device, and you still have to unmount some file system, or say swapoff to some swap partition. --no-reread When starting a repartitioning of a disk, sfdisk checks that this disk is not mounted, or in use as a swap device, and refuses to continue if it is. This option suppresses the test. (On the other hand, the -f option would force sfdisk to continue even when this test fails.) -O file Just before writing the new partition, output the sectors that are going to be overwritten to file (where hopefully file resides on another disk, or on a floppy). -I file After destroying your filesystems with an unfortunate sfdisk command, you would have been able to restore the old situation if only you had preserved it using the -O flag.

Theory
Block 0 of a disk (the Master Boot Record) contains among other things four partition descriptors. The partitions described here are called primary partitions. A partition descriptor has 6 fields:
struct partition { unsigned char bootable; hsc begin_hsc; unsigned char id; hsc end_hsc; unsigned int starting_sector; unsigned int nr_of_sectors; } /* 0 or 0x80 */

The two hsc fields indicate head, sector and cylinder of the begin and the end of the partition. Since each hsc field only takes 3 bytes, only 24 bits are available, which does not suffice for big disks (say > 8GB). In fact, due to the wasteful representation (that uses a byte for the number of heads, which is typically 16), problems already start with 0.5GB. However Linux does not use these fields, and problems can arise only at boot time, before Linux has been started. For more details, see the lilo documentation.

Each partition has a type, its 'Id', and if this type is 5 or f ('extended partition') the starting sector of the partition again contains 4 partition descriptors. MSDOS only uses the first two of these: the first one an actual data partition, and the second one again an extended partition (or empty). In this way one gets a chain of extended partitions. Other operatingsystems have slightly different conventions. Linux also accepts type 85 as equivalent to 5 and f - this can be useful if one wants to have extended partitions under Linux past the 1024 cylinder boundary, without DOS FDISK hanging. (If there is no good reason, you should just use 5, which is understood by other systems.) Partitions that are not primary or extended are called logical. Often, one cannot boot from logical partitions (because the process of finding them is more involved than just looking at the MBR). Note that of an extended partition only the Id and the start are used. There are various conventions about what to write in the other fields. One should not try to use extended partitions for data storage or swap.

Input Format
sfdisk reads lines of the form <start> <size> <id> <bootable> <c,h,s> <c,h,s> where each line fills one partition descriptor. Fields are separated by whitespace, or comma or semicolon possibly followed by whitespace; initial and trailing whitespace is ignored. Numbers can be octal, decimal or hexadecimal, decimal is default. When a field is absent or empty, a default value is used. The <c,h,s> parts can (and probably should) be omitted - sfdisk computes them from <start> and <size> and the disk geometry as given by the kernel or specified using the -H, -S, -C flags. Bootable is specified as [*|-], with as default not-bootable. (The value of this field is irrelevant for Linux when Linux runs it has been booted already - but might play a role for certain boot loaders and for other operating systems. For example, when there are several primary DOS partitions, DOS assigns C: to the first among these that is bootable.) Id is given in hex, without the 0x prefix, or is [E|S|L|X], where L (LINUX_NATIVE (83)) is the default, S is LINUX_SWAP (82), E is EXTENDED_PARTITION (5), and X is LINUX_EXTENDED (85). The default value of start is the first nonassigned sector/cylinder/... The default value of size is as much as possible (until next partition or end-of-disk). However, for the four partitions inside an extended partition, the defaults are: Linux partition, Extended partition, Empty, Empty. But when the -N option (change a single partition only) is given, the default for each field is its previous value.

Example
The command
sfdisk /dev/hdc << EOF 0,407 ,407 ;

; EOF

will partition /dev/hdc just as indicated above. The command


sfdisk /dev/hdb << EOF ,3,L ,60,L ,19,S ,,E ,130,L ,130,L ,130,L ,,L EOF

will partition /dev/hdb into two Linux partitions of 3 and 60 cylinders, a swap space of 19 cylinders, and an extended partition covering the rest. Inside the extended partition there are four Linux logical partitions, three of 130 cylinders and one covering the rest. With the -x option, the number of input lines must be a multiple of 4: you have to list the two empty partitions that you never want using two blank lines. Without the -x option, you give one line for the partitions inside a extended partition, instead of four, and terminate with end-of-file (^D). (And sfdisk will assume that your input line represents the first offour, that the second one is extended, and the 3rd and 4th are empty.)

DOS 6.x WARNING


The DOS 6.x FORMAT command looks for some information in the first sector of the data area of the partition, and treats this information as more reliable than the information inthe partition table. DOS FORMAT expects DOS FDISK to clear the first 512 bytes of the data area of a partition whenever a size change occurs. DOS FORMAT will look at this extra information even if the /U flag is given -- we consider this a bug in DOS FORMAT and DOS FDISK. The bottom line is that if you use sfdisk to change the size of a DOS partition table entry, then you must also use dd to zero the first 512 bytes of that partition before using DOS FORMAT to format the partition. For example, if you were using sfdisk to make a DOS partition table entry for /dev/hda1, then (after exiting sfdisk and rebooting Linux so that the partition table information is valid) you would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero the first 512 bytes of the partition. BE EXTREMELY CAREFUL if you use the dd command, since a small typo can make all of the data on your disk useless. For best results, you should always use an OS-specific partition table program. For example, you should make DOS partitions with the DOS FDISK program and Linux partitions with the Linux sfdisk program.

Drdos Warnings
Stephen Tweedie reported (930515): 'Most reports of superblock corruption turn out to be due to bad partitioning, with one filesystem overrunning the start of the next and corrupting its superblock. I have even had this problem with the supposedly-reliable DRDOS. This was quite possibly due to DRDOS6.0's FDISK command. Unless I created a blank track or cylinder between the DRDOS partition and the immediately following one, DRDOS would happily stamp all over the start of the next partition. Mind you, as long as I keep a little free disk space after any DRDOS partition, I don't have any other problems with the two coexisting on the one drive.'

A. V. Le Blanc writes in README.efdisk: 'Dr. DOS 5.0 and 6.0 has been reported to have problems cooperating with Linux, and with this version of efdisk in particular. This efdisk sets the system type to hexadecimal 81. Dr. DOS seems to confuse this with hexadecimal 1, a DOS code. If you use Dr. DOS, use the efdisk command 't' to change thesystem code of any Linux partitions to some number less than hexadecimal 80; I suggest 41 and 42 for the moment.' A. V. Le Blanc writes in his README.fdisk: 'DR-DOS 5.0 and 6.0 are reported to have difficulties with partition ID codes of 80 or more. The Linux 'fdisk' used to set the systemtype of new partitions to hexadecimal 81. DR-DOS seems to confuse this with hexadecimal 1, a DOS code. The values 82 for swap and 83 for file systems should not cause problems with DR-DOS. If they do, you may use the 'fdisk' command 't' to change the system code of any Linux partitions to some number less than hexadecimal 80; I suggest 42 and 43 for the moment.' In fact, it seems that only 4 bits are significant for the DRDOS FDISK, so that for example 11 and 21 are listed as DOS 2.0. However, DRDOS itself seems to use the full byte. I have not been able to reproduce any corruption with DRDOS or its fdisk.

Bugs
There are too many options. There is no support for non-DOS partition types.

See Also
cfdisk(8), fdisk(8), mkfs(8), parted(8), partprobe(8), kpartx(8)

Linux / Unix Command: fdisk


Command Library

NAME
fdisk - Partition table manipulator for Linux

SYNOPSIS
fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device fdisk -l [-u] [device ...] fdisk -s partition ... fdisk -v

DESCRIPTION
Hard disks can be divided into one or more logical disks called partitions. This division is described in the partition table found in sector 0 of the disk. In the BSD world one talks about `disk slices' and a `disklabel'. Linux needs at least one partition, namely for its root file system. It can use swap files and/or swap partitions, but the latter are more efficient. So, usually one will want a second Linux partition dedicated as swap partition. On Intel compatible hardware, the BIOS that boots the system can often only access the first 1024 cylinders of the disk. For this reason people with large disks often create a third partition, just a few MB large, typically mounted on /boot, to store the kernel image and a few auxiliary files needed at boot time, so as to make sure that this stuff is accessible to the BIOS. There may be reasons of security, ease of administration and backup, or testing, to use more than the minimum number of partitions.

Linux Command Reference Index ( GNU / linux kernel 2.4.18-3, 2.4.18-14 and 2.4.20-6 )* Linux is a registered trademark of Linus Torvalds

These are just a few of the most common GNU / Linux commands that you may find yourself looking for, along with some answers to common questions about running Linux. On most systems more information about a command can be found by typing [ man command ] ; man being the word man and command being the particular command you are checking. You will need to be root to use some of these commands ; also be sure to check your path. If there is no path to the command then you will likely get a " command not found " error. Check the command to be sure you have typed it correctly. Be extremely careful as root , you can make your system unusable. This is very important to understand. If you are using a dual boot system you may not be able to access either system if you make a mistake as root and your system is not bootable. Before you type any command as root be absolutely certain of what you are doing. Any comments are encouraged and welcome at

Update March 08, 2011: I am in the process of checking all the commands on Ubuntu Linux (Lucid). The Kernel I am using is ( 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11 19:00:09 UTC 2011 i686 GNU/Linux ). So far All the commands up to "pdfinfo" work. Please note that some of the commands may refer to programs not yet installed on your machine. Ubuntu will ask you if you want to install a program usually rather than just give you a "command not found" message. For example when I typed the command "quota" (without the quotes and after I pressed enter, of course) I got this:

The program 'quota' is currently not installed. You can install it by typing: sudo apt-get install quota You will then be asked to type your password (the admin password) and the installation will proceed (after you press enter) (this assumes you have an active internet connection).

First posted 2002-10-14 page last modified 2011-03-22 Linux Commands A B C D E F G H I K L M N P Q R S T U V W XYZ References and answers back to beginning

A alias Create your own name for a command arch print machine architecture ash ash command interpreter (shell) awk (gawk) pattern scanning and processing language

B basename Remove directory and suffix from a file name bash GNU Bourne-Again Shell bsh Command interpreter (Shell) bc Command line calculator bunzip2 Unzip .bz2 files

C back to commands top cat Concatenate a file print it to the screen chgrp Change the group designation of a file chmod Change file permissions chown Change the owner of a file cjpeg Compress an image file to a JPEG file clear Clear terminal screen (command line) comm Compare two sorted files stty cooked Formatting the display of text in a terminal cp Copy command cpio Copy files to and from archives csh C Shell cut Print selected parts of lines to standard output

D back to commands top date Display date and time dc Command line calculator df Show amount of disk space free diff Determine difference between two files diff3 Determine difference between 3 files dig Interrogate DNS name servers djpeg Decompress a JPEG file to an image file

dmesg Print or control the kernel ring buffer (print out bootup messages) dnsdomainname Show the system's DNS domain name doexec Run an executable with an arbitrary argv domainname Show or set the system's NIS/YP domain name dos2unix Converts plain text files in DOS/MAC format to UNIX format du Show disk useage dumpkeys Write keyboard driver's translation tables to std output

E back to commands top echo Display a line of text ed Line-oriented text editor egrep Print lines matching a pattern elinks A text mode WWW browser (supports frames) env Dislay the path ex Start Vim in ex mode eject Eject media from device ( command line )

F back to commands top factor Display prime factors of a number false Exit with a status code indicating failure fdisk The fdisk command with usage examples fgrep Variant of grep find Find a file

finger Displays information about the system users fixps Try to fix common PostScript problems that break postprocessing free Display free memory

G back to commands top grep Search for a pattern using regular expression gtar See the tar command gunzip Unzip .gz files gzip Compress using Lempel-Ziv coding (LZ77)

H back to commands top halt Stop the system hdparm Get/set harddisk parameters head Print the first 10 lines of a file to standard output hostname Show or set the system's host name history Display entire command history HISTSIZE Change history size httpd Start Apache

I back to commands top identify Describes the format and characteristics of image files. id Print information for username, or the current user

ifconfig Display network and hardware addresses igawk Gawk with include files ipcalc Calculate IP information for a host

K back to commands top kbd_mode Report or set the keyboard mode (RAW, MEDI- UMRAW or XLATE) kill Terminate a process

L back to commands top last Show listing of last logged in users lastlog Formats and prints the contents of the last login log /var/log/lastlog file link Call the link function to create a link to a file links See elinks ln Create a link to the specified TARGET with optional LINK_NAME loadkeys Load keyboard translation tables locate Locate a file login Sign on look Displays any lines in file which contain "string" as a prefix. ls List directory contents lsmod List loaded kernel modules lynx Command to start the Lynx browser

M back to commands top mac2unix Converts plain text files in DOS/MAC format to UNIX format mail A mail processing system, which has a command syntax like ed man Display a particular manual entry manweb Manweb is part of the Netpbm package mdu Display the amount of space occupied by an MSDOS directory mkdir Create a directory mkfs Make a filesystem on a drive mknod Make block or character special files mktemp Make temporary filename (unique) more Page through text one screenful at a time. mount Mount a filesystem/device mt Control magnetic tape drive operation mv Move and / or rename files :

N namei Follow a pathname until a terminal point is found nano An enhanced free Pico clone nc arbitrary TCP and UDP connections and listens (note that nc is also called the client interface to the NEdit program but it is not the command that invokes nedit-nc on current systems)

ncftp Browser program for the File Transfer Protocol nedit-nc nedit-nc is the client interface to the NEdit text editor netstat Display verbose info about network processes and ports nice Run a command with modified priority nisdomainname Show or set system's NIS/YP domain name nslookup query internet domain name servers

P paste Merge lines of files pdf2dsc Generate a PostScript page list of a PDF document pdf2ps Convert PDF file "input.pdf" to PostScript(tm) in "output.ps" pdfinfo Print contents of the 'Info' dictionary (plus some other useful information) from a PDF file pdftotext Convert pdf files to plain text perl (start) Practical Extraction and Report Language pgawk The profiling version of gawk pico Text editor that comes with Pine (from the University of Washington) pine Email program used by The University of Washington ping6 Ping ping Send ICMP ECHO_REQUEST to network hosts pinky A lightweight 'finger' program; pr Format for printing ps Processes running ps2ascii Ghostscript translator from PostScript or PDF to ASCII

ps2epsi Generate conforming Encapsulated PostScript ps2frag Obsolete shell script for the PSfrag system ps2pdf12 Convert PostScript to PDF 1.2 (Acrobat 3 and later compatible) using ghostscript ps2pdf13 Convert PostScript to PDF 1.3 (Acrobat 4 and later compatible) using ghostscript ps2pdf14 Use ps2pdfwr: Convert PostScript to PDF without specifying Compatibility Level, using ghostscript ps2pdf Convert PostScript to PDF using ghostscript ps2pdfwr Convert PostScript to PDF without specifying Compatibility Level, using ghostscript ps2pk creates a TeX pkfont from a type1 PostScript font ps2ps ps2ps uses gs to convert PostScript(tm) file "input.ps" to simpler and (usually) faster PostScript in "output.ps" psbook Rearranges pages from a PostScript document into "signatures" for printing books or booklets pwd Print Working Directory

Q back to commands top quota display disk usage and limits

R back to commands top resize Xterm window size readelf Displays information about ELF files reboot Stop the system, poweroff, reboot red red is a restricted ed: it can only edit files in the current directory and cannot execute shell commands rename Rename files

rmdir Remove a directory rm Remove files or directories rpm rpm command options rundig Sample script to create a search database for ht://Dig rview The GUI version of Vim in easy mode with restrictions rvi Vi / Vim editor

S back to commands top sed Stream editor setfont Load EGA/VGA console screen font set gid Set group id set serial Get / set Linux serial port info set uid Set user id sfdisk Modified fdisk program sftp Secure file transfer protocol (ftp) sh Shell (BASH) shred Safely remove data from disk drive sleep Delay for a specified amount of time slocate Security Enhanced version of the GNU Locate sort Sort lines of a text file ssh Secure shell connection command stty change and print terminal line settings stty raw Unformatted output to terminal su Become super user ( root )

switchdesk Graphical and text mode interface for choosing desktop environment sync Force changed blocks to disk, update the super block ssh Secure shell connection command

T back to commands top tail Print the last 10 Lines of a file standard output tar Create an Archive tcsh Enhanced completely compatible version of the Berkeley UNIX C shell, csh tee Copy standard input to each file, and also to standard output telnet User interface to the telnet protocol time Run the specified program command with the given arguments touch Change file timestamps tracepath6 See tracepath tracepath Trace path to a network host discovering MTU along this path traceroute6 See traceroute traceroute Print the route packets take to network host tree Display file tree true Exit with a status code indicating success tty Print name of terminal connected to standard output

U back to commands top umask File creation mask / Bash builtins umount Detache file system(s) mentioned from file hierarchy

uname Print system information ( kernel version ) unicode_start Put keyboard and console into Unicode (UTF-8) mode unicode_stop Undo the effect of unicode_start unlink Call the unlink function to remove the specified file uniq Remove duplicate lines from sorted file updatedb Update the slocate database unset gid Group id change unset uid User id change untar Unarchive ( untar ) a file unzip Unzip .zip files useradd Add new user users Output who is currently logged in according to system records usleep Sleep a given number of microseconds. default is 1

V back to commands top view Start vim in read-only mode vi Start the vi editor

W back to commands top w Show who is logged on and what they are doing wc Word count of a file wget Non-interactive download of files from the Web whatis Search the whatis database for complete words (command names)

whereis Locate a command or file which Find command path whoami Print effective userid who show who is logged on whois Client for the whois service

X,Y,Z back to commands top xinit Start Xserver xpdf Portable Document Format (PDF) file viewer for X windows xrandr Change resolution running Xwindows ( command line ) ypdomainname show or set the system's NIS/YP domain name zcat Compress or expand files zip Compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows NT, Minix, Atari and Macintosh, Amiga and Acorn RISC OS. It is analogous to a combination of the UNIX commands tar(1) and compress(1) and is compatible with PKZIP (Phil Katzs ZIP for MSDOS systems) zipinfo List detailed information about a ZIP archive

7. How changing at user password is accumplished in Linux environment ?

How Do I Change my Linux Password?


You can use thepasswdcommand to change your log-in password, and as you can tell from themanoutput shown in the preceding section, you have quite a few options. Here are some of the most common: passwd Change your own password. Change sleepy's password. Delete sleepy's password.

passwdsleepy passwd -dsleepy

When you enter one of these commands to change a password, you will be prompted for the old (current) password and a new password. Your new password should be at least six characters long and not too easy for someone else to guess. Oh, and writing it down on a scrap of paper taped to your monitor is not recommended either. :-) If you share your Linux system with multiple users, or if you have a dial-in modem attached, password security for each account is particularly important. But if you're the only one who will ever lay a finger on your system, you might want to delete your password, thus removing the need to enter it each time you log in. It's your call, but you never know when your five-year-old will wander by the keyboard! By the way, you might get the idea from the preceding commands that users can go around changing each other's passwords at will, but that's not the case. Only a superuser (such as root) can change or delete another user's password.

Read more:http://lowfatlinux.com/linux-change-passwordpasswd.html#ixzz1dt9vghMX

What Are The Most Important Linux Commands?


Working from a Linux command line is not always intuitive, especially since there are hundreds of different commands with a myriad of switches and flags to make things even more confusing. You certainly don't need to know all of them to make good use of

your Linux system, but there is a certain set of indispensable tools with which you should be familiar. We've covered a handful of commands in previous sections that let you work with the shell and your file system. The commands covered in this section will complement what you've learned and give you some essential tools to manage your Linux environment. (You'll also be able to use these commands on other Unix-based systems.) You'll pick up other important commands in the "Text Editors" and "Slicing and Dicing" sections but you should first master this starter set to build the skills that will help you perform common Linux tasks more easily. If You Need Help, Ask the man Assuming you can remember the right command for a particular job, it's tougher still to remember all the switches associated with that command. Themancommand (short for manual) will help you on both counts by displaying pages from online manuals and telling you which commands may be relevant to the task at hand. Say you want to change your password, but you don't know the command to do it. You can use themancommand plus the keyword flag,-k, to search by keywordpasswordfor relevant commands: man -k password passwd passwd (1) - change login password pwck pwck (1m) - password/group file checkers vipw vipw (1b) - edit the password file You can probably deduce thatpasswdis the correct command. But before blindly issuing any Linux command, you should know the proper syntax and understand what the command might do to you first. Usingmanwith a command name will display all you need to know (probably more) about a command. For example, entering man passwd will display passwd(1) User Commands passwd(1) NAME passwd - change login password and attributes SYNOPSIS passwd [ name ] passwd [ -d | -l ] [ -f ] [ -n min ] [ -w warn ]

[ -x max ] name passwd -s [ -a ] passwd -s [ name ] DESCRIPTION The passwd command changes the password or lists attributes associated with the user's login name. --More--(5%) (Themancommand pauses after each screenful and waits for you to press the spacebar before continuing.) The wordMoreat the bottom of each page indicates how much of the help has so far been displayed. The terms in square brackets are optional parameters (-d, -l, -f, for example); vertical bars indicate that the terms on either side are mutually exclusive--you can use only one at a time.

Read more:http://lowfatlinux.com/linuxcommands.html#ixzz1dtA6szox

The man Command


man - format and display the on-line manual pages manpath - determine user's search path for man pages

SYNOPSIS
man [-acdfFhkKtwW] [-m system] [-p string] [-C con fig_file] [-M path] [-P pager] [-S section_list] [section] name ...

DESCRIPTION
man formats and displays the on-line manual pages. This version knows about the MANPATH and (MAN)PAGER environment variables, so you can have your own set(s) of personal man pages and choose whatever program you like to display the formatted pages. If section is specified, man only looks in that section of the manual. You may also specify the order to search the sections for entries and which prepro cessors to run on the source files via command line options or environment variables. If name contains a /

then it is first tried as a filename, so that you man ./foo.5 or even man /cd/foo/bar.1.gz.

can

do

OPTIONS
-C config_file Specify the man.conf file to use; the default is /etc/man.config. (See man.conf(5).) path Specify the list of directories to search for man pages. If no such option is given, the environment variable MANPATH is used. If no such environment variable is found, the default list is found by consulting /etc/man.config. An empty substring of MANPATH denotes the default list. pager Specify which pager to use. This option overrides the MANPAGER environment variable, which in turn overrides the PAGER variable. By default, man uses /usr/bin/less-is. section_list List is a colon separated list of manual sections to search. This option overrides the MANSECT envi ronment variable. By default, man will exit after displaying the first manual page it finds. Using this option forces man to display all the manual pages that match name, not just the first. Reformat the source man page, even when an up-todate cat page exists. This can be meaningful if page is corrupted. Don't actually display the man pages, but do print gobs of debugging information. Both display and print debugging info. Equivalent to whatis.

-M

-P

-S

-a

-c

-d -D -f

-F or --preformat Format only - do not display. -h -k -K Print a one-line help message and exit. Equivalent to apropos. Search for the specified string in *all* man pages. Warning: this is probably very slow! It helps to specify a section. (Just to give a rough idea, on

my machine pages.) -m

this

takes about a minute per 500 man

system Specify an alternate set of man based on the system name given.

pages

to

search

-p

string Specify the sequence of preprocessors to run before nroff or troff. Not all installations will have a full set of preprocessors. Some of the preproces sors and the letters used to designate them are: eqn (e), grap (g), pic (p), tbl (t), vgrind (v), refer (r). This option overrides the MANROFFSEQ environment variable. Use /usr/bin/groff -Tps -mandoc to format the man ual page, passing the output to stdout. The output from /usr/bin/groff -Tps -mandoc may need to be passed through some filter or another before being printed.

-t

-w or --path Don't actually display the man pages, but do print the location(s) of the files that would be format ted or displayed. If no argument is given: display (on stdout) the list of directories that is searched by man for man pages. If manpath is a link to man, then "manpath" is equivalent to "man --path". -W Like -w, but print file names one per line, without additional information. This is useful in shell

Man will try to save the formatted man pages, in order to save formatting time the next time these pages are needed. Traditionally, formatted versions of pages in DIR/manX are saved in DIR/catX, but other mappings from man dir to cat dir can be specified in /etc/man.config. No cat pages are saved when the required cat directory does not exist. It is possible to make man suid to a user man. Then, if a cat directory has owner man and mode 0755 (only writable by man), and the cat files have owner man and mode 0644 or 0444 (only writable by man, or not writable at all), no ordinary user can change the cat pages or put other files in the cat directory. If man is not made suid, then a cat directory should have mode 0777 if all users should be able to leave cat pages there. The option -c forces reformatting a page, even if a recent cat page exists.

ENVIRONMENT
MANPATH If MANPATH is set, its value is used as the path to search for manual pages. MANPL If MANPL is set, its value is used as the display page length. Otherwise, the entire man page will occupy one (long) page.

MANROFFSEQ If MANROFFSEQ is set, its value is used to deter mine the set of preprocessors run before running nroff or troff. By default, pages are passed through the table preprocessor before nroff. MANSECT If MANSECT is set, its value is used which manual sections to search. to determine

MANWIDTH If MANWIDTH is set, its value is used as the width manpages should be displayed. Otherwise the pages may be displayed over the whole width of your screen. MANPAGER If MANPAGER is set, its value is used as the name of the program to use to display the man page. If not, then PAGER is used. If that has no value either, /usr/bin/less -is is used. Thus, the command `LANG=dk man 1 foo' will cause man to look for the foo man page in .../dk/man1/foo.1, and if it cannot find such a file, then in .../man1/foo.1, where ... is a direc tory on the search path. NLSPATH, LC_MESSAGES, LANG The environment variables NLSPATH and LC_MESSAGES (or LANG when the latter does not exist) play a role in locating the message catalog. (But the English messages are compiled in, and for English no catalog is required.) Note that programs like col(1) called by man also use e.g. LC_CTYPE. PATH PATH is used in the construction search path for man pages. of the default

SYSTEM SYSTEM is used to get the default alternate system name (for use with the -m option).

SEE ALSO
apropos(1), whatis(1), less(1), groff(1).

BUGS
The -t option only works if a troff-like program is installed. If you see blinking \255 or <AD> instead of hyphens, put `LESSCHARSET=latin1' in your environment.

TIPS
If you add the line (global-set-key [(f1)] (lambda () (interactive) (manualentry (current-word)))) to your .emacs file, then hitting F1 will give you the man page for the library call at the current cursor position. To get a plain text version backspaces and underscores, try # man foo | col -b > foo.mantxt of a man page, without

Read more:http://lowfatlinux.com/linux-manmanual.html#ixzz1dtADIMg2 Using Chmod to Change a File's Permissions Fine; you can decipher the permissions for a file or directory, but what if you want to change them? Maybe you've decided that thepig_infofile is a little too sensitive for just anybody to view, or that you should allow all users to execute the zippity program. Thechmod(change mode) command can take care of that. The general form of thechmodcommand is chmod <permission flags> <file or directory name(s)> To tellchmodthe new permissions for a file, you can use any combination of these permission flag characters:

WHO IT APPLIES TO (pick one or more) u For the owner g For the group o For all others

ACCESS CHANGE (pick one) + Grant access - Deny access

ACCESS TYPE (pick one or more) r For read access w For write access x For execute access

Here are some examples: chmod o-r pig_infoRemove read access from all others. chmod g+rw pig_infoGrant read and write access to group. chmod ugo+x zippityGrant execute access to everybody. In effect, you're saying "change the mode forthese peoplebyadding/removingtheir access toread/write/executethe file namedwhatever." Just pick the proper combination of flags in each of the three columns, depending on what type of access you want for the file. Note: If you givechmoda directory name instead of a file name, the permissions have slightly different meanings. For a directory, read access means that you can list the files with thelscommand; write access allows you to create or delete files; and execute access gives you the ability to change to that directory with thecdcommand. Transferring Ownership of a File Using Chown If you are logged in as root, you can transfer ownership of a file or directory (if you move it into another user's directory) using thechowncommand. To tellchownwhat to do, just give it the new owner and the file name, like this: chown sigmund zippity This will make sigmund the owner ofzippity. Once you've transferred ownership, sigmund will be able to set the file's permissions (withchmod) if he wants to.

Read more:http://lowfatlinux.com/linux-chmod-chown.html#ixzz1dtARH6AB

8. Give a comparison of DOS and LINUX operating systems.


Juergen Haas, About.com Guide

See More About:

Ads Red Hat Linux TrainingRHCE, RHCSS Training & Exam Best Red Hat training in Hyderabadwww.cossindia.net 6-Core 4-Way SuperServersEnergy-efficient Supermicro Server! Featuring Intel Xeon ProcessorsSupermicro.com/ComputerSystem Total System InformationAsset Agent & Utility for Windows, AppleMac, UNIX/Linux GUI/CLI/APIwww.MagniComp.com/sysinfo Linux Ads

unix vs. windows selecting an os unix systems os history os market share

Ads 20 find command examplesTwenty examples of the Unix/Linux find command (free).devdaily.com HP All in One PCMulti Functional & High Performance HP All In One PC, Visit Us Today! www.youtube.com/personalagain What is an Operating System An operating system (OS) is a program that allows you to interact with the computer -- all of the software and hardware on your computer. How? Basically, there are two ways.

OS Operating System Linux Unix OS 7 Windows System New Linux OS

With a command-line operating system (e.g., DOS), you type a text command and the computer responds according to that command. With a graphical user interface (GUI) operating system (e.g., Windows), you interact with the computer through a graphical interface with pictures and buttons by using the mouse and keyboard. With Unix you have in general the option of using either command-lines (more control and flexibility) or GUIs (easier). Unix and Windows: Two Major Classes of Operating Systems And they have a competitive history and future. Unix has been in use for more than three decades. Originally it rose from the ashes of a failed attempt in the early 1960s to develop a reliable

timesharing operating system. A few survivors from Bell Labs did not give up and developed a system that provided a work environment described as "of unusual simplicity, power, and elegance". Since the 1980's Unix's main competitor Windows has gained popularity due to the increasing power of micro-computers with Intel-compatible processors. Windows, at the time, was the only major OS designed for this type of processors. In recent years, however, a new version of Unix called Linux, also specifically developed for micro-computers, has emerged. It can be obtained for free and is therefore a lucrative choice for individuals and businesses. On the server front, Unix has been closing in on Microsofts market share. In 1999, Linux scooted past Novell's Netware to become the No. 2 server operating system behind Windows NT. In 2001 the market share for the Linux operating system was 25 percent; other Unix flavors 12 percent. On the client front, Microsoft is currently dominating the operating system market with over 90% market share. Because of Microsofts aggressive marketing practices, millions of users who have no idea what an operating system is have been using Windows operating systems given to them when they purchased their PCs. Many others are not aware that there are operating systems other than Windows. But you are here reading an article about operating systems, which probably means that you are trying to make conscious OS decisions for home use or for your organizations. In that case, you should at least give Linux/Unix your consideration, especially if the following is relevant in your environment. Advantages of Unix - Unix is more flexible and can be installed on many different types of machines, including main-frame computers, supercomputers and micro-computers. - Unix is more stable and does not go down as often as Windows does, therefore requires less administration and maintenance. - Unix has greater built-in security and permissions features than Windows. - Unix possesses much greater processing power than Windows. - Unix is the leader in serving the Web. About 90% of the Internet relies on Unix operating systems running Apache, the world's most widely used Web server. - Software upgrades from Microsoft often require the user to purchase new or more hardware or prerequisite software. That is not the case with Unix. - The mostly free or inexpensive open-source operating systems, such as Linux and BSD, with their flexibility and control, are very attractive to (aspiring) computer wizards. Many of the smartest programmers are developing state-of-the-art software free of charge for the fast growing "open-source movement. - Unix also inspires novel approaches to software design, such as solving problems by interconnecting simpler tools instead of creating large monolithic application programs. Remember, no one single type of operating system can offer universal answers to all your computing needs. It is about having choices and making educated decisions.

3. Comparison of Linux with MS-DOS, Windows 9x and NT


3.1. Linux Vs MS-DOS
DOS was the first operating system I learned to use. I remember a test by my tutor in which one had to create a hierarchical set of directories. This probably sounds trivial to anyone familiar with graphical user interfaces, but then the scenario was very different. It even looks ancient by today's standards. Windows 95 hadn't been released at that time, and Linux was unheard of in India. I liked DOS much better than Windows 3.1, which looked quite flimsy and unstable, not to mention that it was a big memory hog. DOS is quite different from Linux in many ways. DOS does not provide any graphical user interface and you have to learn at least a dozen commands with its numerous options to do some basic tasks like copying a file or moving between the directories. Even a minor spelling mistake can result in a "Bad command or file name" error. DOS does not support the concept of multi-users; each and every user has to customise the system according to his need every time he wants to work on it. It was also not a multitasking system. This meant that you could not check out the value of a calculation when typing a letter without closing that application first. DOS also does not have any in built security features. This was acceptable as long as you did not want a networking system. There was other variants of MS-DOS, like PCDOS from IBM and some others, which tried to add the missing features. Some of the deficiencies have been resolved using third party utilities but basic limitations like the arcane 640kb-memory limit and single-tasking were not acceptable to many. Now in case you are wondering why anyone would care to use DOS, I will point out some advantages. Basically DOS has had very different goals from that of Linux. It was a very cheap system (as far as cost is concerned) and it was quite usable with its minimalist set of features. It was a simple system to work with. There weren't too many complications to worry about if you didn't want to develop anything on it. It was arguably the world's most popular operating system and it had a comfortable number of applications for common tasks.

3.1.1. Files and directories

The files in Linux can be very long, up-to 255 characters like Windows, and they do not always have extensions. The executable files are identified through an attribute rather than the extension. File extensions are less important to Linux than for DOS and Windows, since Linux usually identifies files by a unique identification code called the magic number that depends on the file type. Directories are similar to that of DOS and follow a hierarchical structure. The path names are separated by forward slashes (/)in Linux whereas DOS and Windows uses back slashes (\). For example:
% cd /mnt/cdrom

A / denotes the root and .. stands for the parent directory, similar to DOS. In bash shells, the ~ symbol maybe used to jump to the home directory quickly. For example:
% cd ~

3.1.2. Linux shell

Several of the DOS commands have Linux equivalents. The Linux shell is similar to the DOS command line but is far more powerful, and I found that it was also more workable with features like colour highlighting and friendlier navigation capabilities, depending on the particular shell you are using. Most Linux distributions come with the Bash (Bourne Again SHell) as the default. There are several others, like the Korn shell and the C shell. They are usually similar. It's recommended that you learn to work with one shell completely before trying out the others. Things usually get complicated if you want to run shell scripts, which are similar to batch files (files with the .bat extension) under DOS.
3.1.3. Running DOS programs under Linux (DOS emulation)

There is a DOS emulator called dosemu www.dosemu.org for Linux that is capable of running DOS programs under the Linux operating system. This software is still under development; you may wish to try it out though. It is known to be fairly usable at least for some applications. If you are looking for Linux just to use DOS programs for free then try using FreeDOS www.freedos.org. That should be much better than Linux.

3.2. Linux vs. Windows 9x and NT


As I have said before Windows is more or less similar to Linux. When people are introduced to Linux they are at first intimidated by the system. It has different kinds of graphical interfaces and things don't always work as they are expected to. When users look at me in a puzzled manner I demonstrate in some easy ways how common tasks like changing the desktop wallpaper or playing a song is similar to Windows. The problem with this kind of approach is that the users complain very soon that Linux doesn't offer them much more than Windows does :-). I agree with them to a certain extent on this. There are some limitations to what you can expect from an operating system. You just can't expect Linux to work like a 3Dshooter game or something. Of course, there are many differences in the shell, the choice of user interfaces and the philosophy and goals of the operating system. Linux is developed as a open system in which the source code of the core Linux system (kernel) is available for anyone for free but how this could affect the end user is difficult to explain initially. The user interface is probably the first thing you notice when you begin to use the Linux system. Windows offers a single, monolithic user interface, which is more or less the same across all the versions. In contrast, Linux has two major desktop environments called KDE (www.kde.org) and Gnome (www.gnome.org). KDE has a built-in window manager, while Gnome is supported by many, such as Sawfish and Enlightenment. The decision of choosing one among the desktop environments and windows managers is left to you. Some of them can run efficiently in a system with low amounts of memory and some of them are designed to look like a game console. KDE would be more similar to Windows, and Gnome with the Enlightenment window manager was fancy enough for me. Try out some of the popular ones before making the decision. Let's take a look at Windows in more detail so that you can clearly make out the differences.
3.2.1. Versions of Windows

Windows has two major series, a desktop oriented series (Windows 9x) And a network oriented series (Windows NT).There are also other versions like Windows CE for embedded systems. Windows 9x series

Before Windows 95 was released, all versions of Windows until version 3.1 were graphical platforms on top of DOS. This offered limited capability for multitasking and the Program Manager interface was cluttered with no distinct hierarchy. Windows 95 was a 32-bit operating system and a major improvement in user interface with its "Desktop" concept adapted from the Macintosh user interface. It also offered limited compatibility with previous versions of Windows and DOS. Stability was also improved Windows 98 and Windows ME offered some more features though nothing major was added. The more recent version called Windows XP is considerably more stable due to incorporating the Windows 2000 kernel, and is comparatively friendlier and easier due to an attractive interface. Windows NT series Windows NT is considerably stable but demands more resources. It supports the Intel architecture, and at one time the Digital alpha and MIPS processors, but I believe those have been dropped now. It managed to replace UNIX in small-scale networks due to the similarity to the popular Windows 95 interface. The latest incarnation called Windows 2000 provides a few more administrative utilities and services.
1) Linux is multiuser , multitask os. 1) dos is single user or windows also its multitasking envornment. 2) Linux is more secured than dos/windows. 3) Linux required password ( its first level security is password.Its support number of level security dep on you. 4) Linux support more than one shell.Thats why you can easily handled same hardware through different way. 5) Linux is portable .Means its open system software. I think this difference is enough for you . If you want more diff than mail me here.

9. Illustrate the significance of /etc/fstab file with respect to installation

< How to edit and understand /etc/fstab - 1.1 > There's a file called /etc/fstab in your Linux system. Learn what its contents mean and how it's used in conjunction with the mount command. When you learn to understand the fstab file, you'll be able to edit its contents yourself, too. In this tuXfile I assume you already know how to mount filesystems and partitions with the mount command. If you don't, I suggest reading the Mounting tuXfile before reading this one.

Author: Nana Lngstedt < nana.langstedt at gmail.com > tuXfile created: 12 October 2003 Last updated: 5 September 2009

contents

What is fstab and why it's useful Overview of the file Device and default mount point Filesystem type Mount options Dump and fsck options Example fstab entries

back to

File systems and directories Linux help tuXfiles home

< What is fstab and why it's useful >

fstab is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under /etc, so the full path to this file is /etc/fstab. /etc/fstab contains information of where your partitions and storage devices should be mounted and how. If you
can't access your Windows partition from Linux, aren't able to mount your CD or write to your floppy as a normal user, or have problems with your CD-RW, you probably have a misconfigured /etc/fstab file. So, you can usually fix your mounting problems by editing your fstab file.

/etc/fstab is just a plain text file, so you can open and edit it with any text editor you're familiar with. However, note that you must have the root privileges before editing fstab. So, in order to edit the file, you must either log in as root or use the su command to become root.

< Overview of the file > Of course everybody has a bit different /etc/fstab file because the partitions, devices and their properties are different on different systems. But the basic structure of fstab is always the same. Here's an example of the contents of /etc/fstab: /dev/hda2 /dev/hdb1 / /home ext2 ext2 defaults defaults 11 12

/dev/cdrom /media/cdrom auto /dev/fd0 proc /media/floppy auto /proc proc

ro,noauto,user,exec 0 0 rw,noauto,user,sync 0 0 defaults 00

/dev/hda1

swap

swap pri=42

00

What does all this gibberish mean? As you see, every line (or row) contains the information of one device or partition. The first column contains the device name, the second one its mount point, third its filesystem type, fourth the mount options, fifth (a number) dump options, and sixth (another number) filesystem check options. Let's take a closer look at this stuff.

< 1st and 2nd columns: Device and default mount point > The first and second columns should be pretty straightforward. They tell the mount command exactly the same things that you tell mount when you mount stuff manually: what is the device or partition, and what is the mount point. The mount point specified for a device in /etc/fstab is its default mount point. That is the directory where the device will be mounted if you don't specify any other mount point when mounting the device. Like you already learned from the Mounting tuXfile, most Linux distros create special directories for mount points. Most distros create them under /mnt, but some (at least SuSE) under /media. As you probably noticed when looking at the example fstab, I use SuSE's mount points as an example. What does all this mean? If I type the following command:

$ mount /dev/fd0
... my floppy will be mounted in /media/floppy, because that's the default mount point specified in /etc/fstab. If there is no entry for /dev/fd0 in my fstab when I issue the command above,mount gets very confused because it doesn't know where to mount the floppy. You can freely change the default mount points listed in /etc/fstab if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it. Some partitions and devices are also automatically mounted when your Linux system boots up. For example, have a look at the example fstab above. There are lines that look like this:

/dev/hda2 / ext2 defaults 1 1 /dev/hdb1 /home ext2 defaults 1 2


As you've learned, these lines mean that /dev/hda2 will be mounted to / and /dev/hdb1 to /home. This is done automatically when your Linux system boots up... if it wouldn't, you'd have a hard time using your cool Linux system because all the programs you use are in / and you wouldn't be able to run them if / wasn't mounted! But how does the system know where you want to mount /dev/hda2and /dev/hdb1? By looking at the /etc/fstab file of course.

< 3rd column: Filesystem type > The third column in /etc/fstab specifies the filesystem type of the device or partition. Many different filesystems are supported but we'll take a look at the most common ones only. ext2 and ext3 Very likely your Linux partitions are Ext3. Ext2 used to be the standard filesystem for Linux, but these days, Ext3 and ReiserFS are usually the default filesystems for almost every new Linux distro. Ext3 is a newer filesystem type that differs from Ext2 in that it's journaled, meaning that if you turn the computer off without properly

shutting down, you shouldn't lose any data and your system shouldn't spend ages doing filesystem checks the next time you boot up. reiserfs Your Linux partitions may very well be formatted as ReiserFS. Like Ext3, ReiserFS is a journaled filesystem, but it's much more advanced than Ext3. Many Linux distros (including SuSE) have started using ReiserFS as their default filesystem for Linux partitions. swap The filesystem name is self-explanatory. The filesystem type "swap" is used in your swap partitions. vfat and ntfs Your USB stick is most likely formatted as Vfat (more widely known as FAT32). Your Windows partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat, and the NT series (NT, 2000, XP, Vista, 7) use NTFS but they may be formatted as Vfat, too. auto No, this isn't a filesystem type :-) The option "auto" simply means that the filesystem type is detected automatically. If you take a look at the example fstab above, you'll see that the floppy and CD-ROM both have "auto" as their filesystem type. Why? Their filesystem type may vary. One floppy might be formatted for Windows and the other for Linux's Ext2. That's why it's wise to let the system automatically detect the filesystem type of media such as floppies and cdroms.

< 4th column: Mount options > The fourth column in fstab lists all the mount options for the device or partition. This is also the most confusing column in the fstab file, but knowing what some of the most common options mean, saves you from a big headache. Yes, there are many options available, but I'll take a look at the most widely used ones only. For more information, check out the man page of mount. auto and noauto With the auto option, the device will be mounted automatically (at bootup, just like I told you a bit earlier, or when you issue the mount -a command). auto is the default option. If you don't want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be mounted only explicitly. user and nouser These are very useful options. The user option allows normal users to mount the device, whereas nouser lets only the root to mount the device. nouser is the default, which is a major cause of headache for new Linux users. If you're not able to mount your cdrom, floppy, Windows partition, or something else as a normal user, add the user option into /etc/fstab. exec and noexec exec lets you execute binaries that are on that partition, whereas noexec doesn't let you do that. noexec might be useful for a partition that contains binaries you don't want to execute on your system, or that can't even be executed on your system. This might be the case of a Windows partition.

exec is the default option, which is a good thing. Imagine what would happen if you accidentally used the noexec option with your Linux root partition...
ro Mount the filesystem read-only. rw Mount the filesystem read-write. Again, using this option might cure the headache of many new Linux users who are tearing their hair off because they can't write to their floppies, Windows partitions, or something else. sync and async How the input and output to the filesystem should be done. sync means it's done synchronously. If you look at the example fstab, you'll notice that this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.

However, if you have the async option in /etc/fstab, input and output is done asynchronously. Now when you copy a file to the floppy, the changes may be physically written to it long time afterissuing the command. This isn't bad, and may sometimes be favorable, but can cause some nasty accidents: if you just remove the floppy without unmounting it first, the copied file may not physically exist on the floppy yet!

async is the default. However, it may be wise to use sync with the floppy, especially if you're used to the way it's
done in Windows and have a tendency to remove floppies before unmounting them first. defaults Uses the default options that are rw, suid, dev, exec, auto, nouser, and async.

< 5th and 6th columns: Dump and fsck options > Dump and, uh, what options? Well, dump is a backup utility and fsck is a filesystem check utility. I won't discuss them in great length here (they would both need their own tuXfile), but I'll mention them, because otherwise you'd spend the rest of the day wondering what on God's green Earth do these things mean. The 5th column in /etc/fstab is the dump option. Dump checks it and uses the number to decide if a filesystem should be backed up. If it's zero, dump will ignore that filesystem. If you take a look at the example fstab, you'll notice that the 5th column is zero in most cases. The 6th column is a fsck option. fsck looks at the number in the 6th column to determine in which order the filesystems should be checked. If it's zero, fsck won't check the filesystem.

< Example /etc/fstab entries > As an example, we'll take a look at a couple of fstab entries that have been a source of endless frustration for new Linux users: floppy and CD-ROM (although these days floppies aren't that important anymore).

/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0


This line means that the floppy is mounted to /media/floppy by default and that its filesystem type is detected automatically. This is useful because the type of the floppy may wary. Note especially the rw and user options: they must be there if you want to be able to mount and write to the floppy as a normal user. If you have trouble with this, check your fstab file to see if these options are there. Also note the sync option. It can be async just as well, but it's sync because of reasons discussed a bit earlier.

/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0


Note, again, the user option that enables you to mount the CD as a normal user. The CD-ROM has the ro option because it's no use mounting a CD-ROM read-write because you wouldn't be able to write to it anyway. Also note the exec option. It's especially useful if you'd like to be able to execute something from your CD. Also note that the noauto option is used with the floppy and CD-ROM. This means that they won't be automatically mounted when your Linux system boots up. This is useful for removable media, because sometimes there won't be any floppy or CD-ROM when you boot up your system, so there isn't any reason to try to mount something that doesn't even exist.

10. What is partitioning at hard disk drive?


Partitioning your Hard Disk for Linux

As outlined in the General Information section, the most common way to install Linux is to allocate a part of your hard disk for Linux. Most computers come with one hard disk, and that hard disk is usually setup to have just one partition which uses all of the space on the hard disk. If this is the case with your computer, then you will need to either add a new hard disk for Linux, or shrink your existing partition to make space for Linux. Each partition not only creates a separate independent space on the hard disk but it also associates a method of reading and writing information to the drive, the format of the drive. Linux has a number of different formats it can use for sections of the hard disk, the most popular being ext2 and ext3 (others include reiserfs, xfs and jfs). Normally you will not have to worry much about the formats of Linux partitions, the installation program will make appropriate suggestions. One other type of partition format for Linux which is worthy of mention is swap. A swap partition is used to effectively extend your memory onto the hard disk, so if your computer wants to use more memory then it has, it will "swap" information in memory which it doesn't need at the time onto the hard disk. It is possible to use a large file on a normal partition for swap however this is much slower. Unless you measure your memory in Gigabytes, you should probably use a swap partition at least the size of your memory, and if you have less then 256Megabytes of ram then you may want a partition 2 or 3 times it. If you are in the common situation of having to shrink the only Windows partition on your hard disk, the first thing to be aware of is that your access to the information on the Windows partition will depend on its format. There are two main types of partition formats for Windows, FAT and NTFS. Generally computers with the Windows 95/98/ME systems will have FAT partitions and Windows NT/2000/XP will have NTFS partitions, though the NT/2000/XP family can also use FAT. The critical difference between FAT and NTFS as far as Linux is concerned, is that while reading information from either system is perfectly safe under Linux, writing information to an NTFS partition is currently regarded as potentially unsafe so you wouldn't be able to edit these files from Linux and access the changes directly under Windows. Linux is perfectly reliable sharing FAT partitions with other operating systems (if your feeling lost, perhaps telling you that when you format a floppy you are actually making a FAT filesystem on it will help put things in perspective). Windows has no native method of reading Linux formatted partitions, but the Free explore2fs program allows you to read and copy information from ext2 and ext3 Linux partitions while you are running Windows. There is now also a filesystem driver from the same source called ext2ifs which allows your ext2 and ext3 partitions to appear as extra drives in Windows NT4/2000/XP (still read only). There are numerous methods for shrinking Windows partitions to make space for Linux (and I would recommend simply making the space and using the installer to create the partitions and format them). No matter what method you use to do this, you should backup all your data before you begin, in fact you should always keep backups of all your important information as a hard disk could fail at any time. Another tip is to defragment your drive in windows before you begin which makes it much easier for the software which has to do the shrinking. The tried and true method for shrinking a partition is a commercial program

called Partition Magic ($69.95 as of Sept 2004). You can also do this with Free software such as parted (or the graphical front-end QTparted) or often as part of the installer itself. Check the installation documentation for the system you plan on installing to see if it's now supports resizing/shrinking ntfs partitions. Whatever scenario you start in, when you begin to install Linux you need to know where you have space to put it. It may be a new hard disk or free space on an existing hard disk. For a modern desktop Linux system you would want to allocate an absolute minimum of 2GB of hard disk space, 5GB would be far better and if you have plenty of space (or if you plan to install lots of large pieces of software, perhaps games) 10GB+ is perfectly reasonable. If you have enough free space the installation program may suggest creating more than one Linux partition, if so it is well worthwhile creating a separate partition for your files, the /home partition. Amongst other things you can reinstall your system or install a new system without having to make an additional backup of your files (remember again you do always keep backups of everything important)

Welcome to the most active Linux Forum on the web.

Home

Forums

HCL

Reviews

Tutorials

Articles

Register

Search Remember Me?


Log in

Main Menu

LinuxQuestions.org > Linux Answers > Hardware

User Name Password

A Short Guide to Partitioning a Hard Drive for a Linux System

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Linux Forums Android Forum Search LQ Tags Linux HCL Linux Tutorials LQ Job Marketplace Linux Wiki Distro Reviews Book Reviews Download Linux Social Groups LQ Blogs Home (Con't)

GNU/Linux Basic Guide This guide will introduce you to the world of GNU/Linux. This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter. Click Here to receive this Complete Guide absolutely free.
Buy Linux - Buy Linux Stickers
By moses at 2004-02-23 14:25 My LQ

Login Register

Write for LQ

LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu

Introduction At some point during your first Linux installation, you may be introduced to "partitioning". This document attempts to provide the new user with the knowledge and understanding necessary to make informed choices about the partitioning of their computer hard disk. First, a brief introduction to what it means to partition a hard disk, and why you would want to do this. What are partitions? Well, as the name suggests, a partition is a small, virtual piece of your hard disk. A partition helps to separate data from other data on your hard disk. You can think of partitions as compartments in the old cafeteria trays--there are small containers built into the tray so you can keep your mashed potatoes separate from your Jell-o, which is kept separate from your meat loaf. If you had only one compartment, your food would run together and you probably don't like lime-flavored gravy on your mashed potatoes. If the tray didn't have any compartments (say you turned the tray over), it wouldn't be useful for holding food at all. Similarly, without any partitions, your hard disk is one lump of empty space upon which no file systems may be placed (in the simplest view). With a single partition, you will have all of your data collect together (while it's possible to separate the data using directories, there are good reasons to make more than one partition on a hard drive). With multiple partitions, you can easily collect similar data sets into one partition, which keeps everything logically and "physically" separate. The simplest partition scheme is just to create one partition and install everything into it. However, there are multiple reasons you probably don't want to do this for the typical install. 1) Partitions keep data separated and safe from one another in case of certain hard drive failures. 2) You should almost always have a "swap" partition (this will be explained in more detail later). 3) If some rogue program starts spitting data to /tmp, if you've got that partition separated from /, your system will not become unusable. There are more reasons, but just let it suffice to say that partitioning is a Good Thing (R) The second simplest partition scheme is to create one large / partition and a swap partition. I promised I would talk about swap space in more detail, so here goes: Swap is what the Linux people talk about when they mean "virtual memory". That is, swap space is used as a slow extension to RAM. The reason it's needed is that most computers don't have so much RAM that all of their programs (and associated files and data) will happily fit into RAM (you could conceivably need as much RAM as hard drive space, and that's prohibitively expensive). So, what the kernel does is take data from some unused block of RAM and write that data out to the swap space. This then frees that RAM for something that needs it right away. Now you know why you need swap, but how much do you need? Well, that depends on what you plan to do with your computer, and how much RAM you have. The best way of determining your swap requirements is to estimate the total required memory of all programs that you will ever run at one time (kernel, X, games, music player, etc.). If you will have multiple people using the computer at one time, it's likely that many of your programs will be loaded two or more times (though that does not

LQ Calendar LQ Rules LQ Sitemap Site FAQ View New Posts View Latest Posts Zero Reply Threads LQ Wiki Most Wanted Jeremy's Blog Bug Report LQ

Syndicate

Latest Threads LQ News


Twitter: @linuxquestions identi.ca: @linuxquestions Facebook: @linuxquestion s

necessarily double or linearly increase the RAM requirements since many of the necessary libraries are only loaded into RAM once). After calculating what you think you'll need, multiply that number by 1.25 to 2 times. This is because you forgot some program, not all programs are dynamically linked to their libraries, you didn't take in to account everyone who will be using the computer, or whatever--you don't want to have too little available memory. Now, subtract the amount of RAM you have installed on your computer. If the number you finally calculate is more than about two times (or so) that of your RAM, you should add more RAM--your computer is going to be slow and will be swapping to disk too often. As an example, I have a Slackware image processing station at home. Here is a partial list of the results from a "top" command when I'm not running much:
Code:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 16 0 480 228 456 S 0.0 0.0 0:04.75 init 2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0 3 root 5 -10 0 0 0 S 0.0 0.0 0:00.06 events/0 4 root 5 -10 0 0 0 S 0.0 0.0 0:00.01 kblockd/0 5 root 16 0 0 0 0 S 0.0 0.0 0:00.05 khubd 6 root 25 0 0 0 0 S 0.0 0.0 0:00.00 pdflush 7 root 15 0 0 0 0 S 0.0 0.0 0:00.39 pdflush 8 root 25 0 0 0 0 S 0.0 0.0 0:00.00

kswapd0 9 root 10 -10 0 0 0 S 0.0 0.0 0:00.00 aio/0 10 root 16 0 0 0 0 S 0.0 0.0 0:00.00 kseriod 11 root 16 0 0 0 0 S 0.0 0.0 0:00.00 usb-storage 12 root 15 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0 13 root 5 -10 0 0 0 S 0.0 0.0 0:00.00 reiserfs/0 17 root 18 0 1488 688 1344 S 0.0 0.1 0:00.08 devfsd 80 root 18 0 1388 536 1336 S 0.0 0.1 0:00.00 dhcpcd 512 rpc 16 0 1512 580 1448 S 0.0 0.1 0:00.00 rpc.portmap 518 root 16 0 1552 616 1364 S 0.0 0.1 0:00.03 syslogd 521 root 16 0 1484 460 1320 S 0.0 0.1 0:00.00 klogd 523 root 18 0 1400 528 1360 S 0.0 0.1 0:00.00

inetd 526 root 20 0 3048 1396 2792 S 0.0 0.2 0:00.20 sshd 535 root 15 0 0 0 0 S 0.0 0.0 0:00.00 nfsd 536 root 21 0 0 0 0 S 0.0 0.0 0:00.00 nfsd 538 root 18 0 1504 552 1424 S 0.0 0.1 0:00.00 rpc.mountd 541 root 21 0 0 0 0 S 0.0 0.0 0:00.00 lockd 542 root 19 0 0 0 0 S 0.0 0.0 0:00.00 rpciod 543 root 21 0 1516 708 1452 S 0.0 0.1 0:00.00 rpc.statd 557 root 16 0 4788 1880 3072 S 0.0 0.2 0:00.13 cupsd 720 root 16 0 1480 588 1436 S 0.0 0.1 0:00.00 crond 722 daemon 16 0 1612 652 1440 S 0.0 0.1 0:00.00 atd 726 root 19 0 1360 556 1316 S 0.0 0.1 0:00.00

acpid 729 root 16 0 3244 1612 2756 S 0.0 0.2 0:00.01 httpd 731 root 16 0 1412 524 1364 S 0.0 0.1 0:00.00 gpm 906 lp 15 0 3040 1164 2724 S 0.0 0.2 0:00.15 cupspolld 913 nobody 16 0 3260 1604 2756 S 0.0 0.2 0:00.00 httpd 914 nobody 16 0 3260 1604 2756 S 0.0 0.2 0:00.00 httpd 915 nobody 16 0 3260 1604 2756 S 0.0 0.2 0:00.00 httpd 916 nobody 16 0 3260 1604 2756 S 0.0 0.2 0:00.00 httpd 917 nobody 16 0 3260 1604 2756 S 0.0 0.2 0:00.00 httpd 981 moses 16 0 2288 1308 2060 S 0.0 0.2 0:00.01 bash 982 root 16 0 1356 492 1312 S 0.0 0.1 0:00.00 agetty 983 root 16 0 1356 492 1312 S 0.0

0.1 0:00.00 agetty 984 root 16 0 1356 492 1312 S 0.0 0.1 0:00.00 agetty 985 root 16 0 1356 492 1312 S 0.0 0.1 0:00.00 agetty 986 root 16 0 1356 492 1312 S 0.0 0.1 0:00.00 agetty 998 moses 17 0 2036 988 1936 S 0.0 0.1 0:00.01 startx 999 moses 16 0 2772 984 2520 S 0.0 0.1 0:00.00 openwin 1015 moses 17 0 2228 636 2192 S 0.0 0.1 0:00.00 xinit 1016 root 15 0 46536 11m 35m S 0.0 1.5 3:33.90 X 1026 moses 15 0 3176 1628 2748 S 0.0 0.2 0:00.49 olvwm 1041 root 16 0 6468 2904 4468 S 0.0 0.4 0:00.50 xterm 1043 root 16 0 6424 2592 4468 S 0.0 0.3 0:00.11 xterm 1045 moses 16 0 2088 1048 1936 S 0.0 0.1

0:00.01 runmozilla.sh 1059 moses 15 0 45804 27m 24m S 0.0 3.7 0:52.84 MozillaFirebird 1060 moses 18 0 3432 1448 3280 S 0.0 0.2 0:00.01 olwmslave 1063 moses 16 0 2280 1276 2060 S 0.0 0.2 0:00.00 bash 1064 moses 16 0 3112 1580 2784 S 0.0 0.2 0:00.14 ssh 1072 moses 16 0 5004 2852 3952 S 0.0 0.4 0:00.04 gconfd2 1135 moses 15 0 1972 880 1732 S 0.0 0.1 0:00.10 telnet 1137 moses 17 0 1704 452 1652 S 0.0 0.1 0:00.01 esd 1138 moses 17 0 0 0 0 Z 0.0 0.0 0:00.00 netstat <defunct> 1140 root 15 0 6456 4200 4468 S 0.0 0.5 0:00.40 xterm 1141 moses 15 0 2280 1312 2060 S 0.0 0.2 0:00.09 bash

1192 root 15 0 6432 2812 4468 S 0.0 0.4 0:00.22 xterm 1193 moses 17 0 2280 1328 2060 S 0.0 0.2 0:00.03 bash 1299 moses 16 0 1860 896 1740 R 0.0 0.1 0:00.00 top The column labeled, "VIRT" shows the total amount of virtual memory (in KB) used by the task. This includes swapped and resident memory used. This is the interesting column since it tells me how much total memory (swap and RAM) I'm using. With the processes above, I'm using approximately 212MB of memory. This includes memory that's "reserved" but not actively being used. I have a total of 768 MB RAM to use. This means that, with very little going on, I'm already about 1/3 of the way to needing to actually use my swap disk. Now, if I were to start doing some image viewing, the total usage jumps to 360 MB with very little effort. If I were to do some actual image processing, the usage would go well over 500MB quickly. That's small beans image processing. I've got images of Io that are well over 800 MB in size, and there are times when I need to load the entire thing in to memory in order to do matrix math on it. A single file will easily max out my RAM, but generally when I do this kind of processing, I'll need several versions of the image in memory. I have a 2GB swap partition because I can not afford more RAM right now. When I do real work, the system slows to a crawl because everything is swapping out to disk. Now, suppose I just want to run a game of Neverwinter Nights on this system? Well, pretty much everything shown in the top above is going to be in use, but I'll also have nwn running. This adds quite a bit because, though the game executable itself is not very large, its data files are huge. We could easily run into nwn needing >128 MB memory without a blink. This would bring us up to 340 MB of memory needed. Now, take in to account that I use my home machine for work, which is the reason I've got 768 MB RAM. If you've only got 128 MB RAM, you're likely going to have problems running your games (especially if you use wine) without swap space. You may have heard that you should make your swap partition 2x the amount of RAM you have. This is OK advice, but it doesn't really address the issue of swap, and it can be horribly inaccurate (you may only need 1.1x or 1.2x RAM, or even 0.5x RAM--it all depends on your planned usage). You can also have more than one swap partition, so if you don't have enough swap and will add another hard drive in the future, you can just create another swap partition on that new drive. The first thing one needs to do before even turning on their shiny new computer is decide how to partition the hard drive. Several questions need to be asked and answered (these questions are not necessarily in order of importance) before that can be done: Part 1. Is this to be a Linux only system? If yes, continue on with part 1. If no, jump to part 2. What kind of system is this?[list=a][*]A file server?[*]A desktop/gaming machine?[*]A work station?[*]A web server?[*]Something else? (Note that there are many similarities between most schemes)[/list=a] Partitioning a Linux-only System: Decisions, Decisions, Decisions:

Disk space requirements: Slackware 9.1: About 2-3 GB for a full install. You should figure out how much your distro of choice needs. What Kind of Partitions: First, some philosophy and actual requirements from the Filesystem Hierarchy Standard: http://www.pathname.com/fhs/pub/fhs-...#THEFILESYSTEM
Quote:

The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system. * To boot a system, enough must be present on the root partition to mount other filesystems. This includes utilities, configuration, boot loader information, and other essential start-up data. /usr, /opt, and /var are designed such that they may be located on other partitions or filesystems. * To enable recovery and/or repair of a system, those utilities needed by an experienced maintainer to diagnose and reconstruct a damaged system must be present on the root filesystem. * To restore a system, those utilities needed to restore from system backups (on floppy, tape, etc.) must be present on the root filesystem. The primary concern used to balance these considerations, which favor placing many things on the root filesystem, is the goal of keeping root as small as reasonably possible. For several reasons, it is desirable to keep the root filesystem small: * It is occasionally mounted from very small media. * The root filesystem contains many system-specific configuration files. Possible examples include a kernel that is specific to the system, a specific hostname, etc. This means that the root filesystem isn't always shareable between networked systems. Keeping it small on servers in networked systems minimizes the amount of lost space for areas of unshareable files. It also allows workstations with smaller local hard drives. * While you may have the root filesystem on a large partition, and may be able to fill it to your heart's content, there will be people with smaller partitions. If you have more files installed, you may find incompatibilities with other systems using root filesystems on smaller partitions. If you are a developer then you may be turning your assumption into a problem for a large number of users.

* Disk errors that corrupt data on the root filesystem are a greater problem than errors on any other partition. A small root filesystem is less prone to corruption as the result of a system crash.
If the distribution follows the FHS, then the following directories will be created in your root filesystem:
Code:

bin Essential command binaries boot Static files of the boot loader dev Device files etc Host-specific system configuration lib Essential shared libraries and kernel modules media Mount point for removeable media mnt Mount point for mounting a filesystem temporarily opt Add-on application software packages sbin Essential system binaries srv Data for services provided by this system (export is more common) tmp Temporary files usr

Secondary hierarchy var Variable data home User home directories (optional) root Home directory for the root user (optional) (note that not even Slackware follows this to the letter) The FHS requires that /usr be used for shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere. Unfortunately, not all developers follow this rule, so you'll likely have to make /usr into a separate partition with enough room to add data and software later. /opt is typically used for add-on software, so should also be made into its own partition. It's a good idea to make a small parition for /boot so that it is safe from any errors in the root filesystem, and you can share it among various installations of Linux If you are going to have a lot of users or a lot of space used by users, it is probably a good idea to make /home its own partition as well. If you are serving a lot of data to other computers, you'll want a separate partition for /export (or /srv). You might even consider having multiple partitions that are mounted under /export, for example, /export/Mars_images /export/Jupiter_images /export/Saturn_images, etc. OK, now that we know what our filesystem is going to look like, it's time to answer some of those questions posed above. i) What kind of system is this?[list=a][*]A file server? You need to provide a lot of space for those files. You probably want to store the data in the /export partition. Give yourself plenty of room, and maybe even multiple partitions under /export. A good rule is to give yourself 2-5 times as much space as you think you'll ever need. If you have multiple data sets, you should provide separate partitions for each. The same goes for an FTP-type server, you'll just need different mount points and names. . . [*]A desktop/gaming machine? You'll want a lot of space in /home, and it should be on its own partition. You'll probably also want to have extra space in /opt and /usr since you're likely to be adding programs in the future. You'll need to have a lot of space available for your 500+ MB games, which means you should have separate partitions for /opt and /usr, since these are the places games typically install to. Also, leave enough space on / so that you can save stuff in your home directory if it's not on its own partition. You should also look at putting a few GB into a /tmp partition. Make sure you don't forget about the swap partition! [*]A work station? A work station typically mounts most necessary data and filesystems from a file server, so very little disk space is really necessary for this type of machine. You should probably have a lot of swap space and a large portion of what's left in /var and /tmp, but /usr and / should not be ignored either--this is probably the most "balanced" partition scheme

since no one local filesystem is more important than any other. [*]A web server? Where ever you decide to install your web pages, they should not be directly on the root partition. It's become accepted policy to create a new mount point under / called /www (though not officially supported by the HFS). This should be a separate partition and large enough to grow. If you are going to log transactions, make sure you have enough space to deal with possible log explosions.[/list=a] A good rule of thumb is to provide enough space to grow in /tmp, /usr, /opt, and the partitions specific to your needs. This means that you'll usually want to make these partitions 2-5 times as large as you think you'll need (really, disk space abhors a vacuum). Creating an Actual Partition Map: My first example is a Slackware file server. This file server is running Slack 9.1, has an 80 GB hard drive in it, almost a GB of RAM, and the only thing it does is export a large amount of data for NFS mounting by other systems. The swap space probably doesn't need to be as big as it is, and neither does the /boot partition. However, I tend to like round numbers. . . Plan for the Partitions:
Code:

Name Size point GB GB GB GB

mount 2 3 2 1

35 GB /export/Cassini Galileo 35 GB /export/Galileo swap 2 GB swap 80GB Total:

root / usr /usr opt /opt boot /boot Cassini

Creating the Partitions: On Slackware, once we've booted to the command prompt with, we do the following (assuming the drive is /dev/hda) (read the man page for fdisk!):
Code:

% fdisk /dev/hda

The number of cylinders for this disk is set to 10011. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/hda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Create the / partition:
Code:

Command (m for help): n Command action e extended p primary partition (1-4)

p Partition number (1-4): 1 First cylinder (1-1011, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (110011, default 10011): +2000M Create the /usr partition
Code:

Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (245-10011, default 245): Using default value 245 Last cylinder or +size or +sizeM or +sizeK (24510011, default 10011): +3000M Create the /opt partition
Code:

Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (611-10011, default 611): Using default value 611

Last cylinder or +size or +sizeM or +sizeK (61110011, default 10011): +2000M Create an extended partition so we can have more than four partitions. This will extend to the end of the disk.
Code:

Command (m for help): n Command action e extended p primary partition (1-4) e Selected partition 4 First cylinder (855-10011, default 855): Using default value 855 Last cylinder or +size or +sizeM or +sizeK (85510011, default 10011): Using default value 10011 Create the /boot partition
Code:

Command (m for help): n First cylinder (855-10011, default 855): Using default value 855 Last cylinder or +size or +sizeM or +sizeK (85510011, default 10011): +1000M Create the Cassini partition
Code:

Command (m for help): n First cylinder

(978-10011, default 978): Using default value 978 Last cylinder or +size or +sizeM or +sizeK (97810011, default 10011): +35000M Create the Galileo partition
Code:

Command (m for help): n First cylinder (5234-10011, default 5234): Using default value 5234 Last cylinder or +size or +sizeM or +sizeK (523410011, default 10011): +35000M Create the swap partition
Code:

Command (m for help):n First cylinder (9490-10011, default 9490): Using default value 9490 Last cylinder or +size or +sizeM or +sizeK (949010011, default 10011): Using default value 10011 Activate the first partition as bootable and print the partition table, change the swap partition type to 82 (Linux Swap).
Code:

Command (m for help): a Partition number (1-8): 1 Command (m for

help): p Disk /dev/hda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 244 1959898+ 83 Linux /dev/hda2 245 610 2939895 83 Linux /dev/hda3 611 854 1959930 83 Linux /dev/hda4 855 10011 73553602+ 5 Extended /dev/hda5 855 977 987966 83 Linux /dev/hda6 978 5233 34186288+ 83 Linux /dev/hda7 5234 9489 34186288+ 83 Linux /dev/hda8 9490 10011 4192933+ 82 Linux Command (m for help): t Partition number (1-8): 8

Hex code (type L to list codes): 82 Changed system type of partition 8 to 82 (Linux swap) Command (m for help): p Disk /dev/hda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 244 1959898+ 83 Linux /dev/hda2 245 610 2939895 83 Linux /dev/hda3 611 854 1959930 83 Linux /dev/hda4 855 10011 73553602+ 5 Extended /dev/hda5 855 977 987966 83 Linux /dev/hda6 978 5233 34186288+ 83 Linux /dev/hda7 5234 9489 34186288+ 83 Linux

/dev/hda8 9490 10011 4192933+ 82 Linux swap Command (m for help): w So, if you're satisfied, you write the partition table. If not, you re-do it to your liking. You'll then need to create filesystems and swap space. That's not really part of this document. You shold have noticed that there are two kinds of partition terms used in fdisk. The first is a "primary" partition, and the second is an "extended" partition (under which other partitions may reside). The reason for this distiction is mostly hereditary--it's a hold-over from the DOS days when we still partitioned disks using DOS, which could only handle four partitions at one time, and instead of fixing that, MS decided to extend the partition tables and created an "extended" partition. I don't really know why Linux still uses such a terrible method, but we're currently stuck with it unless you would like to rewrite a large chunk of the filesystem code in the kernel, as well as the partitioning programs. Anyway, know that the maximum number of regular (primary or extended) partitions is 4. So, if you want to have more than four partitions, you need to have one (and can have only one) extended partition under which you have some number of logical partitions. The partition table will number the extended partition even though you need to have logical partitions within the extended in order to put filesystems onto said partitions, so be wary of, for example, /dev/hda4 in the above example, it's not actually an available partition for the user (you), it's strictly for the computer. The next step is to choose a filesystem for each of our new partitions. The root partition should be journaled (ext3, reiserfs, etc.). The boot partition doesn't need to be journaled, nor do /opt or /usr as long as they are relatively stable. If you are going to be making a lot of changes to the /export/Galileo or /export/Cassini data, you'll need to think about which is more important, security (journaled) or access speed (probably limited by your network more than a journal). A journaled filesystem is not going to completely protect your data, so you should consider a backup solution. The next example is a gaming/home computer running Slackware. 80 GB disk: Plan for the Partitions:
Code:

Size point GB GB GB GB

Name

mount

root 10 / usr 35 /usr opt 33 /opt swap 2 swap

Why so much in root? Because I don't have a separate home partition and so I want room to put data such as papers, images, save files, etc. in my home directories. You may notice that I don't have a /tmp partition either. I tend to go through and clean out /tmp about once a week, so it's not become too much of a problem, though it could be some

day. Especially since it's all residing on /. Maybe I should have saved a gig or so for /tmp, and if it ever becomes a problem, I'll probably make some adjustments (or change the swap partition to /tmp and install one of these "small" 6GB disks laying around). Follow the example above for partitioning the disk. You don't need to make an extended partition this time because you only have four partitions. Don't forget to tag your swap partition as Linux Swap (code 82 in fdisk). There is no boot partition because 1) I only have one OS on this machine; 2) I'm living on the edge w.r.t. keeping my kernel, etc. safe from problems on the root filesystem. I use reiserfs for almost all of my filesystem needs. Part 2. Partitioning for Linux and another OS. This section is going to try to stay generic with regard to which other OS you are going to let reside on your computer. There will, however, be specific references to certain filesystems most commonly used today. Again, before you jump in to partitioning your hard drive, you need to ask yourself some questions. Then you need to answer them. A. Are you installing another OS onto a system on which Linux is already installed?[list=a][*]Have you made backups of the current OS and all data of importance? Do so. Do it again. I'm not kidding or trying to be funny--one backup can be lost or destroyed, and once your data's gone, it's gone. [*]Will you be adding another hard drive or[*]Shrinking the filesystems/partitions to make space for the new OS? [*]Do you have safe backups of all your important data?[*]You might be thinking to yourself, do I need so many backups?[*]You've got to ask yourself a question: Do I feel lucky?[*]Well, do ya, punk?[/list=a] B. Is the other OS already installed on the computer?[list=a][*]Have you made backups of the current OS and all data of importance? Do so. Do it again. I'm not kidding. Don't you think the cost in time and money to back up your data is worth more than the cost in time and money to get back your lost data, if it's even possible?[*]Will you be adding another hard drive[*]Or be shrinking the other filesystem/partitions when you add Linux?[*]Do you have backups?[*]You might be thinking to yourself, do I need so many backups?[*]You've got to ask yourself a question: Do I feel lucky?[*]Well, do ya, punk?[/list=a] C. There are currently no OSs on your system, but you would like to install two, a Linux OS and some other OS (may also be Linux). i) Installing onto a system which already contains Linux. If you are installing an OS onto a system which already contains Linux, you have basically two options: [list=1][*] Add another hard drive and keep the OSs on their own hard drives. This only works if you can afford another hard drive and have space in your computer for another drive (laptops are right out). This scenario is safe and easy. For partitioning, you essentially follow the same rules described in the first part of this document. If you are installing Windows or some other non-Linux OS, the partitioning tools and schemes for those OSs are beyond the scope of this document. Since the OS is going to reside apart from Linux, it can simply be treated as though it were not even on the same computer for purposes of partitioning (dual booting, etc. require other considerations). [*] Add the other OS to the existing drive, which is currently completely occupied by Linux.[/list=1] This is where the "fun" and danger come in. You absolutely MUST back up everything you consider important. If you don't want to reinstall the OS, back it all up. [list=a][*]Backup up.[*]Begin by going to the GNU parted web page. Read the documentation on what you are doing. You must read this and understand that you are putting your data at risk by changing the size of your partitions. I

won't recreate the documentation here, as it's lengthy. Rest assured that it's all important. http://www.gnu.org/software/parted/m...no/parted.html[*]Follow the examples, making sure only to modify the end of a partition, not the beginnning. Section 2.5 contains the examples that will probably interest you.[/list=a] ii) Installing Linux on a machine which already has an OS installed. The most common filesystem other than ext2 is probably HPFS/NTFS, now that Windows XP has gotten itself away from that mess called FAT. To modify NTFS, you should get the ntfsresize package for Linux. I don't know anything about proprietary partitioning programs, so if you choose to use one of those, you're on your own. I am not responsible for any data loss that you may experience, regardless of whether you use ntfsresize or not, but there will be no mention of how to use any other resizeing tools (although parted may be getting to the point that it can mess with NTFS and FAT filesystems too). Ok. So, you got your shiny new laptop with Windows XP installed on it and you're afraid to remove XP completely, but you really want Linux on it too. How to partition the hard drive? Really, it's a question of how to resize the NTFS filesystem so that you can incorporate a partition scheme as discussed above. To change the size of the NTFS, there's a wonderful site that gives you a step-by-step cookbook on how to do it. Since this document is already too long, I'll just point you to the description. http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html Read the page, understand the page, get a boot disk of some sort, and resize your NTFS partition. . . The partition scheme on my laptops is very simple. I typically have a swap partition and a root partition. I don't dual boot, so there's no pressing need for a /boot partition. The hard drives are usually small (20 GB), so there's not much use in making many partitions since one of them is likely to be too small at some point, and I cannot add another hard drive. This is dangerous since I don't have /tmp separated, nor do I have /home separate. It requires that I be much more deligent about what is put on the hard drive. It requires that I worry about backups of important data more. However, it's the compromise I've made, and I live with it. iii) Installing Linux and some other OS (or more) on a fresh computer This is just a simple case of deciding what you want to do with your new computer. Read the first part of this document again, decide what kind of machine this is to be, and decide how you want to set it up. If you want to have Linux and Windows, it was true in the past that you needed to have the bootable windows partition be the first partition on the hard drive. It is unclear to me if that's still the case, but Linux doesn't care, so you might as well make the first partition a windows partition. I use fdisk for ALL of my partitioning needs--I'm old fashioned and know how fdisk works (and doesn't work). cfdisk does weird things (IMHO), and any proprietary tool is never going to make it on my system, and is going to require the use of linux fdisk anyway. fdisk knows how to tag a partition with just about any partition type you need, so it'll work just fine if you want to install BeOS, Windows XP, Linux, and FreeBSD, you can partition the drive using fdisk and everything should be fine (cfdisk has the same abilities w.r.t. partition types). You can see the list of partitions possible by typing "l" while at the fdisk prompt:
Code:

0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wizard hid 1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris

boot 2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/sec (FAT5 Extended 40 Venix 80286 83 Linux c7 Syrinx 6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data 7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / . 8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility 9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor

e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs f Win95 Ext'd (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT 10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT12/16/ 11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PARISC b 12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor 14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedStor 16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary 17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto 18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep 1b Hidden Win95 FA 65 Novell Netware b8 BSDI swap ff BBT In order to have more than four partitions, you have to use extended partitions. fdisk defaults to using the "linux extended" partition type (type "85"). However, if you use type "85", you won't be able to put any non-Linux

filesystems (that are accessable by their OSs) under that Linux extended partition, so you may need to use type "f". Summary So, the trick to partitioning your system is first to decide what you are going to use your system for, but there are some things that don't really change, regardless of the intended use. * You should always have a swap partition. * Partitions are for keeping data separate from other data. * Make sure you have room to grow in the partitions that will need it. * Before changing an existing system, always back up your data. Twice. * If it's possible, it's best to keep your OSs on separate hard disks. 3D acceleration on an ATI IGP 340MupADSL modem Sagem f@st 800 SuSE 10.1 x86_64 installation 28 comments
by johns123 on Mon, 2004-03-01 14:20

This is so typical of the Linux community. Why did you write this? It contains no useful "How to" information at all, and yet you call it a tutorial. Who do you think you are? Our Daddy? Why don't you go back and simply put a "how to" under each heading, and delete the rest of that arrogant poop. I just did a search on "dual boot" of Linux and WinXP. Guess what? I got nothing except this article with tells me nothing. johns
by trickykid on Mon, 2004-03-01 20:05 Quote:

Originally posted by johns123 This is so typical of the Linux community. Why did you write this? It contains no useful "How to" information at all, and yet you call it a tutorial. Who do you think you are? Our Daddy? Why don't you go back and simply put a "how to" under each heading, and delete the rest of that arrogant poop. I just did a search on "dual boot" of Linux and WinXP. Guess what? I got nothing except this article with tells me nothing. johns
Then you should simply move on as this article might help others. Review our rules, if you have nothing constructive to say, then don't say it and just move on to the next thread. http://www.linuxquestions.org/rules.php If you want to post negative comments, do it constructively and explain yourself in why you think it was not helpful. There is no need to post utter crap like this which is not the least bit helpful itself. If you want to discuss this privately, feel free to email me or the admin of the site. If not, then lets move on with the topic, IN A CONSTRUCTIVE MANNER PLEASE! Regards.

by Hartmann on Fri, 2004-03-26 13:32

Hi Moses, I can't thank you enough for this very instructive tutorial. In my humble opinion, you are a talented, highly professional writer. Keep writing! Hartmann.
by Brain Drop on Sun, 2004-04-11 21:40

I have to agree, I thought it was great. I always say I'll make multiple partitions next time and now I think I really will.
by soupface on Wed, 2004-04-21 13:01

A decent article. I learned a lot about partitionswhy they're important, how to create themand about the organization of the filesystem. My only criticism is that your partitioning suggestions aren't very useful. You list a few system types (Server, Workstation, Game-playing computer, etc.) and then have short paragraphs for each with suggestions on how to partition the drive(s). Below are your suggestions for Desktop/Gaming machines:
Quote:

You'll want a lot of space in /home, and it should be on its own partition. You'll probably also want to have extra space in /opt and /usr You'll need to have a lot of space available for your 500+ MB games, which means you should have separate partitions for /opt and /usr, Also, leave enough space on / You should also look at putting a few GB into a /tmp partition. Make sure you don't forget about the swap partition!
So I should have lots of space for, uh, pretty much everything? I don't think this is particularly helpful. I can see that you want to avoid stating percentages explicitly (you mention that most people say "twice as much swap space as RAM" which isn't always best), but you need to say something. Perhaps you could create a list of priorities and explain what users are most likely to want. For example: A gaming system will require lots of space for game data, so a large /opt and /usr partition is most important. Second most important in a gaming system is large swap space so that load-times are reduced. Therefore you should make these partitions reasonably large compared to your /home and root partitions. For workstations, documents are the most important, so the /home directory should be pretty large. If you're working with multimedia (video, images, or sound) be sure to also have enough swap space so editing won't be slow (make your swap as large as the largest file you'll have to edit at a time, plus 100M). However, for other types of editing, the swap space isn't as important, so you can have a larger /opt, /usr partition (I don't know if the suggestions above are wrong or not, so please don't hold me to them) People reading your article need to know why to make certain partitions certain sizes. Tell them what a larger /home partition means and why they do/don't need one. Don't worry about saying things like "your /tmp partition doesn't need to be more than 15% of your total disk space." Other than that, it's a good article. Thanks for sharing it with us.
by moses on Mon, 2004-04-26 11:58

Thanks, guys! Soupface, You are correct, I didn't really want to state exact numbers because it depends on too many variables (disk size, number of applications, usage, etc.). However, you are also correct in stating that there should probably be more useful examples of how large specific partitions should be. . . I'm unable to edit the original LA, so I'll have to post a errata here. That won't happen for some time, but I'll get to it, eventually. Thanks for your suggestions!
by GoinEasy9 on Tue, 2004-04-27 22:12

Thanks Moses as a newbie...just 2 months into using Linux...i appreciate the time u spent writing this.... Thanks again Tom
by Bebo on Thu, 2004-04-29 06:52

Hello, moses, I totally agree with Hartmann - it's a very good article. I have one comment for people reading it, though. I reacted on the gigantic /boot partition - 1 gig! Considering that it probably only will contain a few kernels, come kernel config files and possibly some initrd images, even 100 megs will definitely be enough. Cheers!
by moses on Fri, 2004-04-30 12:32

Holy Cow! I didn't catch that in the editing. . . Yeah, that is huge! It should read something like 100 MB or maybe even 50 MB. . . I've got 9 different kernels in my /boot, some of which have boot splashes and other initrds associated with them and I only use 12 MB. . . Thanks!
by Sage1 on Mon, 2004-05-17 07:27

Good info! Thanks! I find it very difficult to give any credence to the first respondant/troll, who dissed you. He offered absolutely NO constructive guidance, so, is typical of the types of posting that I ignore. I noticed he didn't offer to write an article! If he thinks he is such an expert, he should offer to teach the rest of us! I build up salvaged systems, and put Debian (from Knoppix) on them. My preference, and advice to newbies, is to KISS. For most installs, a 5 Gb home partition, plus the swap file, will do'er. Do you have some advice about making and using, more partitions? I used to make a 60 to 100 Mb Boot partition, but, I quit that.

Read full thread

Login or register to post comments

All times are GMT -5. The time now is 12:09 PM. Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap Open Source Consulting | Domain Registration

Partitioning and Formatting Second Hard Drive in Linux - (ext3)


by Jeff Hunter, Sr. Database Administrator

Contents

Introduction fdisk Create ext3 File System Mounting the File System About the Author

Introduction
This article presents the commands used to partition and format a second hard drive in Linux using the ext3 file system. For the purpose of this example, I installed a second hard drive in a Red Had Linux system where the drive is recognized as/dev/hdb. I want to make only one partition on this hard drive which will be /dev/hdb1.

fdisk
First, you will need to run the fdisk command in order to partition the disk. For this example, I only want to create one ext3 partition. Here is an example session:

[root@racnode1 ~]# fdisk /dev/hdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 4865. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-4865, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): 4865 Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 83 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

Create ext3 File System


The next step is to create an ext3 file system on the new partition. Provided with the distribution is a script named /sbin/mkfs.ext3. Here is an example session of using the mkfs.ext3 script:

[root@racnode1 ~]# mkfs.ext3 -b 4096 /dev/hdb1 mke2fs 1.27 (8-Mar-2002) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 4889248 inodes, 9769520 blocks 488476 blocks (5.00%) reserved for the super user First data block=0 299 block groups 32768 blocks per group, 32768 fragments per group 16352 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.

Mounting the File System


Now that the new hard drive is partition and formated, the last step is to mount the new drive. For this example, I will be mounting the new hard drive on the directory /db. You will first need to create the /db directory before mouting the disk! (e.g. mkdir /db) Edit the /etc/fstab file and add an entry for the new drive. For my example, I will create the /dev/hdb1 entry as follows:

LABEL=/ LABEL=/boot none none none /dev/hdb1 /dev/hda2 /dev/cdrom /dev/fd0

/ /boot /dev/pts /proc /dev/shm /db swap /mnt/cdrom /mnt/floppy

ext3 ext3 devpts proc tmpfs ext3 swap iso9660 auto

defaults 1 1 defaults 1 2 gid=5,mode=620 0 0 defaults 0 0 defaults 0 0 defaults 1 1 defaults 0 0 noauto,owner,kudzu,ro 0 0 noauto,owner,kudzu 0 0

After making the entry in the /etc/fstab file, it is now just a matter of mounting the disk: [root@racnode1 ~]# mount /db [root@racnode1 ~]# df -k Filesystem 1K-blocks /dev/hda3 37191660 /dev/hda1 101089 none 515524 /dev/hdb1 38464340 Used Available Use% Mounted on 11016692 24285724 32% / 12130 83740 13% /boot 0 515524 0% /dev/shm 32828 36477608 1% /db

About the Author


Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX, Linux, and Windows server environment. Jeff's other

interests include mathematical encryption theory, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 17 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science.

The importance of Linux partitions


by VI VE K G IT E on OCTOBER 1, 2005 23 CO MMEN TS

Disk partitioning is the creation of separate divisions of a hard disk drive using partition editors such as fdisk. Once a disk is divided into several partitions, directories and files of different categories may be stored in different partitions. Many new Linux sys admin (or Windows admin) create only two partitions / (root) and swap for entire hard drive. This is really a bad idea. You need to consider the following points while partitioning disk.

Purposes for Disk Partitioning


An operating system like Windows / Linux can be installed on a single, unpartitioned hard disk. However, the ability to divide a hard disk into multiple partitions offers some important advantages. If you are running Linux on server consider following facts: Ease of use - Make it easier to recover a corrupted file system or operating system Performance - Smaller file systems are more efficient. You can tune file system as per

installation.

application such as log or cache files. Dedicated swap partition can also improve the performance (this may not be true with latest Linux kernel 2.6).

Security - Separation of the operating system files from user files may result into a better

and secure system. Restrict the growth of certain file systems is possible using various techniques.

Backup and Recovery - Easier backup and recovery. Stability and efficiency - You can increase disk space efficiency by formatting disk with

various block sizes. It depends upon usage. For example, if the data is lots of small files, it is better to use small block size.

Testing - Boot multiple operating systems such as Linux, Windows and FreeBSD from a

single hard disk.

File systems that need their own partitions Partiti on /usr /var /tmp /boot Purpose This is where most executable binaries, the kernel source tree and much documentation go. This is where spool directories such as those for mail and printing go. In addition, it contains the error log directory. This is where most temporary data files stored by apps. This is where your kernel images and boot loader configuration go.

/home This is where users home directories go.


Let us assume you have 120 GB SCSI hard disk with / (root) and swap partitions only. One of user (may be internal or external or cracker ) runs something which eats up all your hard disk space (DoS attack). For example, consider following tiny script that user can run in /tmp directory:
#!/bin/sh man bash > $(mktemp) $0

Anyone can run above script via cron (if allowed), or even with nohup command:
$ nohup bad-script &

The result can be a total disaster as entire file system comes under Denial of Service attack. It will even bypass the disk quota restriction. One of our Jr. Linux sys admin created only two partition. Later poorly written application eats up all space in /var/log/. End result was memo for him (as he did not followed internal docs that has guidelines for partition setup for clients server). Bottom line create the partition on Linux server.

If you do not have a partition schema, than following attacks can take place: 1. Runaway processes. 2. Denial of Service attack against disk space (see above example script). 3. Users can download or compile SUID programs in /tmp or even in /home. 4. Performance tuning is not possible. 5. Mounting /usr as read only not possible to improve security. 6. All of this attack can be stopped by adding following option to /etc/fstab file:

nosuid - Do not set SUID/SGID access on this partition nodev - Do not character or special devices on this partition noexec - Do not set execution of any binaries on this partition ro - Mount file system as readonly quota - Enable disk quota

Please note that above options can be set only, if you have a separate partition. Make sure you create a partition as above with special option set on each partition: /home - Set option nosuid, and nodev with diskquota option /usr - Set option nodev /tmp - Set option nodev, nosuid, noexec option must be enabled

For example entry in /etc/fstabe for /home should read as follows:

/dev/sda1 /home

ext3

defaults,nosuid,nodev 1 2

Here is mount command output from one of my OpenBSD production server:

/dev/wd0a on / type ffs (local)

/dev/wd1a on /home type ffs (local, nodev, nosuid, with quotas)

/dev/wd0d on /root type ffs (local)

/dev/wd0e on /usr type ffs (local, nodev)

/dev/wd0f on /tmp type ffs (local, nodev)

/dev/wd0h on /var type ffs (local, nodev, nosuid)

/dev/wd0g on /var/log type ffs (local, nodev)

How do I obtain information about partitions?


There are several ways that information about partitions can be obtained on Linux / UNIX like operating systems. List partitions:
fdisk -l

Report file system disk space usage:


df -h

OR
df -k

Display partition mount options including mount points


mount

Sample output:
/dev/sda2 on / type ext3 (rw,relatime,errors=remount-ro)

tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)

/proc on /proc type proc (rw,noexec,nosuid,nodev)

sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)

varrun on /var/run type tmpfs (rw,nosuid,mode=0755)

varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)

udev on /dev type tmpfs (rw,mode=0755)

tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)

devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)

fusectl on /sys/fs/fuse/connections type fusectl (rw)

/dev/sda1 on /media/sda1 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)

/dev/sda5 on /share type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)

/dev/sdb2 on /disk1p2 type ext3 (rw,relatime,errors=remount-ro)

securityfs on /sys/kernel/security type securityfs (rw)

debugfs on /sys/kernel/debug type debugfs (rw)

binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)

gvfs-fuse-daemon on /home/vivek/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=vivek)

Display / edit file system configuration options


less /etc/fstab

or
vi /etc/fstab

Quickly remount /usr in ro mode


mount -o remount, ro /usr

Quickly mount all file system configured in /etc/fstab


mount -a

PART - B 1. a) Explain the architure of Linux..Futher, discuss how the directories are manipulated in this environment. b) In Linux, describe how the file system is organized .Specify the types. 2. a) With relevant options and examples, explain the tar command b) Enlist the differences between the following: i) mv and cp ii) tac and rev19 iii) expr and let iv) cmp and diff 3. a) What is a daemon? Describe the most popular daemons used along with their functions. b) What do you mean by process? Explain the different types of Linux processes. 4. a) Write a simple shell script program for displaying current date all logged in users and process status using switch-case construct. b) What are positional parameters? Give examples. c) Explain the test command with all possible options. 5. a) With respect to Linux operating system, explain the following: i) Path ii) Absolute path name and relative path name. iii) Files in the directory tree. iv) Directory Access Permission. v) File Access Permisson.

b) What is a link ? Justify your answer by giving suitable examples for its types. 6. a) Explain the changes in file system when du and df commnandes are excuted. Futher, describe how the recovery of Linux file system is accomplished. b) Write a note on the following: i) Disabling user accounts ii) Removing user accounts iii) Changing user passwords iv) Starting and stopping processes 7. a) Explain the techinque of managing and changing permissions using any three commands. b) Discuss the different network configuration commands. c) Describe how to remotely use X-Windows from MS-Windows. 8. a) Explain the possible benifits of partitioning of hard disk drive. b) Discuss how the up dation of packges can be done in Linux environment. c) Write a note on Linux installation.

Potrebbero piacerti anche