Sei sulla pagina 1di 15

Cognasium t/a Telamenta. CK 2007/182367/23 P.O.

Box 432, Bromhof, 2154 Phone: 083-377-4946 Fax: 086-679-5126

Linux Survival Guide1


version 0.3

http://www.obsidian.co.za P.O.Box 4938, Cresta, 2118

Tel: +27 11 792 6500

info@obsidian.co.za Fax: +27 11 792 6522

1 This

A document and its LTEX source code may be used and distributed under the GNU Public License

Contents
1 Starting with Linux 2 Shell basics 2.1 Logging in, meeting the shell 2.2 Shell commands . . . . . . . 2.3 Shell interaction . . . . . . . 2.4 Console Features . . . . . . . 2.5 The Standard IO streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 3 3 4 4 5 5 6 7 7 8 8 8 9 9 10 11 11 11 12 13 13 13 13 15

3 Command basics 3.1 The easy way out for DOS addicts . . . . . . . . . . . . . 3.2 Files and Directories Drive Letters not welcome . . . . 3.2.1 Links . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 File ownership and Permissions . . . . . . . . . . 3.2.3 Wild-cards (Globbing) . . . . . . . . . . . . . . . . 3.2.4 Other Oddities . . . . . . . . . . . . . . . . . . . . 3.2.5 What happened to the drive letters? . . . . . . . . 3.3 Commands for Managing Multiple Processes . . . . . . . 3.4 Why Commands need the Shell Piping and Redirection 4 Having a Closer Look 4.1 Revisiting the login procedure . . . 4.2 Further Games Shells Play . . . . 4.3 Commands for a Multi User system 4.4 Printing . . . . . . . . . . . . . . . 4.5 X Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5 The File System 5.1 The Root Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 The /usr and /var Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Copyright c 1997 Obsidian Systems CC. All registered trademarks mentioned are the sole property of their respective owners. All rights reserved.

Starting with Linux

Linux can be intimidating to the beginner. Initially it seems as if you have instantly forgotten everything you knew about computers and you have to start all over. Fortunately many of the concepts are quite simple. The three most fundamental concepts are: Linux is le system centric Everything revolves around the le system. Linux is a multi-tasking system There is always more than one thing that is happening. Linux is a multi-user system Everything that exists and is owned by someone. Have phun.

2 2.1

Shell basics Logging in, meeting the shell

The rst thing you will meet when starting to work with Linux is the login prompt. Linux is fundamentally a multi-user system. This implies that the rst action you must take is to identify yourself to the system by typing your user name and your password. Once you have logged in, you get a command prompt that can look something like: Aleph:$ This means that you are currently working on a machine called Aleph, that your current directory is your home directory (abbreviated by ) and that you do not have super user privileges (indicated by the $ instead of a #). This command prompt is generated by the program that is invoked called the shell. There are many different kinds of shells available for Linux, each with its own commands and conventions. The default shell on Linux is the bash shell and we will assume for the rest of this document that you are using bash.

2.2

Shell commands

The primary purpose of the shell is to provide an interface to the computer by which you can run other programs. Over the years of Unix/Linux development, this has been rened to such an extent that the shell provides a programming language of its own. On the other hand, there are very few commands built directly into the shell. Most actions are implemented as external programs. The simplest shell commands are: help This gives help on shell commands. Type help to get a list of commands (example. help help). cd Change Directory. Changes your current directory. eg. cd /usr/local/src (surprise) /usr/local/src directory. A few helpful variations are: cd (without any directory) takes you back to your home directory. will take you to the

cd - Takes you to the previous directory you were in. cd xxx Takes you to user xxxs home directory.

logout and exit closes the current shell and logs you out if this it the last shell. pwd Prints your present working directory. This might not seem so useful with a proper command prompt setup, but in shells where the current directory isnt displayed, it is essential.

2.3

Shell interaction

The next important aspect of the shell is the tools available to simplify your interaction with the shell. As all interaction with the shell is done by typing, all these tools have the simple purpose of minimizing the number of keystrokes you have to make to get something done. The most important of these are: The TAB key This provides you with command and path completion. When you press the TAB key, the shell tries to gure out what is it that you are trying to type, and completes it for you as far as possible. Words before the rst space on the command line are attempted to be completed as a command, any following words are completed as paths in the le system. As a test, type nsl[TAB]. That should complete to nslookup, a saving of four keystrokes. Or try cd /v[TAB]sp[TAB]mq[TAB]. That should result in cd /var/spool/mqueue, a saving of 8 keystrokes. When the letters are non-unique when you press tab, the computer will beep once, and the second time you press tab it will give you the possibilities. This is an easy way to get a list of all the commands on the system. With nothing on the command line, press [TAB] till you get a question and answer yes. History All commands you type are saved in the history. You can scroll through the history by using the up and the down arrows. History is saved between sessions, so you can nd commands you typed when you logged in the previous time. A more advanced functions of the history that is very useful is reverse searching the history. Try typing Ctrl-R and then the start of a command you typed a while ago. Aliasing You often have to type a long command over and over. The shell provides an easy way for you to create a nickname for that long command. For example on my system, I like to start X-windows with this command: startx -- -bpp 16. By typing alias x=startx -- -bpp 16 I can then just type x instead. To get rid of this alias you could then type unalias x. Key Bindings Some things are used so often it is useful to have single (or simple composite) keystrokes for them. Many of these key-bindings are pre-dened (eg. Ctrl-A for beginning of line, Ctrl-E for end, Ctrl-l for clear screen, Ctrl-C for clear line and many more). You can also create your own bindings with the bind command. Directory Stack Often you are busy working somewhere and you quickly need to check something in another directory. When you are nished there you have to nd the original directory you were working in. To solve this problem you have the directory stack. In its simplest form, you can save your current directory with tt pushd . and later retrieve it with popd. To list the directories currently on the directory stack, type tt dirs.

2.4

Console Features

Some actions Joe Average computer user wants to perform can not easily be implemented with commands or from within the shell. Often you want to work in separate windows even if you have only text mode available, or

need to copy information to the command line that is already printed exactly the way you want it on the screen, or that vital piece of information just scrolled off the screen. For these kind of problems Linux implements some useful solutions: virtual consoles By pressing alt-f1 to alt-f6 you can switch between virtual consoles. The number of consoles may vary and can be customized. While in X, the same can be done by ctrl-alt-f1 etc. To get back to X switch to alt-f7. mouse selection Copy a piece of text by pressing mouse button 1 and dragging to the end of the text. Paste the text by pressing mouse button 2 (normally the right one). scrolling the screen By pressing shift-page-up and shift-page-down the text that scrolled off the screen can be revived. The buffer isnt huge but sufcient for most purposes. The buffer is destroyed if you switch between virtual consoles.

2.5

The Standard IO streams

Finally before we go on to the basic commands, there is a fundamental concept that is applicable to all programs running on a Linux/Unix system but is constantly used when working with the shell. Every process is created with 3 open les. These are called: Standard Input (stdin) the default source of input data Standard Output (stdout) the default destination of any output Standard Error (stderr) the default output stream on which to report errors. One of the most powerful concepts of Unix/Linux is that these standard data streams can easily be bound to each other to form pipes of programs. Well get into the details of this later, for now it is enough to know that they exist.

Command basics

Unlike DOS, Linux commands are not usually part of a command interpreter (the shell) but almost always separate programs. This implies that there is no implicit difference between a Linux command and a user program. Linux commands are just the collection of programs that are generally useful and included in most Linux systems. Anything typed on the command line is checked if it is a built-in shell command, if not it is assumed to be an executable somewhere on the system. If a corresponding executable is found, it is run with the command line arguments following it. Command switches for Linux commands are indicated with a - or sometimes a + and normally come right after the command name, before the operands. For example, in DOS the command to list all the les starting with c in columns would be: dir c*.* /w while the equivalent Linux command would be ls c* As a fast start, here is a comparison of DOS and Unix/Linux commands:

3.1

The easy way out for DOS addicts


DOS cd rd md dir Linux cd rmdir mkdir ls nd df du clear cat more less cp cat mv rm -r cmp comm diff diff3 sort man date date Notes (Lets start easy :-) Who said Linux is more cryptic than DOS ? For le names Finding les For space on drive For space used by les Clear screen Doesnt pause type /p a le browser copying les concatenating les copy le1 le2 le3 = cat le1 le2 le3 doesnt do wild-card renames Be careful !! Simple version Sorted les Complex version Getting kinky 3 les Some things never change Oops, this is computing for grownups :-) Opens up Linux to the ... pro :-) Highly congurable As I said . . .

cls type

copy

ren deltree fc

sort undelete help date time

The following commands are some of the most used commands in Linux as they provide important & useful info. (Most people also type ls when they havent decided what to do next, which makes it probably the most used command in Linux) ls Lists the les in the current directory. Some often used switches: -l long format (default is just names) -a all les. File names starting with . are hidden and dont show up in normal lists. -F add a character to indicate the type of le cat Places the contents of a le or les on the standard output. This is initially useful for reading short text les (cat README), concatenating les (cat le1 le2 le3 leall) but can be used in a wide variety of circumstances. Try cat /etc/fstab to see the conguration le of the le system. more Displays info a screen full at a time. more has been largely replaced by less on systems where it is available. less Is used to view les in a more controlled fashion. Page up and page down works as expected, you can search by typing / and to exit from the viewer you type tt q. Two different ways to invoke less is with a le name or with input from the standard input: less /etc/sendmail.cf cat /etc/sendmail.cf | less

man With man Linux is an open book might be a slight overstatement, but man denitely makes Linux manageable if not exactly friendly. man subject gives a (sometimes cryptic) description of commands, c system calls, subroutines, devices, le formats, games, system admin subjects and other miscellaneous facts of life2 . find the mother of nd programs. Pretty complex and cumbersome but it can search for almost anything. The simplest way of using it is typically find . -iname "foo*" to look for les in this directory and child directories for les starting with foo.

3.2

Files and Directories Drive Letters not welcome

The hierarchical le system is an idea that originated with Unix. It created the concept of a directory that can contain both les and other directories. The basic tools for manipulating les and directories are: mkdir Make a new directory. rmdir Removes a directory. cp Copies les. Takes at least 2 arguments. If both are le names it copies le1 to le2, if the second is a directory the name is kept identical and the le is copied to the directory. If more than 2 arguments are specied the last must be a directory and all the names les are copied to the directory. mv identical to cp but deletes the original le. Note because of shell wild-card expansion the typical DOS construct mv *.a *.b will be expanded to something like mv f1.a f2.a xxx.b whatever.b and will result in an error. The easiest way to do this is by using a sed script. rm Removes les. Removes are not recoverable. rm -r foo removes directory foo and all its subdirectory. Should the super user type rm -r * in the root directory the whole system will be deleted without so much as a are you sure(y/n) you have been warned.

3.2.1

Links

The Linux le system is more versatile than the DOS le system. An important extension (or omissions depending which way you look) is the concept of a link. Often the same le is needed in different places on a disk. Instead of making copies of these les it is possible in Linux to create links. Two kinds of links are possible hard and soft (or symbolic) links. Hard linked les are indistinguishable from normal les, but a change to one is a change to the other. If two les are hard linked one can be deleted without affecting the other seen in another way, you have to remove all hard links to data on a disk before the space is available again. Hard links are only possible between les on the same partition. Directories can not be hard linked. For example, say we have a 10 MB le /home/httpd/hugefile. We need the same le to be in /home/ftp/pub but called interestingle. By executing: ln /home/httpd/hugefile /home/ftp/pub/interestingfile we have two le names, both reported to be 10MB in size but we only use 10MB of space on the hard drive. Symbolic links are just pointers to where the real le can be found. If the real le is deleted the pointer still exists but points to nothing. Symbolic links can span partitions and can link directories. As symbolic links are generally more versatile than hard links, they are more often used.
2 Try

man /usr/share/emacs/19.34/etc/sex.6

3.2.2

File ownership and Permissions

As Unix/Linux is a multi-user system, there must be some way for les to belong to certain users and there must be a mechanism for sharing les amongst users. Furthermore must there be some system by which to tell whom can do what with which le. To implement this, Unix associates every le and directory with an owner and a group. Three different types of permission are given to each le read permission, write permission and execute permission. Combining these aspects, it is logical that each le or directory has 9 pieces of permission information about it. A le permission string typically looks something like -rwxr-xr-- the rst dash is space where the type of le is specied (- is a normal le, d for directory, l for symbolic link etc.) then you get three groups of three entries, a 3 for each of the user, group and other (the rest of the universe). The three dashes in each group is for readability, writeability and executability. In our example the owner can read, write and execute the le, the group members can read and execute the le and the rest can only read it. chown changes the owner of a le or les chgrp changes the group a le or les belong(s) to. chmod changes le permissions. Typically chmod ugo+rwx foo. For example to give the group write permission to le foo: chmod g+w foo

3.2.3 Wild-cards (Globbing) Another difference between DOS and Linux is the handling of wild-cards in le names. DOS requires each program that handles le names to be able to expand wild-cards. In Linux the shell is responsible for expanding wild cards. Thus in DOS if we say del s*.* the delete program has to nd all the les that start with s (say s1 and s2), in Linux the shell expands the le names and rm s* it becomes rm s1 s2 before the remove command is run. Linux also has more wild-card expansions: * matches unlimited numbers of all characters ? matches one occurrence of any character [abcd] matches any one of a,b,c or d [abcd] matches anything but a,b,c or d [a-z] matches the whole range from a to z

3.2.4

Other Oddities

Except for normal les, directories and links, there are a few other le types in Linux. Physical devices are also represented by les. For example your rst serial port is seen as a le /dev/ttyS0. This le can be manipulated with commands like ln, cat and echo, just like a normal le. Another type of le is a named pipe. This is temporary store for data generated by one program and to be read by another.

3.2.5

What happened to the drive letters?

One thing glaringly different between DOS and Linux is the absence of drive letters. Because a unix system may have many more than 26 physical devices (and many drive letters are confusing to say the least), a different type of system is employed. On any unix system one physical device must be specied as the root device. Any number of other divides can then be attached to this le system by mounting the device on an empty directory on an already mounted device. For example, if we have an empty directory /mnt/cdrom, we can mount a SCSI cdrom under that directory with the command: mount /dev/scd0 /mnt/cdrom Later when the cd must be removed, we can unmount it with umount /mnt/cdrom. The power of this system becomes apparent when we realise that the mounting is not limited by physical devices only, but you can mount a remote le system (say on machine foo) to look as part of the local le system with a command like: mount foo:/remote/directory /local/directory Mounting and unmounting also takes care of the problem with removable media and multiple users. In our CD-ROM example the umount would return an error if someone was still using the cd. Some commands used in working with disk drives under Linux are: mount Attaches a drive to the le system. If the le /etc/fstab is set up correctly mounting can be very simple. eg mount /cdrom, if not pretty hairy eg. mount -t iso9660 /dev/scd0 /cdrom. Remote drives are easy to mount but it can normally be done only by the su eg. mount kib1:/usr1/linux/redhat /home/ftp/pub/redhat umount Detaches a drive from the le system. Very simple in comparison to mount. fdformat Low-level formats removable drives (oppies and stifes). sync Most disk transfers under Linux is asynchronous, i.e. it would be possible to remove a stiffy after a copy command has been successful but before the data is actually written to the disk. sync ensures all disk buffers are ushed. Always sync before unmounting drives or other potentially hazardous actions. du Disk utilization. Gives the size (in kb) of the total les in directories. df Disk free. Gives statistics of usage on disk mounted on the le system.

3.3

Commands for Managing Multiple Processes

Except being a multi user system, Linux allows a single user to run multiple processes at the same time. To start multiple processes there are commands for different situations. To handle the processes however the shell must be involved. First we look at the bash interface for multiple jobs. & A command followed by & is run in the background. Z Pressing Z suspends most programs.

fg using fg a suspended program or background job can be brought to the foreground. bg changes a process to a background process. A program that has been suspended with Z can be made to continue in the background using bg. jobs describe the current jobs. fg, bg and kill can function with either %jobnumber (eg %1) or the process id number supplied by ps. ps lists the processes. Without options it lists just the users processes. To see all the processes use ps -ax. pstree graphical representation of processes indicating parentage of processes as well. nohup starts a process that will not be terminated when the shell quits (or the user logs out). Works well only in conjunction with & kill sends a signal to a process identied by its PID or jobnumber. Get the pid with ps. The default signal is terminate, which asks a process to clean up and stop. If that doesnt work you can send the K ILL signal using kill -9 pid killall kills all processes running specied commands. batch runs a process when the load on the system is low. Takes the commands to run from a le or stdin. at schedules a command to be run at a specied time. atq prints the list of commands that are to run at later stages. atrm removes a command from the at queue. crontab program to run commands at scheduled intervals. nice sets the scheduling priority of a program. renice changes the scheduling priority of a program.

3.4

Why Commands need the Shell Piping and Redirection

One of the most powerful aspects of Unix is to string simple commands together to make complex commands that can in turn get their information from les and deposit the results into les. This is called piping and redirection. Under normal circumstances, the output of one command is written to its standard output. A pipe then connects the standard output of that process with the standard input of the next. Either (or both) the initial input and the nal output can be connected to a le called redirection. command1 | command2 Pipes the output of command1 to command2. command > foo Creates or overwrites le foo and write the stdout of command to foo. command < foo Reads stdin from foo. This is the same as cat foo command. command >> foo Appends the stdout of command to the le foo. command &> foo Redirects both the stdout and the stderr to le foo. There are various other ways of accomplishing this. One is important as it is very general: command > foo 2&>1. 2&1 copies stream 2 (stderr) to stream 1 (stdout).

Say for example we had a list of all the commands in Linux in a le called commands. Now we want to order this list and remove any duplicates. We know that there are standard commands called sort and uniq that will do each of these functions (or at least we know it now ;-), and we want the result to be in sorted.commands. We could do something like: cat commands | sort | uniq > sorted.commands Simple! Now try doing that in Windows ;-)

Having a Closer Look

Now we are going to zoom in on a few special aspects we need to understand, or normally need to get working long before we understand them.

4.1

Revisiting the login procedure

OK, so you encounter this Linux system. It looks you in the eye and says: Darkstar login: But youre armed with your user name and password and boldly type them in. Now the question is: What happens next ? The program that allows you to log into a unix system is very simple. It checks if the user name and password combination that you supply should allow access into the system (from information it nds in the /etc/passwd le) and then starts a program called a shell. Your preferred (or enforced) shell is also specied in the /etc/passwd directory. Your shell can be any program. Sometimes it could be a menu system but mostly it is a command line based interpreter. There isnt a standard shell, but there are a number of very widely used ones. Some of the most famous are: sh The original Bourne shell. This is the grandfather of all shells. It has powerful programming capabilities but the original doesnt support getting access to programs running simultaneously (called job control). csh C shell. A very popular shell for human computer interaction but not so popular with shell programmers. The rst shell to support job control. ksh The Korn shell. A very powerful shell that keeps developing. The newer versions are pretty expensive. bash The Bourne Again Shell :-). This is the standard shell from the GNU software suite. The standard choice on a Linux system. The shell you get when you log into the system can be changed with the chsh command.

4.2

Further Games Shells Play

An important aspect of working with shells is setting environment variables.

It is very easy to set an environment variable, for example to set XXX to hallo you type XXX=hallo. This will only be valid for the current shell. In order to make the variable available to all your current shells, you need to export it: export XXX or export XXX=hallo To get a value for an environment variable interactively, you use the read command: read XXX Bash has a complete control language built in. All normal programming structures like for, while and until loops, if and case statements, functions command line argument parsing. Just to wet your appetite, this code snippet would nd all the les under /etc that contains the word confused and in them change any occurance of hallo to goodbye: for x in find /etc -type f do if grep confused $x > /dev/null then cat $x | sed s/hallo/goodbye/g > /tmp/$$ cat /tmp/$$ > $x echo "Modified file $x" fi done

4.3

Commands for a Multi User system

Linux is designed for multiple users that use the same system. It needs commands to manage security, user information and communication between users. login Login into the system is usually handled by the program controlling the terminal. A user is asked for his/her user name and password. When logged in a user starts in his/her home directory where all the users conguration les are and the user has rights to create les and directories. passwd Changes a users pass word. Most systems have certain checks of what constitutes good pass words. su Runs a shell with a different user identication. Without a user name assumes root. Root can su to different users without supplying passwords. groups prints the groups a user belongs to. newgrp changes the users current group. whoami prints the users login name. id prints a summary of identication info. chfn changes information about the user stored in the system. w prints the users that are currently logged unto the system and what they are doing. write sends a message to another user. Write continues until a D or C is entered. wall writes to all users on system.

4.4

Printing

Once the printing systems on a Linux system has been set up printing is simple. even to remote printers. The three main commands are: lpr Print to line printer. Often used as cat try.ps | lpr. Printing is spooled. Different printers and options are controlled by command line options. lpq Prints the pinter queue. lprm Removes a print job from the queue.

4.5

X Windows

Starting X is simple, the only question being which X window manager to start. This section also describes the steps to run X programs on remote machines so that the windows created are displayed on the local X server. startx This is the command usually used to initiate X. It is set up to start the preferred window manager (on Linux without Motif this is usually fvwm). openwin starts the openwindows windows manager, better know to S UN users. xsetroot there are many programs that control and customize the look of the X desktop. xsetroot is one way of changing the desktop background. This is a good example to play around with to get the feel of X conguration utilities. starting remote X clients To start a X client on machine farstar so that the display is on the local machine gaia the following steps must be performed (either manually or automated): 4.1 start an xterm 4.2 Give farstar permission to display on the gaias X server. The simplest (insecure) way of doing this is to run xhost +farstar 4.3 telnet, rlogin or rsh to farstar 4.4 set the DISPLAY variable to gaia:0. Using sh or bash this is done with DISPLAY=gaia:0; export DISPLAY or on csh by set DISPLAY gaia:0 4.5 Run the X program simple :-)

The File System

Outlay of the basic Linux le system: All directories, les, links and devices have the same origin: the root directory /

5.1

The Root Directory

In the root directory are number of standard directories:

/bin contains the binaries for the programs necessary to get the system up and running. Most of the binaries are located in /usr/bin but while starting up the system, is is possible that /usr isnt available yet. (Often the /usr drive is mounted from some remote computer). /dev contains special les that link the le system with the hardware devices. /etc contains system conguration les. The le control the behavior of most of the standard system functions, the system startup, networking and hardware congurations. The /etc directory can have a number of sub directories for grouping collections of les for specic purposes. For example on a typical Linux system /etc can have the following directories: rc.d Files that are executed when the system boots, is shut down or changes its run level. skel Files that should be copied to the home directory of each new user thats created. lilo.conf Linux loader congurations. fstab the le describing which devices are mounted where at boot time /home is where all the users of the systems have their personal directories where they can create les and subdirectories. This directory is often interlinked, cross mounted and generally mangled. /lib is where the dynamically linked libraries needed for the basic system are kept. As all system programs need some of these its a bad idea to delete any les in here unless you really know what youre doing. /sbin is super user (also called root) territory. Programs that are necessary to get the system running, but should only be used by root is kept here. /tmp is temporary work space available to all users of the system. You shouldnt put any les here however as the system has authority to delete anything in here. /tmp is meant to be used by programs only. /lost+found is where bad les go :-) If the system goes down unexpectedly and a le position is lost but not the contents, it is placed in lost+found. This doesnt happen regularly but if you lose something, you know where to look. Every Linux le system that can be mounted somewhere has its own lost+found directory. /mnt All le systems that you want to use on a unix system has to be mounted somewhere. /mnt is a place where you can mount a le system temporarily. /root is the home directory of the super user. This isnt part of the general /home directories as they could possible not be present if something goes wrong. /boot is used by LILO on a Linux system. It contains information and programs to boot the system. /usr is the rest of the Linux system. All the above directories (except for the /home system) must be on the root partition of the system. /usr is where the basic system is extended. On small installations /usr often shares the same disk or even partition with the / directory. On larger system or small systems connected over a network, the detachability of the /usr system leads to more exibility. The outlay of the /usr directory will be detailed in the next section. /var If /usr directories are shared across networks, there are some les that should be local to the machine being used, either because of differences in hardware or preference. These les are kept in the /var directory. Other les kept in the /var directory are les that would normally be in the /usr directory but have been extensively of frequently customized. The les are then symbolically linked tot eh correct places in the /usr directory structure. This means that when the data on a machine is backed up, the /usr directory has to me backed up less frequently, as most modications are done in the /var directory. Large parts of the the /var directory structure mirror the structure of the /usr directory.

5.2

The /usr and /var Directories

A number of subdirectories in the /usr directory are direct counterparts of the directories in the root. These are: bin for binaries of programs and utilities. etc for general program conguration les. Very few programs use this directory. lib are the dynamic libraries used by programs. sbin are binaries intended for use by the super user only. Then there are directories that share system resources: src keeps the source code of the programs installed on the system. Often the binaries installed by the system distribution doesnt contain the source code but there are still some les in src that is used to make parts of the program like conguration les. man the manual pages of the system is kept in the man directory in subdirectories named man1, man2 etc. These manual pages are in source code format and you need the man command to read them. Once formatted, the formatted text is stored in the cat1 cat2 etc. directories. include are the programming include les that are needed to compile new applications or to write your own code that makes use of libraries. doc contains various forms of documentation. info contains documentation in the gnu-info format that is readable using the info program of the emacs editor. share contains information that can be directly shared across platforms. At this stage it is suspiciously empty. dict, dll are directories used by development programs that creates information that is shared by applications developed by them. All programs and applications that need more les for it in order to run creates les and directories in /usr/lib to store this information. It is sometimes said that the order in the rest of the Linux directory tree is just to hide the chaos in /usr/lib :-) One very important directory in usr is the local directory. It is virtually a clone of the /usr system, but is used to manually install new programs and application. This implies that when the operating system is upgraded, everything is /usr that is not in /usr/local can be replaced without loss, and everything in /usr/local should be able to work like usual with a new system (provided the programs are compatible). Some huge programs have their own directories in /usr where they replicate the basic /usr structure just for the specic program. Examples of these are the X windows system (currently X11R6 in /usr/X11R6), the openwindows extensions to X (in /usr/openwin). All games are collected in a similar directory (/usr/games). The var directory contains some directories that were originally part of usr but are now permanently in var.

200826-1185-0

Potrebbero piacerti anche