This action might not be possible to undo. Are you sure you want to continue?
The Linux System Administrator's
Table of Contents Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter 1. Introduction 2. Overview of a Linux System 3. Overview of the Directory Tree 4. Hardware, Devices, and Tools 5. Using Disks and Other Storage Media 6. Memory Management 7. System Monitoring 8. Boots And Shutdowns 9. init 10. Logging In And Out 11. Managing user accounts 12. Backups 13. Task Automation 14. Keeping Time 15. System Logs 16. System Updates 17. The Linux Kernel Source 18. Finding Help
Linux Administration 1
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
Chapter 1. Introduction
"In the beginning, the file was without form, and void; and emptiness was upon the face the bits. And the Fingers of the Author moved upon the face of the keyboard. A nd the Author said, Let there be words, and there were words." The Linux System Administrator's Guide, describes the system administration aspects of using Linux. It is intended for people who know next to nothing about system administration (those saying ``what is it?''), but who have already mastered at least the basics of normal usage. This manual doesn't tell you how to install Linux; that is described in the Installation and Getting Started document. See below for more information about Linux manuals. System administration covers all the things that you have to do to keep a computer syste m in usable order. It includes things like backing up files (and restoring them if necessary), installing new progr ams, creating accounts for users (and deleting them when no longer needed), making certain that the fil esystem is not corrupted, and so on. If a computer were, say, a house, system administration would be c alled maintenance, and would include cleaning, fixing broken windows, and other such things. The structure of this manual is such that many of the chapters should be usable independe ntly, so if you need information about backups, for example, you can read just that chapter. However, this ma nual is first and foremost a tutorial and can be read sequentially or as a whole. This manual is not intended to be used completely independently. Plenty of the rest of the L inux documentation is also important for system administrators. After all, a system administrato r is just a user with special privileges and duties. Very useful resources are the manual pages, which should alw ays be consulted when you are not familiar with a command. If you do not know which command you need, then the apropos command can be used. Consult its manual page for more details. While this manual is targeted at Linux, a general principle has been that it should be useful with other UNIX based operating systems as well. Unfortunately, since there is so much variance between d ifferent versions of UNIX in general, and in system administration in particular, there is little hope to cover all variants. Even covering all possibilities for Linux is difficult, due to the nature of its development.
Linux Administration 2
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
There is no one official Linux distribution, so different people have different setups and man y people have a setup they have built up themselves. This book is not targeted at any one distribution. Distri butions can and do vary considerably. When possible, differences have been noted and alternatives given. For a list of distributions and some of their differences see http://en.wikipedia.org/wiki/Comparison_of_ Linux_distributions. In trying to describe how things work, rather than just listing ``five easy steps'' for each ta sk, there is much information here that is not necessary for everyone, but those parts are marked as such an d can be skipped if you use a preconfigured system. Reading everything will, naturally, increase your understan ding of the system and should make using and administering it more productive. Understanding is the key to success with Linux. This book could just provide recipes, but w hat would you do when confronted by a problem this book had no recipe for? If the book can provide underst anding, then recipes are not required. The answers will be self evident.
Chapter 1. Introduction Like all other Linux related development, the work to write this manual was done on a volun teer basis: I did it because I thought it might be fun and because I felt it should be done. However, like all vol unteer work, there is a limit to how much time, knowledge and experience people have. This means that the m anual is not necessarily as good as it would be if a wizard had been paid handsomely to write it and had spent millennia to perfect it. Be warned. One particular point where corners have been cut is that many things that are already well d ocumented in other freely available manuals are not always covered here. This applies especially to progra m specific documentation, such as all the details of using mkfs. Only the purpose of the program and as much of its usage as is necessary for the purposes of this manual is described. For further information, consult these other manuals. Usually, all of the referred to documentation is part of the full Linux documentatio n set. 1.1. Linux or GNU/Linux, that is the question. Many people feel that Linux should really be called GNU/Linux. This is because Linux is only the kernel, not
Linux Administration 3
C libraries. because I feel it is important to understand the relationship between GNU a nd Linux. licensed exclusivel y through X/Open Linux Administration 4 . In a nutshell.org/linux/lingl.in the applications that run on it. mv lsof. and Windows XP are trademarks an d/or registered trademarks of Microsoft Corporation. I do not feel that this is the proper forum to debate what name people should use when refe rring to Linux. Introduction Red Hat is a trademark of Red Hat.org/gnu/gnu−linux−faq.. Chapter 1. SuSE is a trademark of Novell.php 1. Windows 2000.com/?inode=2312 http://www. the FSF started developing GNU by writing things lik e compliers.html Here are some Alternate views: http://librenix.html GNU/Linux FAQ's − http://www. Linus Torvalds. and to also explain why some Linux is sometimes referred to as GNU/Linux.2.topology. No.html http://atulchitnis. I mention it here.gnu. Inc. UNIX is a registered trademark in the United States and other countries. Linux is a registered trademark of Linus Torvalds. GNU's side of the issue is discussed on their website: The relationship − http://www. what happened was. in the United States and other countries.3. and basic command line utilities before the kernel. Trademarks Microsoft.org/gnu/why−gnu−linux. started Linu x by writing the Linux kernel first and using applications written for GNU.gnu.proximo. II Floor. The document will be s imply referring to it as Linux. Website: www. and dd.html Why Linux should be GNU/Linux − http://www. Windows.net/writings/gnulinux. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Among those utilities are some of the most basic commands like cp.org/gnu/linux−and−gnu.gnu. Windows NT. Most of the basic command line utilities were written by the F ree Software Foundation while developing their GNU operating system.
receives packets from and sends packets to the network. but it provides tools with which all services can be built. 2. an d so on. assigns me mory and other resources to various processes. Overview of a Linux System "God saw everything that he had made. Linux Administration 5 . There are also some application programs for doing work. This way the kernel provides some protection for users from each other. It also pre vents anyone from accessing the hardware directly. Chapter 2. The tools provided by the kernel are used via sy stem calls. forcing everyone to use the tools it provides.in Company Ltd. starts programs and runs them concurrently. " −− Bible King James Version. Various parts of an operating system UNIX and 'UNIX−like' operating systems (such as Linux) consist of a kernel and some syst em programs. First.3. See manual page section 2 for more information on these. Other product names mentioned herein may be trademarks and/or registered trademarks of their respective companies. but it is not.1. so that each part is described in detail elsewhere. It keeps track of files on the disk. An op erating system provides provides many more services than a plain kernel. Genesis 1:31 This chapter gives an overview of a Linux system. the programs that implement these services are described with a consi derable lack of detail. In fact. The purpose of this chapter is to give an understanding of the system as a whole. the major services provided by the operating system are described. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. GNU is a registered trademark of the Free Software Foundation. and saw that it was very good. Then. Website: www. II Floor. The kernel is the heart of the op erating system. The kernel does very little by itself.proximo. No. it is often mistakenly considered to be the operating system itself.
Website: www. The difference is often somewhat blurry. whereas system p rograms are needed to get the system working. run `on top of the kernel'. System programs. if it happens to be a game). Documentation. the opera ting system has been defined by the contents of the installation tape or disks. Some of the more important parts of the Linux kernel Chapter 2. and sometimes even games. II Floor.3. and various other bits and pieces.proximo. network management.in The system programs use the tools provided by the kernel to implement the various service s required from an operating system. can also be part of it. A word processor is an application.2. mount is a system p rogram. although not all programming languages need be part of the opera ting system. filesystem drivers. Overview of a Linux System Linux Administration 6 . in what is called the user mode. 2. and all other programs. Traditionally. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Important parts of the kernel The Linux kernel consists of several important parts: process management. however. memory mana gement. No. Figure 2−1 showssome of them. The difference between system and application programs is one of intent: applic ations are intended for getting useful things done (or for playing. and is important only to compulsive categoriz ers. An operating system can also contain compilers and their corresponding libraries (GCC and the C library in particular under Linux). with Linux it is not as clear si nce it is spread all over the FTP sites of the world. Figure 2−1. hardware device drivers.
Since the world is full of different kinds of hardware. parts of the kernel. i.e. Process management creates p rocesses. No. II Floor. the kernel contains a hardware device driver for each kind of hardware i t supports. At the lowest level. each member of the class has the same interface to the rest of the kernel but differs in what it needs to do t o implement them.3.in Probably the most important parts of the kernel (nothing else works without them) are me mory management and process management. and implements multitasking by switching the active process on the processor.. For example. Some software services provided by the kernel itself have similar properties. and `write sector N'. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Memory management takes care of assigning memory areas a nd swap space areas to processes. Website: www. `read sector N'. the various network protocols have been abstracted into one pr Linux Administration 7 .proximo. There are often many otherwise similar pieces of hardware that differ in how they are controlled by sof tware. all disk drivers look alike to the rest of the kernel. and for the buffer cache. the number of hardware device drivers is larg e. they all have operation s like `initialize the drive'. For example. The similarities make it possible to have general classes of drivers that support similar operation s. and can ther efore be abstracted into classes.
the usual mode is called multiuser mode.org/LDP/l ki/index.3. They are described more thoroughly in later chapters. 0−9. Run level 5 is typically the same as 3 except that a GUI gets started also. The exact list of things that init does depends on which flavor it is. but without much detail.tldp.6 kernel. When I find one for the 2. to run X on the console. init The single most important service in a UNIX system is provided by init init is started as t he first process of every UNIX system. No. in which no one can log in and root uses a shell at the console. Another example is the virtual filesystem (VFS) layer th at abstracts the filesystem operations away from their implementation. the request goes vi a the VFS. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. but usually only some of these are defined by defa ult. Each filesystem type provides an i mplementation of each filesystem operation.html . When some entity tries to use a filesystem. Other runlevels are dependent on how your particular distribution has defined them. Website: www.3. II Floor. Runlevel 3 is defin ed as "multi user" because it is the runlevel that the system boot into under normal day to day conditions. for example. 2.proximo. Runlevel 0 is defined as ``system halt''. it co ntinues the boot process by doing various startup chores (checking and mounting filesystems. there are several to cho ose from. and they vary significa Linux Administration 8 .in ogramming interface.1. I will list it here. Linux allows for up to 10 runlevels. Runlevel 6 is defined as ``system reboot ''. A more in−depth discussion of kernel internals can be found at http://www. and there can be additional ones as w ell. Thisdocument was written for the 2.3. When init starts.4 kernel. single and multiuser modes are considered to be two run levels. as the last thing the kernel does when it boots. the BSD socket library. which routes the request to the proper filesystem driver. starting dae mons. 2. etc). Major services in a UNIX system This section describes some of the more important UNIX services. Runlevel 1 is defined as ``single user mode''. init usually provides the concept of single user mode. Some flavors generalize this as run levels .
even much later.proximo. i.. It can be configured to sort the messages to different files according to write r or degree of importance.3. For example. init makes sure getty is working (to allow users to log in) and to adop t orphan processes (processes whose parent has died. since kernel messages are often more important and need to be read regularly to spot problems. the user logs out. or when log in terminated because the username and password didn't match. Logins from terminals Logins from terminals (via serial lines) and the console (when not running X) are provided b y the getty program. init notices this and starts a new instanc e of getty. getty reads the username and runs the loginprogram. In normal operation. in UNIX all processes must be in a single tree. Th e program doing this is syslog . Linux Administration 9 . so they should be written to a file. kernel messages are often directed to a separate file from the oth ers. it is init that is in charge of killing all other processe s. login runs the shell. It is of ten important that these messages can be viewed later. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If the username and password are correct. When the shell terminates.2. Looking at the contents of /etc/inittab usually will give some hint what the pre defined runlevels are and what they have been defined as.3.3. this is all handled by the system programs. When the system is shut down.e. Chapter 15 will provide more on this. along with anything else it has been configur ed to do. warning. 2. and other messages. Syslog The kernel and many system programs produce error. init starts a separate instance of getty for each terminal upon which logins are to be allowed. unmounting all filesystems and stopping the processor. which reads the password.in ntly between distributions. The kernel has no notion of logins. so orphan s must be adopted). II Floor. No. 2.3.
We will go more into this later. Website: www. i.3.3. icewm .proximo. The cron daemon takes care of starting the commands when specified. II Floor. making the system harder to learn. This arrangement makes the system more flexible. crontab(1). This applies for both text mode and graphical environments. but it is once only: the command is executed at the given time.3. it only implements a window system.. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.e. Each user can have a crontab file. to keep the disks from filling up. Periodic command execution: cron and at Both users and system administrators often need to run commands periodically. but has the disadvantage that it is simpl e to implement a different user interface for each program. and windowmaker . tools with w hich a graphical user interface can be implemented. X also does not implement a user interface.5. See the manual pages cron(1). Graphical user interface UNIX and Linux don't incorporate the user interface into the kernel. the system administrator might want to run a command to clean the directories with temporary files (/t mp and /var/tmp) from old files. crontab(5). KDE and Gnome. bl ackbox .4. Networking Networking is the act of connecting two or more computers so that they can communicat Linux Administration 10 . There are also two popular desktop managers. since not all programs clean up aft er themselves correctly. but it is not repeated. The at service is similar to cron. Some popular window managers are: fvwm . where she lists the commands she wishes to execute and the times they should be executed.in 2. a t(1) and atd(8) for more in depth information.3. they let it be i mplemented by user level programs. For exampl e. No. 2. Chapter 13 will cover this. The cron service is set up to do this.6. 2. instead. The graphical environment primarily used with Linux is called the X Window System (X for s hort).
Network logins Network logins work a little differently than normal logins. 2. telnet and ssh being the major ones in TCP/IP networks. It is highly recommended you use ssh rather than telnet or rlogin.3. it starts a new instance of itself to handle that single attempt. The actual methods of connecting and communicating are slightly complicated.3. These days many Linux system administrators consider telnet and rlogin to be insecure and prefer ssh.tldp. instead of a herd of gettys. There are also several different ways to log in via a network. However. Most basic services (filesystems. such as lower costs and better fault tolerance.7. It is therefore not possible to run a separate getty for each possible virtual conn ection.8. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. 2. This can make system administration easier. a single daemon per way of logging in (tel net and ssh have separate daemons) that listens for all incoming login attempts. UNIX operating systems have many networking features. the ``secure shell''.proximo. since it allo ws centralized administration. the original instance continues to listen for other attemp ts. which encrypts traffic going over the network.in e with each other.org/LDP/nag2/index. p rinting. The new instance works similarly to getty. see the Linux Network Administra tors' Guide http://www. When it notices one. this book merely glances at networking. but the en d result is very useful. No. while still reaping in the benefits of microcomputing and distributed computi ng. thereby making it far less l ikely that the malicious can ``sniff'' your connection and gain sensitive data like usernames and passwo rds. and there can be any number of these depending o n the available bandwidth. Network file systems One of the more useful things that can be done with networking services is sharing files via Linux Administration 11 .html for more information. Website: www. For each person logging in via th e network there is a separate virtual network connection. backups. including a basic d escription of hownetworks operate. II Floor. Network logins have.3. etc) can be done over the network.
This fools the program to think that all the files on the other computer ar e actually on the computer the program is running on. or over the Common Internet File System (CIFS). sinc e it requires no modifications to programs. CIFS however is not. Website: www.. This will be covered in more detail in Section 5. The mailboxes are usually st ored in /var/spool/mail until the user's MUA retrieves them. In Linux.org/HOWTO/Mail−Administrator−HOWTO. This makes information sharing extremely simple. or visit the sendmail or postfix'swebsite.9. 2. II Floor. The delivery of mail to local or remote mailbox es is done by one program (the mail transfer agent (MTA) .org/ . where all new mail is store d.html . NFS is typically a 'UNIX' based service.in a network file system.tldp. No.3. An e lectronic letter is stored in a file using a special format.samba. org . Depending on your network this could be done over the Network File System (NFS). If the receiver's mailbox is in another machine. The mail system consists of many programs. which deli vers it to the mailbox as it best sees fit. In Linux. while the programs u sers use are many and varied (mail user agent (MUA) .4.sendmail. e. For more information on setting up and running mail services you can read the Mail Admin istrator HOWTO at http://www.. http://www.g.proximo.org/ . or http://www. With a network file system any file operations done by a program on one machine are sent over the network to another computer. CIFS is supported by Samba http://www. pine . NFS is supported by the kernel. Linux Administration 12 . e. and special mail programs are used to send and re ad the letters. When someone sends mail. the letter is sent to the other machine.postfix. or evolution . Mail Electronic mail is the most popularly used method for communicating via computer.3. sendmail or postfix ). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Each user has an incoming mailbox (a file in the special format).g. the mail program locates the receiver's mailbox and appends the letter to the mailbox file.
tldp. and not have to wait for it to be printed before one can make a completely revised new version. since it allows one to print out one version.3. usually along the lines of a root filesystem with /b in . You can refer to the Printing−HOWTO located at http://www. The printer is therefore managed by software that implements a print queue: all print jobs are p ut into a queue and whenever the printer is done with one job. the division can be different. the text is kept in a file whil e the job is in the queue. but it is uneconomical not to share printers b etween users.com/fhs/ Chapter 3.html for more help in setting up printers. Printing Only one person can use a printer at one time. covers it insomewhat more detail. since no one ever seems to be able to get the queue soft ware to know exactly when anyone's printout is really finished. The filesystem layout The filesystem is divided into many parts.10. and a /home for everyone's personal files.11. II Floor. the application does not have to wait until the job is actually printed to continue. This is really c onvenient. it can even be all in one filesystem. This can be found on the web at: http://www. 2. This is a great boost to intra−office social r elations. the next one is sent to it automatically. Overview of a Linux System 2. This allows an application program to spit out the print jobs quickly to the print queu e software. Overview of the Directory Tree Linux Administration 13 . the Filesystem Hierarchy Stan dard . Instead. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.in Chapter 2. they form a new queue at the printer. Chapter 3 describes the filesystem layout in some little detail. waiting for their printouts. No.org/HOWTO/P rinting−HOWTO/index. /var fil esystem with changing data (such as log files).3. a /usr filesystem with programs and unchanging data. The print queue software also spools the printouts on disk. This relie ves the users from organizing the print queue and fighting over control of the printer.pat hname. /dev .3.proximo. /etc .e.. Depending on the hardware configuration and the decisions of the system administrator. /lib . i. and a few others.
1..A. /usr . 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.g. This chapter does not explain all files in detail. Not all Linux distribu tions follow this standard slavishly. II Floor. beside him. each capable of being on its own disk or partition.. Background This chapter is loosely based on the Filesystems Hierarchy Standard (FHS). but to give an overview of the system from a filesystem point of view. Milne) This chapter describes the important parts of a standard Linux directory tree. or over the network with NFS. Further information on each fi le is available elsewhere in this manual or in the Linux manual pages. a CD−ROM). there was Pooh. and to administer Linux machines. and vice versa. /var . The full directory tree is intended to be breakable into smaller parts. A system administrator should also read the full FHS for a complete understanding. It outlines the normal way of breaking the directory tree into separate filesystems with different purposes and gives the motivation behind this particular split. a nd there. The FHS attempts to follow Unix tradition and current trends. based on the Filesystem Hierarchy Standard . sitting on his branch. were four pots of honey.in " Two days later. It is not a good idea to break with the F HS without very compelling reasons. Linux Administration 14 . whi ch attempts to set a standard for how the directory tree in a Linux system is organized. but it has gained the support of many Linux distributions. to accommodate to disk size limits and to ease backup and other system adminis tration tasks. but it is generic enough to give you an overview. since ev erything should be in standardized places. Website: www. dangling his legs.. The directory tree has been designed so that it works well in a network o f Linux machines which may share some parts of the filesystems over a read−only device (e. Each p art has a different purpose.1.3." (A. No. The major parts are the root (/ ). making Li nux systems familiar to those with experience with other Unix systems. The intention is not to describe every fi le. There is no authority behind the standard that forces anyone to c omply with it.proximo. 3. This chapter is not as detailed as the FHS. and /home filesystems (see Figure 3−1). version 2. Such a standard has th e advantage that it will be easier to write or port software for Linux.
proximo.e. and to bring it up to such a state that the other filesystems may be mounted. It will also contain tools for fixing a broken system.in Figure 3−1. . althou gh it could be a ramdisk or network drive as well) and contains the files that are necessary for bo oting the system up. No. Parts of a Unix directory tree. not each machine separately) to have / usr network mounted. news. Th e contents of the root filesystem will therefore be sufficient for the single user state. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. it could be mounted read−only. i. and temporary files. which can be cost−effective since it saves disk space (there can easily be hundreds of megabytes. This allows the files to be shared over the netw ork. II Floor. Chapter 3. log files. all the real data on the syst em. Separating home directories to their own directory tree or filesystem makes backups easier. The roles of the different parts of the directory tree are described below. . but that made it impossible to mount /usr read−only. • The /usr filesystem contains all commands. n or should they be modified during normal use. Website: www. and other unchanging fi les needed during normal operation. such as spool directories (for mail. Even if the filesystem is on a local disk. increasingly multiple gigabytes in /usr). to lessen the chance of filesystem corruption during a crash. Overview of the Directory Tree . libraries. etc). Linux Administration 15 . and for recovering lost files from backups.3. No files in /usr should be specific for any given machine. Dashed lines indicate partition limits. .. manual pages. • The /home filesystem contains the users' home directories. formatted manual pages. It can make administration easier (only the master /usr needs to be changed when updating an application. prin ters. • The root filesystem is specific for each machine (it is generally stored on a local disk. Traditionally everything in /var has been somewhere below /usr . • The /var filesystem contains files that change.
A corrupted root filesys tem will generally mean that the system becomes unbootable except with special measures (e.. so you don't want to risk it. infrequently modified filesystem has a better chance of not getting corrupted. II Floor.2. for example by moving files below /var into /usr/var. is that all the standard names work. say. Website: www.e. all TeX in another .proximo. and sometimes to even find the files (e. /var and /usr are actually on the s ame partition. except perhaps on older systems w here the standard boot image for the system.. all Emacs files would be in one directory.e. The important part. all commands are in on e place. i. there is no requirement tha t they actually be on separate filesystems. from a fl oppy). i. manual pages in a huge number of places. The problem with the latter approach is that it makes it difficult to share files (the program direc tory often contains both static and sharable and changing and non−sharable files).3. No. and so on. The root directory generally doesn't contain any files. and how space is allocated for various purposes. usually called /vmlinuz was kept there. for example /home/students and /home/staff. depending on how large the disks are. which requires adding an extra naming level below /home. A big /home might have to be broken across several filesystems. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. documentation in a third. Although the different parts have been called filesystems above.a and /var/log/messages must work. even if. The directory tree might also be divided into files ystems differently. though.g. all data files in another. The root filesystem The root filesystem should generally be small. An alternative would be to group files f iles according to the program they belong to. The Unix filesystem structure groups files according to purpose.in the other parts often do not have to be backed up. 3. or at least not as often as they seldom change.. and making the manual page programs find all of them is a maintenance nightmare). and making /var a symlink to /usr/var.g. They could easily be kept in a single one if the system is a small si ngle−user system and the user wants to keep things simple. and so on. (Most distributions ha Linux Administration 16 . since it contains very critical files and a s mall.. the names /usr/lib/libc.
/lib/modules Loadable kernel modules. As the name suggests. /root The home directory for user root. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. No. programs running often store temporary files in her e. and it might be better to keep it in a separate filesystem. /sbin is not usually in the default path of normal users. the directory can easily grow r ather big. II Floor. although they may use them if necessary and allowed.. Overview of the Directory Tree Commands needed during bootup that might be used by normal users (probably after bootu p). /tmp Temporary files. e. Kernel images are often kept here instead of in the root directory. Website: www. /etc Configuration files specific to the machine.3. LILO or GRUB. all files are kept in subdirectories under the root f ilesystem: /bin Chapter 3.proximo. These are special files that help the user interface with the various devic es on the system. Otherwise. /sbin Like /bin.g.. but will be in root's default path. /dev Device files. but the commands are not intended for normal users. network and filesystem drivers). This is usually not accessible to other users on the system /lib Shared libraries needed by the programs on the root filesystem. If there are many kernel images.g. especially those that are needed to boot the system whe n recovering from disasters (e. /boot Files used by the bootstrap loader. Another reason would be to make sure the kernel Linux Administration 17 .in ve moved those files the the /boot directory.
home directory. II Floor. /etc/shadow /etc/shadow is an encrypted file the holds user passwords. /mnt Mount point for temporary mounts by the system administrator. and /mnt/exta might be the same with a n ext2 filesystem). /etc/passwd The user database. 3. Website: www. The /etc directory The /etc maintains a lot of files. Although /proc does not reside on any disk in reality it is still mentioned here.1 forfurther information. Many networking confi guration files are in /etc as well. and are described in the Networking Administrators' Guide. /mnt/dosa might be the floppy drive using an MS−DOS filesystem. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. /home Mount points for the other filesystems. The format is documented in the passwd manual page.d Scripts or directories of scripts to run at startup or when changing the run level. /usr.proximo. With modern BIOSes and later versions of LILO (the LInux LOader) the 1 024 cylinder limit can be passed with logical block addressing (LBA).g. No. and other information about each user. /etc/fdprm Chapter 3. with fields giving the username.. Some of them are described below. See the section about /proc later in the chapter. /var. /etc/rc or /etc/rc.3. Overview of the Directory Tree Linux Administration 18 .3.in images are within the first 1024 cylinders of an IDE disk. See the lilo manual page for more details. you should determine which program they belong to and read the manual page for that program. This 1024 cylinder limit is n o longer true in most cases. Programs aren't su pposed to mount on /mnt automatically.d or /etc/rc?. For others. Se e Section 2.3. real name. /proc. /mnt might be divided into subdirectories (e.
automatically output after a successful login. See the magic and file manual pages for more inform ation. Contents ar e up to the system administrator. Often used for getting information to every user. but describes groups instead of users.in Floppy disk parameter table. also contains information about swap areas us ed automatically by swapon −a .10. II Floor.. No. and upda ted automatically by the mount command. such as warnings a bout planned downtimes. Initially set up by the bootup scripts.3. Used when a list of mounted filesystems is needed.defs file usually has a man Linux Administration 19 .defs Configuration file for the login command. /etc/group Similar to /etc/passwd. See Section 5. Describes what different floppy disk formats loo k like.proximo. /etc/mtab List of currently mounted filesystems. See the group ma nual page in section 5 for more information. Contains the descriptions of various file formats bas ed on which file guesses the type of the file. e. Website: www. /etc/login. /etc/motd The message of the day. See the setfdprm manual page for more information. The contents are up to the system administrator. b y the df command. Also fstab usually has its own manual page in section 5. /etc/inittab Configuration file for init. /etc/issue Output by getty before the login prompt. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Used by setfdprm .g. The login. Usually contains a short description or we lcoming message to the system. /etc/magic The configuration file for file.7 and the mount manual page for more informa tion. Under Linux. /etc/fstab Lists the filesystems mounted automatically at startup by the mount −a command (in /etc/rc or equivalent startup file).
so that it becomes impossible (or at least harder) to gain superuser privileges by breaking into a system over a modem or a network.rc.proximo. will che ck that the user's shell is listed in /etc/shells and will not let people log in unless the shell is listed ther e. II Floor. /etc/printcap Like /etc/termcap /etc/printcap . See the manual pages for the respective shells. Programs are written so that instead of directly outputting an escape s equence that only works on a particular brand of terminal.cshrc Files executed at login or startup time by the Bourne. /etc/bash. See the termcap. BASH . i. /etc/securetty Identifies secure terminals.4. Prefer to log in as an unprivileged user and use su or sudo to gain root pr ivileges. The /dev directory Linux Administration 20 . curs_termcap. Do not allow root logins over a network. Describes by what ``escape sequences'' various terminals can be controlled. the terminals from which root is allowed to log in. /etc/termcap The terminal capability database. No. Website: www. or C shells. /etc/profile. ftpd.e. Users can also create individual cop ies of these in their home directory to personalize their environment. However it uses different syntax. Typically only the virtual consoles are listed.3. The chsh command allows users to change their login shell only to shells listed in this file. The printcap has a manual page in section 5. they look up the correct sequence to do whatever it is they want to do in /etc/termcap. 3. is the server process that provides FTP services for a machine. /etc/csh. /etc/shells Lists trusted shells. but intended for printers. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. These allo w the system administrator to set global defaults for all users. and terminfo manual pages for more information..in ual page in section 5. As a result most programs work with most kinds of te rminals.
It is a character device on major node 2 and minor 0. and later with the /dev/MAKEDEV script.e. /dev/fd0 The first floppy drive. If you are lucky enough to have several drives then they will be numbered sequentially. those that are not pa rt of the standard MAKEDEV. /dev/hdc . II Floor.proximo. It is a character device on major node 14 and minor 3. Partitions 1−4 are primary partitions and partitions 5 and above are logical partitions inside extended partitions. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. I will try to include them in the next revision. This means that applications do not need to know about what kind of h ardware you have but merely how to communicate with the framebuffer driver's API (Application Pro gramming Interface) which is well defined and standardized.3. /dev/hda /dev/hda is the master IDE drive on the primary IDE controller. /dev/fb0 The first framebuffer device. If you think there are other devices which should be included here but aren't then let me know. The framebuffer is a character device and is on major node 29 and minor 0.in The /dev directory contains the special device files for all the devices. The device files are c reated during installation. Therefore the Linux Administration 21 . Website: www. Read the kernel documentation to find details of any particular device. A framebuffer is an abstraction layer between softwa re and graphics hardware. /dev/dsp Digital Signal Processor. The /dev/MAKEDEV. and /dev/hdd are the master and slave devices on the secondary controller respectively. Basically this forms the interface between software which produces sound and your soundcard.local is a scr ipt written by the system administrator that creates local−only device files or links (i. Each disk is divided into partitions. Many of these device files will need support compiled into your kernel for the hardware. No. This list which follows is by no means exhaustive or as detailed as it could be. /dev/hdb the slave d rive on the primary controller. such as device files for some non−standard device driver).
in device file which references each partition is made up of several parts. For each partition inside the drive add the partition number to th e minor minor node number for the drive. The loopback devices are block devices on major node 7 and with minor nodes starti ng at 0 and numbered sequentially. For example if you wish to mount an iso9660 C D ROM image without burning it to CD then you need to use a loopback device to do so. djs1 and so on. Digital joysticks are called djs0. They are character devices on major node 15. Subsequent printers are numbered lp1. Linux Administration 22 . /dev/lp0 The first parallel printer device. The y are character devices on major mode 6 and minor nodes starting at 0 and numbered sequentially . This is usu ally transparent to the user and is handled by the mount command. Subsequent joysticks are numbered js1.3. /dev/loop0 The first loopback device. They are char acter devices on major node 37 and start at minor node 0 for ht0 1 for ht1 etc. The anal ogue joysticks start at minor node 0 and go up to 127 (more than enough for even the most fanati c gamer). Subsequent drives are numbered ht1 etc. minor 69 (64 + 5 = 6 9). Drives on the secondary interface are handled the same way. For example /dev/hdc9 referen ces partition 9 (a logical partition inside an extended partition type) on the master IDE drive on the secondary IDE controller. Refer to the manual pages for mount and losetup. Digital joysticks start at minor node 128. For the first I DE controller all partitions are block devices on major node 3. The major and minor node numbers are somewhat complex. No. lp2 etc. The master drive hda is at minor 0 and the slave drive hdb is at minor 64. For example /dev/hdb5 is major 3. but with major node 22. js2 etc. II Floor.proximo. Website: www. /dev/ht0 The first IDE tape drive. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. /dev/js0 The first analogue joystick. Loopback devices are used for mounting filesystems which are not located on other block devices such as disks.
No. Metadisks are related to RAID (Redundant Array of Independ ent Disks) devices.in /dev/md0 First metadisk group. These are named similarly to disks on the internal IDE control lers (/dev/hd*). II Floor.opensound. Partitions on this device are found by adding the partition number to the minor number for the device. Refer to the OSS documentatio n at http://www. This can be found at http://www. /dev/psaux The PS/2 mouse port. Website: www.org/HOWTO/Software−RAID−HOWTO. minor node 1.tldp. Anything sent to /dev/null will disappear. It is a character device on major nod e 14. The first device is /dev/pda and it is on minor node 0. This scheme limits you to 4 parallel disks of 15 partitions each. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.html . So for example the minor node number for /dev/pdc6 wou ld be 38 (32 + 6 = 38). /dev/pdc at 32 and /dev/pdd at 48. This can be useful if. /dev/pcd0 is on minor node 0 with subsequent drives being on minor nodes 1.proximo.3. These are numbered from 0 onwards. /dev/null The bit bucket. /dev/mixer This is part of the OSS (Open Sound System) driver. It is a character device on major node 1 and minor node 3. you wish to run a comm and but not have any feedback appear on the terminal. They are block devices on major node 45. Please refer to the most current RAID HOWTO at the LDP for more details. 3 Linux Administration 23 . All are block devices on major node 46. Minor nodes need slightly mor e explanation here. /dev/pda Parallel port IDE disks. Metadisk devices are blockdevices on major node 9 with minor nodes starting at 0 and numbered sequentially. Each device is limite d to 15 partitions each rather than 63 (the limit for internal IDE disks). /dev/pcd0 Parallel port CD ROM drives. 2. A black hole where you can send data for it never to be seen again. /dev/pdb minor nodes start at 16.com for more details. This is a character device on major node 10. for example. minor node 0.
in etc. When it has no more entropy to use then it must wait until it has collected more before it will allow any more numbers to be read fro m it. /dev/zero Linux Administration 24 . 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. /dev/random or /dev/urandom These are kernel random number generators. The following drives are named similar to IDE drives. II Floor. Many times this it the port used to connect an external modem to your system. but when there is no more entropy to use it will continue to return numbers using a pseudo ra ndom number generating formula. It is a character device on major node 99 wit h minor node 0. and so on. Website: www.3. The minor node numbers start from 0 for / dev/pt0. /dev/parport0 The raw parallel ports. Subsequent devices after the first are numbered sequentially incrementing the min or node. They are character devices on major node 96.proximo. /dev/urandom works similarly. /dev/sdb is the second SCSI drive. /dev/random is a non−deterministic g enerator which means that the value of the next number cannot be guessed from the preceding one s. 1 for /dev/pt1. This is considered to be less secure for vital purposes such as cr yptographic key pair generation. /dev/pt0 Parallel port tape devices. and so forth. Initially it also uses the entropy of the system hardw are. They are character devices on major node 1 with minor nodes 8 for /dev/random and 9 for /dev/urandom. Tapes do not have partitions so these are just numbered sequentially. No. It uses the entropy of the system hardware to generate numbers. Most devices which are attached to parallel ports have their own drivers. /dev/sdc is the third SCSI drive. /dev/ttyS0 The first serial port. If security is your overriding concern then use /dev/random. This is a device to access the port directly. if spee d is more important then /dev/urandom works fine. /dev/sda The first SCSI drive on the first SCSI bus.
g.proximo. but the tradition is overwhelmingly in support for this name.in This is a simple way of getting many 0s. The /usr filesystem is often large. II Floor. 3.5. The name lib comes from library. /usr/X11R6. and miscellaneous other documentation files. It is a character device on major node 1 and minor node 5. No. t he X files have not been integrated into the rest of the system. /usr/share/doc Manual pages. GNU Info documents. All files in /usr usua lly come from a Linux distribution. Some of the subdirectories of /usr are listed bel ow (some of the less important directories have been dropped. locally installed programs and other stuff goes below /usr/local. There is a directory tree below /usr /X11R6 similar to that below /usr itself. Some commands are in /bin or in /usr/local/bin.. /usr/share/man. /usr/sbin System administration commands that are not needed on the root filesystem . Almost all user commands. /usr/lib Unchanging data files for programs and subsystems. The X Window System. /usr/share/info.3. for example when you want a file of fixed length but don't really care what it contains. This should actually be below / usr/lib for consistency. e. /usr/include Header files for the C programming language. or even a completely n ew distribution. without having to install all programs again. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. T his makes it possible to update the system from a new version of the distribution. /usr/local Linux Administration 25 . To simplify the development and installation of X. all files. most server programs. This can be useful sometimes. respectiv ely. since all programs are installed there. The /usr filesystem. see the FSSTND for more information). Website: www. Every time you read from this device it will r eturn 0. originally libraries of programming subroutines were stored in /usr/lib. including some site−wide co nfiguration files. /usr/bin.
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
The place for locally installed software and other files. Distributions may not install a nything in here. It is reserved solely for the use of the local administrator. This way he can be absolu tely certain that no updates or upgrades to his distribution will overwrite any extra software he has i nstalled locally. 3.6. The /var filesystem The /var contains data that is changed when the system is running normally. It is specific for each system, i.e., not shared over the network with other computers.
/var/cache/man A cache for man pages that are formatted on demand. The source for manual page s is usually stored in /usr/share/man/man?/ (where ? is the manual section. See the manual page for man in section 7); some manual pages might come with a pre−formatted version, which might be stored in Chapter 3. Overview of the Directory Tree /usr/share/man/cat* . Other manual pages need to be formatted when they are fir st viewed; the formatted version is then stored in /var/cache/man so that the next person to view the same page won't have to wait for it to be formatted. /var/games Any variable data belonging to games in /usr should be placed here. This is in case /usr is mounted read only. /var/lib Files that change while the system is running normally. /var/local Variable data for programs that are installed in /usr/local (i.e., programs that have been installed by the system administrator). Note that even locally installed programs should use t he other /var directories if they are appropriate, e.g., /var/lock. /var/lock Lock files. Many programs follow a convention to create a lock file in /var/lock to ind
Linux Administration 26
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
icate that they are using a particular device or file. Other programs will notice the lock file and won't attempt to use the device or file. /var/log Log files from various programs, especially login(/var/log/wtmp, which logs all logi ns and logouts into the system) and syslog(/var/log/messages, where all kernel and syst em program message are usually stored). Files in /var/log can often grow indefinitely, and may require cleaning at regular intervals. /var/mail This is the FHS approved location for user mailbox files. Depending on how far your distribution has gone towards FHS compliance, these files may still be held in /var/spool/mail. /var/run Files that contain information about the system that is valid until the system is next booted. For example, /var/run/utmp contains information about people currently logged in . /var/spool Directories for news, printer queues, and other queued work. Each different spool ha s its own subdirectory below /var/spool, e.g., the news spool is in /var/spool/news . Note that some installations which are not fully compliant with the latest version of the FHS may hav e user mailboxes under /var/spool/mail. /var/tmp Temporary files that are large or that need to exist for a longer time than what is a llowed for /tmp . (Although the system administrator might not allow very old files in /var/tmp eithe r.) 3.7. The /proc filesystem The /proc filesystem contains a illusionary filesystem. It does not exist on a disk. Instead, t he kernel creates it in memory. It is used to provide information about the system (originally about processes , hence the name). Some of the more important files and directories are explained below. The /proc filesystem
Linux Administration 27
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
is described in more detail in the proc manual page.
/proc/1 A directory with information about process number 1. Each process has a directo ry below /proc with the name being its process identification number. /proc/cpuinfo Information about the processor, such as its type, make, model, and performance. /proc/devices List of device drivers configured into the currently running kernel. Chapter 3. Overview of the Directory Tree /proc/dma Shows which DMA channels are being used at the moment. /proc/filesystems Filesystems configured into the kernel. /proc/interrupts Shows which interrupts are in use, and how many of each there have been. /proc/ioports Which I/O ports are in use at the moment. /proc/kcore An image of the physical memory of the system. This is exactly the same size as yo ur physical memory, but does not really take up that much memory; it is generated on the fly a s programs access it. (Remember: unless you copy it elsewhere, nothing under /proc takes up any disk space at all.) /proc/kmsg Messages output by the kernel. These are also routed to syslog. /proc/ksyms Symbol table for the kernel. /proc/loadavg The `load average' of the system; three meaningless indicators of how much work the system has to do at the moment.
Linux Administration 28
1. both physical and swap. 4. This is mainly a convenience to ma ke it easier for programs to get at their process directory.in /proc/meminfo Information about memory usage. No. Hardware Utilities Linux Administration 29 . but wisdom listens. /proc/modules Which kernel modules are loaded at the moment. Wh en two processes look at /proc. For example. II Floor.6. /proc/uptime The time the system has been up. as well). Note that while the above files tend to be easily readable text files. /proc/stat Various statistics about the system. /proc/net Status information about network protocols. /proc/self A symbolic link to the process directory of the program that is looking at /proc. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Hardware. they get different links. /proc/version The kernel version." Jimi Hendrix This chapter gives an overview of what a device file is. and how to create one. such as the number of page faults since the system was booted.8.txt if you have the Linux kernel source code installed on your system. Website: www. There are many commands that do little more than read the ab ove files and format them for easier understanding. Chapter 4. the freeprogram reads /proc/meminfo convert s the amounts given in bytes to kilobytes (and adds a little more information. and Tools "Knowledge speaks. Devices. The devices listed here are correct as of kernel version 2. The canonical list of device files is /usr/src/linux/Documentation/devices.3.proximo. they can sometimes be f ormatted in a way that is not easily digestible.
1. We know from looking at the de vices.3. We need to use mknod to create it. The kernel refers to hardware devices as numbers. 4.1. The major and minor node numbers are numbers understood by the k ernel. If it turns out not to be in your path then you will need to specify the path to it explicitly. so we use filenames. However som etimes the MAKEDEV script will not know about the device file you wish to create. The mknod command MAKEDEV is the preferred way of creating device files which are not present. II Floor. The devices. ttyS0 is a serial port. If by some chance you need to create one which is not provided then you should first try to us e the MAKEDEV script. Access permissions of 0660 means read and write permission for the owner (root in this cas e) and read and write permission for members of the group (dialout in this case) with no access for anyone e lse. This script is usually located in /dev/MAKEDEV but might also have a copy (or a symb olic link) in /sbin/MAKEDEV. No.2. Website: www. So we now know all we need to create the file.txt that it should be a character device with major number 4 and minor number 64. Linux Administration 30 . To take an example. this would be very difficult for us to remember. In general the command is used as: This will create the device file /dev/ttyS0 with major node 4 and minor node 64 as a char acter device with access permissions 0660 with owner root and group dialout.txt file in the kernel source documentation is the canonical sourc e of this information. In order to use mknod you need to know the major and minor node numbers for the device you wish to create. let us suppose that our version of the MAKEDEV script does not know how to create the /dev/ttyS0 device file. The MAKEDEV Script Most device files will already be created and will be there ready to use after you install your Linux system.1.in 4. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo. This is where the m knod command comes in.
1.5. It is unlikely in the extreme that the ttyS0 file would not be provided by t he MAKEDEV script. The lsdev command lsdev TO BE ADDED 4.1.7 in chapter 3. The lsusb command lsusb TO BE ADDED 4.2. insmod Linux Administration 31 .8. More Hardware Resources More information on what hardware resources the kernel is using can be found in the /proc directory. No. 4.6. The hdparm command hdparm TO BE ADDED 4.2.1. TO BE ADDED 4.2. II Floor. 4.2.1. lsmod lsmod TO BE ADDED 4.1.7. The lsraid command lsraid TO BE ADDED 4.4.in As you can see. but it suffices to illustrate the point. The lspci command lspci TO BE ADDED 4.1.proximo. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.3. Kernel Modules This section will discuss kernel modules.3. Refer to Section 3. many more steps are required to create the file. In this example you can se e the process required however.1.
The disk means nothing to L inux until you make a filesystem. • Format your disk.5.2.) . II Floor. • Mount different filesystems to form a single tree structure. This chapter explains all these initial activities. except for using floppies.in insmod TO BE ADDED 4. You have to make filesystems on your disks so that files can be stored on them and reserve space for t he different parts of your system.2.proximo. Usually. then files can be created and accessed on it. modprobe modprobe TO BE ADDED Chapter 5.3. depmod depmod TO BE ADDED 4.3. No. (Formatting is nowadays not necessary for most hard disks. . One reason for partitioning is to store different operating systems on the same disk. Website: www. • Make a filesystem (of a suitable type) on each disk or partition. such as checking for bad se ctors. or manually as Linux Administration 32 . You'll need to come back to this cha pter if you add a new disk or want to fine−tune your disk usage. Using Disks and Other Storage Media "On a clear disk you can seek forever. if you want to use it for several activities that aren't supposed to interf ere with one another. This does various things to prepare it for use. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. either automatically. once you get your system set up. rmmod rmmod TO BE ADDED 4. The basic tasks in administering disks are: . you need to do a fair amount of work on your di sks. • Partition a hard disk.2.4. you won't have to go through the work again. which simplifies back−ups a nd helps protect the system files from corruption. Another reason is to keep user files separate from system files. " When you install or upgrade your system. .
Something similar is needed for most devices. (Manually mounted filesystems usually need to be unmounted manually as well. This way no spe cial programs (and no special application programming methodology. For example. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. since it is not a good idea to have several people cat their files to the printer at th e same time.1. be in a form that the printe r understands). and character devices (such as tapes and serial lines) . II Floor. inspecting a serial device might give Linux Administration 33 .3. recognizes two different kinds of device: random−access block d evices (such as disks). for example. No. of which you also need to be awarewhen using disks. of course. In the output of ls −l. one seldom needs to wo rry about device files at all. and some random−access. to send a file to the printer. Each supported device is represented in the filesystem as a device file. Since devices show up as files in the filesystem (in the /dev directory).in needed. some of which may be serial. such as catching interrupts or polling a se rial port) are necessary to access devices. it is easy to see just what device files exist. Wh en you read or write a device file. 5. Two kinds of devices UNIX. and therefore Linux. This program m akes sure that only one file is being printed at a time.proximo. Website: www. the data comes from or goes to the device it represents. Using Disks and Other Storage Media and its permissions. In fact. and will automatically send files to the printer as soon as it finishes with the previous file. one could just say and the contents of the file are printed (the file must. the first column contain s the type of the file Chapter 5. using ls or another suitable command. one usually uses a special program to send the files to be printed (usually lpr ). However.) Chapter 6 contains information about virtual memory and disk caching.
the first character is `−'. the computer can say just ``hey disk. Website: www. Hard disks This subsection introduces terminology related to hard disks. tells an informed user the type of the file. of which either or both surfaces are coat ed with a magnetic substance used for recording the data. Linux Administration 34 . you can skip this subsection. it doesn't mean that you really do have an SCSI hard disk. `c' in crw−rw−rw− above. give me what I want''. this movement combined with the rotation of the platters a llows the head to access all parts of the surfaces. although high−performance hard disks have higher speeds and older disks may have lower speeds. For each surface.3. The processor (CPU) and the actual disk communicate through a disk controller . but much less so than it would otherwise be. for directori es it is `d'. or automatic bad sector repl acement. and for block devices `b'. (In reality. This relie ves the rest of the computer from knowing how to use the drive. A hard disk co nsists of one ormore circular aluminum platters\ . See Figure 5−1 for a schematic picture of the important parts in a hard disk. Note that usually all device files exist even though the device itself might be not be installed . No. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo. If you already know the terms and concepts. II Floor. Having all the device files makes the installation programs simpler. and makes it easier to add new hardware (the re is no need to find out the correct parameters for and create the device files for the new device). For ordinary files.. So just because you have a file /dev/sda. typical rotation speed is 5400 or 7200 rotations per minute. in this case a character device.in The first character in the first column.e. instead of a long and complex series of electric signals to move the head to the proper location and waiting for the correct position to come under the head and doing all the other unpleasant stuff necessary. see the ls man page for further information. since the controllers for different types of dis ks can be made to use the same interface towards the rest of the computer. such as caching. i. The heads move along the radius of the platters. 5. there is a read−write head that examines or alters the recorded data. Therefore. the interface to the controller is still complex.) The controller may also do other things. The platters rotate on a common axis.2.
This division is used to specify locations on the hard disk and to allocate disk space to files. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. and these in turn are di vided into sectors.3. Usually the number of sectors is the same for all tracks. but some hard disks put more sectors in outer tracks (all sectors are of the sa me physical size. called tracks. one might say ``surface 3. A schematic picture of a hard disk. Using Disks and Other Storage Media Linux Administration 35 . and the electronics that control the operation of the mechanical parts. No. Chapter 5.in The above is usually all one needs to understand about the hardware. Typically. Figure 5−1.proximo. The surfaces are usually divided into concentric rings. a sector will hold 512 bytes of data. sector 7''. track 5. There are also othe r things. Website: www. To find a given place on the hard disk. II Floor. so more of them fit in the longer outer tracks). but they are mostly not relevant for understanding the working principl es of a hard disk. T he disk itself can't handle smaller amounts of data than one sector. such as the motor that rotates the platters and moves the heads.
It is not always possible to place files like this. II Floor. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. This improves performance. it is not necessary to move the heads to read all of it. files that are stored in several places on the disk are called fragmented. so by placing the data that is often accessed together (say. a file) so that it is within one cylinder.3. the heads for the other surfaces are also on the corresponding tracks . Linux Administration 36 . No. It takes time to move the heads from one track (cylinder) to another. This means that when th e head for one surface is on a track.proximo.in Each surface is divided into tracks (and sectors) in the same way. All the corresponding tracks taken together are called a cylinder.
respectively. its filesystems don't even try to keep files within a single cylinder. II Floor. and 35 sectors per track. which makes it impossible to specify a track number that is larger than 1024 in the CMOS RAM. 1024 tracks. 2048 tracks. The geometry is usually stored in a special. the specification of the number of each is called the geometry of a hard disk. and automati c prefetches done by the controller. and translates the address that the computer gives it by halving the head nu mber. Since Linux often will not know the real geometry of a disk. the hard disk controller lies about the geometry. which is the same thing). thus making it impractical to use the all−data−on−one−cylinder trick to boost performance. Unfortunately.3. Instead. /dev/sdb. The issue is further complicated by on−controller caches. which is too little for a large hard disk. and 35 sectors per track. the controller translates a sequential sector number to a head. /dev/hdb. Its controller could lie to the computer and claim that it has 16 heads. The mathematics can be more complicated in reality.in The number of surfaces (or heads. because the numbe rs are not as nice as here (but again. that the computer might not know the real geometry of an SCSI disk either. This translatio n distorts the operating system's view of how the disk is organized. Similar naming conventions exist for oth Linux Administration 37 . and /dev/hdd. SCSI disks use a sequential sector number (i . cylinder. For example. and sectors vary a lo t. battery−powered memory location called the CMOS RAM . the BIOS has a design limitation. These are known as /dev/hda. Each hard disk is represented by a separate device file.e. Note. There can (usually) be only two or f our IDE hard disks. cylinders. the details are not relevant for understanding the principle). The translation is only a problem for IDE disks. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo. Website: www. and a complet ely different method for the CPU to talk with the controller. which alm ost always gives similar performance. SCSI hard disks are known as /dev/sda.. from where the operating system can fetch it during bootup or driver initialization. and so on. No. a hard disk might have 8 heads. howev er. /dev/hdc. and doubling the track number. th us not exceeding the limit on tracks. so they are insulated from the problem. and translates the addresses given by the computer into something that fits reality. it tries to assign sequentially numbered sectors to files. and sector triplet). To overcome thi s.
3. This technology is commonly used to provide mult iple workstations access to the same data. and format the disk in any means he or she chooses. A fibre cha nnel network is very fast and is not burdened by the other network traffic in a company's LAN. it does save money by using less expensive network hardware. a NAS need to make use of a protocol to allow access to it's disks. The administrator can partition. is a virtual disk provided by the SAN. iSCSI is a newer technology that sends SCSI commands over a TCP/IP network. While this method may not be as fast as a Fibre Channel network. This i s filesystem level access. However. Note that the device files for the hard disks give access to theentire disk. with no regard to partitions (which will be discussed below).00 USD each. Website: www. Similar to a SAN.proximo. II Floor. More To Be Added 5. A LUN. Fibre channel cards cost around $1000. 5. Network Attached Storage − Draft A NAS uses your companies existing Ethernet network to allow access to shared disks. Two networking protocols commonly used in a SAN are fibre channel and iSCSI . it's very expensive. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. or NFS. Linux Administration 38 . No. The system administrator does not have the ability to partition or format the di sks since they are potentially shared by multiple computers. and it' s easy to mess up the partitions or the data in them if you aren't careful. They also require special fibre channel switches. Storage Area Networks − Draft A SAN is a dedicated storage network that provides block level access to LUNs. The disks' device files are usually used only to get access to the master boot record (which will also be discussed below). With a NAS this is either CIFS/Samba .4. The system administrator the same access and rights to the LUN as if it were a disk directly attached to it. or logical unit number. see Chapter 4 for more information.in er hard disk types.3.
but is removable and one drive can be used to a ccess different floppies. which must be a 3. that is included in th e drive. No.proximo. usi ng a 3. More To Be Added 5. However. Since the drive has to operate a bit differently and the operating sy stem must know how big the disk is. a floppy is divided into tracks and sectors (and the two corresponding track s on either side of a floppy form a cylinder).4. Website: www. for example.5 inch driv e can use both 720 KB and 1. A floppy drive can usually use several different types of disks. CIFS TO BE ADDED 5. a 3.5 inch. Linux Administration 39 . A floppy corresponds to one platter in a hard disk.5 inch HD floppy. The floppy disk itself doesn't have a read−write head.4. a normal 3. Like a hard disk. Floppies A floppy disk consists of a flexible membrane covered on one or both sides with similar m agnetic substance as a hard disk. Linux machines can also make use of CIFS shares. and NFS was used with UNIX & Linux networks. there are many device files for floppy drives.. whereas the hard disk is one in divisible unit.in Chapter 5.1. Does this mean that your Windows 2003 server or your Linux box are NAS servers because they provide access to shared drives over your network? Yes. These devices are specifically designed to provide high speed acc ess to data. Using Disks and Other Storage Media Traditionally CIFS was used with Microsoft Windows networks. one per combination of dr ive and disk type. i. II Floor. and the same floppy can be read by many drives. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.2. NFS TO BE ADDED 5.44 MB disks.5 inch drive. Therefore. high density disk (H) of size 1440 KB (1440). You could also purchase a NAS de vice from a number of manufacturers. but there are many fewer of them than on a hard disk.3. they are. /dev/fd0H1440 is the first floppy drive (fd0).e. with Samba.5.
No. e. /dev/fd1. Whereas a typical hard disk will have an a Linux Administration 40 . but in the mean time you can examine the /etc/fdprm file. mere mechanics. II Floor. plastic coated disk. the signal line that is used f or this is sometimes broken. CD−ROMs A CD−ROM drive uses an optically read. When the laser hits a hole.in The names for floppy drives are complex.6. The automatic devices are called /dev/fd0. Some of these require using special formatting programs. This naturally requ ires that the floppy is formatted first. This makes it easy to code bits. The information is recorded on the surface of the disk in small `holes' aligned along a spiral from the center to the edge. for exa mple. and worse. the laser is reflected in one wa y. or if the autodetecting for some reason fails and the proper device file is missing. however. CD−ROM drives are slow compared to hard disks.proximo. 5. Linux can handle many nonstandard floppy disk formats in addition to all the standard one s. Using Disks and Other Storage Media you are experiencing weird problems using floppies. The drive direct s a laser beam along the spiral to read the disk. The parameters the automatic device uses to access a disk can also be set using the progr am setfdprm . This can be useful if you need to use disks that do not follow any usual floppy sizes.g. it is reflected in another way. this might be the reason. Unfortunately. and Linux therefore has a special flopp y device type that automatically detects the type of the disk in the drive. if the y have an unusual number of sectors. It specifies the settings that setfdprm recognizes. and so on. The rest is easy. It works by trying to read the first s ector of a newly inserted floppy using different floppy types until it finds the correct one. Website: www. We'll skip these disk types for now.3. when it hits smooth surface. and therefor e information.. The only way to correct it is to repair the floppy drive. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The operating system must know when a disk has been changed in a floppy drive. in order to avoid using cached data from the previous disk. this won't always be noticeable when using the drive from within MS−DOS. If Chapter 5.
in verage seek time less than 15 milliseconds. There is also VMWare.proximo. a commercial product. Rock Ridge allows longer filenames. No. http://www. making a CD−ROM look more or less like any contemporary UNIX filesystem.3. II Floor. Website: www.com for more information. is an API (Application Program Interface) replacement. A CD−ROM drive is accessed via the corresponding device file. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Linux supports both ISO 9660 and the Rock Ridge extensions.com for more information. a fast CD−ROM drive can use tenths of a second for seeks. more strict ly. the extensions are recognize d and used automatically. making it usable by non−UNIX sys tems as well. CD−ROMs are very good. The filesystem is only half the battle. making it unnecessary to copy the files to the hard disk. See the VMWare website. symbolic li nks. the ISO 9660 filesystem is not usable. Most CD−ROMs contain data that requires a special program to access. and a lot of other goodies. For installing new software. This standard specifies a very minimal filesystem.vmware. making installation easier and saving a lot of hard disk space). Ironically perhaps. it is so minimal that every operating system should be a ble to map it to its native system. On the other hand. Wine. which emulates an entire x86 machine in software. although it is still possible. Please see the wine documentation at http: //www. wine actually stands for ``Wine Is Not an Emulator''. under dos emu. called the Rock Ridge extension. For normal UNIX use. or wine. the Windows emulator. The slowness means that CD−ROM dr ives are not as pleasant to use as hard disks (some Linux distributions provide `live' filesystems on CD−RO Ms. The most popular one is specified by the international standard ISO 9660 . The ac tual data transfer rate is fairly high at hundreds of kilobytes per second. a Rock Ridge filesystem is still a valid ISO 9660 filesystem. which is even more c rude than the one MS−DOS uses. There are several ways to connect a Linux Administration 41 . however. since maxi mum speed is not essential during installation. the Linux MS−DOS emulator. There are several ways to arrange data on a CD−ROM. and most of these programs do not run under Linux (except. so an extension to the standar d has been developed. possibly.winehq. Even better.
the two pr ocesses are often combined. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. the real formatti ng is called low−level formatting. but that is irrelevant. Formatting Formatting is the process of writing marks on the magnetic media that are used to mark tr acks and sectors. its magnetic surface is a complete mess of magnetic signals. 5. In fact.7. When the distinction needs to be made. 5. and where they are divided into sectors. T hey can also easily be made quite long. II Floor.e. Tapes A tape drive uses a tape. but benefit from low costs and large storage capacities. formatting a hard disk can cause it to work less well. W hen it is formatted. On the other hand. and can therefore contain a large amount of data. Website: www. while making the filesystem is called high−level formatting . Linux Administration 42 . similar to cassettes used for music.3. whic h means that in order to get to any given part of it. hence most people rarely need to worry about it.proximo. For IDE and some SCSI disks the formatting is actually done at the factory and doesn't nee d to be repeated. tapes are relatively cheap to make. the word formatting is used to cover also the process of creating a filesystem (which will be discussed below). Before a disk is formatted. The terminology is a bit confusing here: in MS−DOS and MS Windows. the two are called formatting and making a filesystem. A tape is serial in nature. The serial access of tapes makes them slow. There. which do not require large speeds. or via EIDE. A disk can be accessed randomly. especially for floppies. you first have to go through all the parts in between. since they do not need to be fast. some order is brought into the chaos by essentially drawing lines where the tracks go. No. The hardware h acking needed to do this is outside the scope of this book. but the type of connection decides the device fil e. The actual details are not quite exactly like this.. so that's what is used in this book as well.8. via a sound card.in CD−ROM drive to the computer: via SCSI. What is important is that a disk cannot be used unless it has been formatted. This makes tapes v ery suitable for things like archiving and backups. you can jump directly to any place on the disk. In UNIX circles. i.
For example. this approach might be a good idea if the bad spot is very large.proximo. but even then. since filesy stems can sometimes have trouble with very large bad areas.g. called bad blocks or bad sect ors. Website: www. These are sometimes handled by the drive itself.5 inch floppy in the first floppy driv e: Note that if you want to use an autodetecting device (e. Disks that need to be or can be formatted often require a special program anyway. The floppy device file to use is given as the param eter.in for example because a disk might need to be formatted in some very special way to allow automatic bad sector replacement to work.. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. one might create a small partition that covers just the bad part of the disk. Floppies are formatted with fdformat . No. II Floor. the following command would format a high density. During formatting one might encounter bad spots on the disk. if more of them develop. something n eeds to be done to avoid using those parts of the disk. because the interface to the formatting logic inside the drive is different from drive to drive. neither of these can easily be used from within Linux. or is supplied as an MS−DOS program. The formatting program is often either on the controller BIOS.3. Alternatively. The logic to do this is built into the filesystem. 3. /dev/fd0). you must set the para meters of the It is usually more convenient to choose the correct device file that matches the type of the floppy. Note that it Linux Administration 43 . how to a dd the information into the filesystem is described below.
This is invisible to the operating system. Most filesystems can avoi d such bad blocks.proximo. Website: www. reserved good block instead. Even such disks can fail. i. They maintain a list of known bad blocks. to the file /var/log/messages. these will g o to the console or. The kernel will print log messages for each I/O error it finds.. so it can be used to check even existing filesystems. fdformat won't complain. II Floor. fdformatalso validate the floppy. if you're curious if it is happening. some errors are false signals). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. check it for bad blocks.3. which is initialized when the filesystem is made. This feature should be documented i n the disk's manual. The example below checks a 3.5 badblocks outputs the block numbers of the bad blocks it finds. Many modern disks automatically notice bad blocks. and can be modified later.in is unwise to format floppies to contain more information than what they are designed for. It will try a bad block several times (you can usually hear this. The badblocks command can be used to search any disk or partition for bad blocks (includi ng a floppy). If the floppy is only marginally bad (due to dirt on the read/write head. but a real error will abort the validation process. but later checks should be done with badblocks and the new blocks should be added with fsck. We'll describe mkfs and fsck later. the drive noise changes dramatically). It does not format the disk. The initial search for bad blocks can be done by the mkfs command (which initializes the filesystem). if syslog is being used. if the number of bad bl Linux Administration 44 . fdformat itself won't tell where th e error is (one usually doesn't care. floppies are cheap enough that a bad one is automatically thrown away).e. No. and attempt to fix them by using a spe cial.
Each operating system uses its partition as it wishes and doesn 't touch the other ones. but they occupy one partition on the hard disk. and Linux Administration 45 .in ocks grows too large. you can divide Chapter 5. Floppies are not usually partitioned. boot sectors and partition table The information about how a hard disk has been partitioned is stored in its first sector (that is. but it has a special status and therefore a special name). It is only a convention that many operating systems follow. two operating systems o n it. Not all operating systems do follow it. This boot sector contains another small progra m that reads the first part of the operating system stored on that partition (assuming it is bootable). and the n starts it. Using Disks and Other Storage Media the disk into two partitions. This way the two operating systems can co−exist peacefully on the same hard disk.9. and reads the first sector of that partition. Partitions A hard disk can be divided into several partitions. or even into the BIOS. mark ed bootable). the partition's boot sector (the MBR is also a boot sec tor. and there is seldom a need to have several operating systems on one. this is the sector that the BIOS reads in and starts when the machine is first booted. II Floor. CD−ROMs are usually also not partitioned. Website: www. The partitioning scheme is not built into the hardware. the first sector of the first track on the first disk surface). The first sector is the master boot record (MBR) o f the disk.1. although chances are that by then the disk will be so rotten as to be unusable. The idea is that if you have one hard disk. The MBR.9.proximo. 5.3. since it's easier to use them as one big disk. Without partitions one would have to buy a hard disk for each operating system. The master b oot record contains a small program that reads the partition table. but they are the e xceptions. Each partition functions as if it were a se parate hard disk. 5. but since they 're so small. and want to have. partitions would be useful only very rarely. say. checks which partition is active (that is. There is no technical reason against this. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Some operating systems support partitions. No.
in use their internal partitioning method within that partition. so that if it ever corrupts you don't have to lose all your files. the Linux Administration 46 . swap space is usually best put in its own partition for Linux instead of in the main Linux partition for reasons of speed (see b elow). No. The relevant information is given by the fdisk −l command: 5. Minix. or Windows/NT. partly because some people want more than four operating systems (L inux. Using Disks and Other Storage Media To overcome this design problem. Website: www. This quickly turned out to be too little in real life. The latter type exists peacefully with other oper ating systems (including Linux). For example. (A bad partition table can be fixed with fdisk). Extended and logical partitions The original partitioning scheme for PC hard disks allowed only four partitions.3. but an operating system th at doesn't support partitions cannot co−exist on the same disk with any other operating system. OS/2.9. FreeBSD. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo. Chapter 5. and does not require any special measures. II Floor. but primarily because so metimes it is a good idea to have several partitions for one operating system. As a safety precaution.2. it is a good idea to write down the partition table on a piece of paper . MS−DOS. extended partitions were invented. NetBSD. to name a few). The primary partition thus subdivided is the extended partition . This trick allows partit ioning a primary partition into sub−partitions.
Linux doesn't care at all what it is. and the ones for extended partitions) contain one byte per partition that identifies the type of that partition. There is no standardization agency to specify what each byte value means.9. while others don't. The disk as a whole and each primary partition has a boot sector. Partition types The partition tables (the one in the MBR.. some of them use it incorrectly. the second of which is divided into two logical partitions. or what it uses it for. By using an extended partition you can now have up to 15 partitions per disk.in sub−partitions are logical partitions. here is a list of partition types as per the fdisk program. but as far as Li nux is concerned. 5. e. Figure 5−2. A sample hard disk partitioning. No.3. The purpose is to make it possible to avoid having two operating syste ms accidentally using the same partition. but are created dif ferently.g. Linux Administration 47 . The partition structure of a hard disk might look like that in Figure 5−2. e.proximo. The disk is divided i nto three primarypartitions. This attempts to identify the operating system that uses the partition. at least some versions of DR−DOS ignore the most significant bit of the byte.. in reality. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. They behave like primary partitions.3. Website: www. There is no speed difference between them. II Floor. Part of the disk is not partitioned at all.g. However. Worse. operating systems do not really care about th e partition type byte.
including the Linux one. Partitioning a hard disk There are many programs for creating and removing partitions. Linux Administration 48 .proximo. it is a very bad idea to do it.in 5. Many of the programs are called fdisk. When using IDE disks. but has a nicer (full screen) user interface. the boot partition (the partition with the bootable kernel image files ) must be completely within the first 1024 cylinders. Since this is difficult to arrange. Website: www. Most operating systems ha ve their own. you never know when a kernel update or disk defragmentation will r esult in an unbootable system. Therefore. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. This is because the disk is used via the BIOS dur ing boot (before the system goes into protected mode). Details on using the Linux fdisk given on its man page. II Floor.9. just in case it does something unu sual that the others can't.4. or variations thereof. The cfdisk command is similar to fdisk. and BIOS can't handle more than 1024 cylinders. No. make sure your boot partition is completely within the first 1024 cylinders.3. It is sometimes possible to use a boot partition that is only partly within the first 1024 cylinders. and it can be a good idea to use each operating system's own. This work s as long as all the files that are read with the BIOS are within the first 1024 cylinders.
Changing a partition's size usually requires first backing up everything you want to save fr om that partition (preferably the whole disk. Each partition should have an even number of sectors. Since changing partition sizes is painful. Consult the documentation for your distribution to see if it has a version of LI LO where LBA is supported. If the partition is growing. handle disks with more than 1024 cylinders. Make sure you have a recent backup of any important data before you try changing partitio n sizes ``on the fly''. p ut it within the first 1024 cylinders.in However. and some versions of fdisk will warn about it.3. No. If you have such a system. from CD−ROM. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. but it is ugly. The commercial partition manager ``Partition Magic'' also has a similar facility but with a nicer interface. An odd number of sectors will result in the last sector being unused. Consult the parted documentation before using it.e. two sectors. if you aren't quite sure of it. just in case). deleting the partition. since the Linux filesystems use a 1 kilobyte block size. Please do remember that partitio ning is dangerous. called fips . it is not so painful to modify partition sizes several times. If you're installing from a media that does not req uire much human intervention (say.proximo. II Floor. you may need to adjust the siz es (and backup and restore) of the adjoining partitions as well. Linux Administration 49 . but for other filesystems it is still necessary. it is preferable to get the partitions right the first ti me. creating new partition. which resizes an MS−DOS partition with out requiring the backup and restore. or have an effective and easy to use backup system. The program parted can resize other types of partitions as well as MS−DOS. this may no longer be true with newer versions of LILO that support LBA (Logical Block Addressing). you can forget about the problem. Website: www. better safe than sorry. Some newer versions of the BIOS and IDE disks can. in fact. but some times in a limited manner. as opposed to floppies). There is a program for MS−DOS. the n restoring everything to the new partition. This won't result in any problems. Since you don't already have data to back up. Chapter 5. Using Disks and Other Storage Media The fips program is included in most Linux distributions. i.. it is often easy to play with differ ent configuration at first.
The naming convention for the se files is that a partition's number is appended after the name of the whole disk. with the convention that 1 −4 are primary partitions (regardless of how many primary partitions there are) and number greater than 5 are logical partitions (regardless of within which primary partition they reside).5. it needs to be initialized.10. inode . For example. and /dev/sdb7 is the third extended partition on the second SCSI hard disk. Device files and partitions Each partition and extended partition has its own device file. directory block .proximo. Most UNIX filesystem types have a similar general structure. and the bookkeeping data structures need to be written to the disk. A few programs (including. This process is called making a filesystem. What are filesystems? A filesystem is the methods and data structures that an operating system uses to keep track of files on a disk or partition. the way the files are organized on the disk. No. Most programs operate on a filesystem. II Floor.9. although the exact details vary quite a bit. Thus. meaning the type of the filesystem. 5. Before a partition or disk can be used as a filesystem. or that one is using the ``extend ed filesystem''. that is. The word is also used to refer to a partition or disk that is used to store the files or the type of the filesystem. Website: www. if there is an existing file system there it will be destroyed or seriously corrupt ed. T he superblock contains information about the filesystem as a whole. programs that create filesystems) operate directly on the ra w sectors of a disk or partition. and indirection block.in 5. one might say ``I hav e two filesystems'' meaning one has two partitions on which one stores files. The central concepts are superblock. Filesystems 5.10.1. The difference between a disk or partition and the filesystem it contains is important. /dev/hda1 is the first primary partition on the first IDE hard disk. such as its size (the exact information here depends on Linux Administration 50 . data block.3. reasonably enough. and therefore won't work on a partition that doesn't contain one ( or that contains one of the wrong type). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.
check the manual page). xia A modified version of the minix filesystem that lifts the limits on the filenames and f ilesystem sizes. Linux share d libraries. II Floor. These dyna mically allocated blocks are indirect blocks. This special address means that no data block i s allocated for that part of the file. UNIX filesystems usually allow one to create a hole in a file (this is done with the lseek() sy stem call. A directory entry consists of a filename an d the number of the inode which represents the file.) 5. the name indicates that in order to find the data block. some Chapter 5. but no actual disk sectors are reserved for that place in the file (th is means that the file will use a bit less disk space).2. Filesystems galore Linux supports several types of filesystems. Website: www. at most 30 character filenames) and restricted in capabilities (at most 64 M B per filesystem). No. and a few other special cases. which are used to store the data in the file. and if more are needed. The difference is. together with the number of the inode. As of this writing the most important ones are: minix The oldest. more space for pointers to the data blocks is allocated dynamically. but does not otherwise introduce new features. Using Disks and Other Storage Media databases. one has t o find its number in the indirect block first. (Holes are implemented by storing a special value as the address of the data block in the indirect block or inode. The inode contains the numbers of several data blocks. ext3 The ext3 filesystem has all the features of the ext2 filesystem.in the filesystem). but quite limited in features (some ti me stamps are missing. which means that the filesystem just pretends that at a particular place in the file there is just zero bytes. except its name. but is reporte d to work very well.10. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. There is space only for a few data block numbers in the inode. there is a hole in the file. The name is stored in the directory.proximo. This happens especially often for small binaries. ergo. An inode contains all information about a file. presumed to be the most reliable. jo urnaling has been Linux Administration 51 . how ever. It is not very popular.3.
msdos Compatibility with MS−DOS (and OS/2 and Windows NT) FAT filesystems. reiserfs A more robust filesystem. or other oddities. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. p ermissions. Th is has become more popular than ext2. owners. It supports larger disk sizes than FAT. XFS was also designed to maintain high performance with large files and filesystems. for example. This improves performance and recovery time in case of a system crash. or have curious limitations. links. to make it easier to exchange files with other operating systems. Most MS Windows disks are vfat. or which have been performed. Website: www. Using Disks and Other Storage Media Linux Administration 52 . thus removing the need for a separate partition for Linux. II Floor.3. support for several foreign filesystems exists. Jo urnaling is a mechanism whereby a record is kept of transaction which are to be performed. In addition. and most people have converted to ext2. ext2 The most featureful of the native Linux filesystems. vfat This is an extension of the FAT filesystem known as FAT32. ext An older version of ext2 that wasn't upwards compatible. This allows the filesystem to reconstruct itself fairly easily after damag e caused by. These foreign filesystems work just like native ones. iso9660 Chapter 5. This allows a normal msdos filesystem to be used as if it were a L inux one. improper shutdowns. jfs JFS is a journaled filesystem designed by IBM to to work in high performance environments > xfs XFS was originally designed by Silicon Graphics to work as a 64−bit journaled filesy stem. It is designed to be easily upwar ds compatible. except that they may be lacking in some usual UNIX features. umsdos Extends the msdos filesystem driver under Linux to get long filenames. so that new versions of the filesystem code do not require re−making the existing filesy stems.proximo. No. Journaling is used which makes data loss less likely.in added. It is hardly ever used in new installations any more. and device files.
tldp. Website: www. The choice of filesystem to use depends on the situation.10. and Xenix filesystems.in The standard CD−ROM filesystem. sysv SystemV/386. II Floor. hpfs The OS/2 filesystem. NTFS The most advanced Microsoft journaled filesystem providing faster file access a nd stability over previous Microsoft filesystems.6. which is not reall y a filesystem at all. t hen it is probably wisest to use ext3.proximo. to get a listing of all processes one might use the command Linux Administration 53 . The proc filesystem makes it easy to access certain kernel data structures. see Section 5. If compatibility or other reasons make one of the non−native filesystems necessary.3. the popular Rock Ridge extension to the CD−RO M standard that allows longer file names is supported automatically. Coherent. smbfs A networks filesystem which allows sharing of a filesystem with an MS Windows computer. and is a journaled filesystem. No.org/HOWTO/Filesystems−HOWTO. You can also read the Filesystems HOWTO located at http: //www. then that one must be used. It makes these data structures look like a filesyst em. nfs A networked filesystem that allows sharing a filesystem between many comput ers to allow easy access to the files from all of them.html There is also the proc filesystem. For more information on filesystems. It is compatible with the Windows file sharing protocols. such as the process list (hence the name). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If one can choose freely. since it has all the features of ext2. even though it looks like one. usually accessible as the /proc directory. For example. and that filesystem can be manipulated with all the usual file tools.
compatibility. Currently it is probably the wisest choice.in (There will be a few extra files that don't correspond to processes. Whenever anyone tries to look at any part of the proc filesystem. no part of the proc filesystem touches any di sk. This needs to be decided on a case−by−case basis. because it is a journaled filesystem. In the event of a system crash. A filesystem that uses journaling is also called a journaled filesystem. or if your 2 year old son hits Linux Administration 54 . A journaled filesyste m maintains a log.10. (perceived) reliability. Which filesystem should be used? There is usually little point in using many different filesystems.) Note that even though it is called a filesystem. So. Depending on the overhead for bookkeeping structures. sp eed. and various other reasons. The above exam ple has been shortened. II Floor.proximo. though. or journal.3. No. 5. Website: www. of what has happened on a filesystem. even though it doesn't. it doesn't take any disk space. even though there is a m ulti−megabyte /proc/kcore file.3. Reiserfs is an other popular choice because it to is journaled. Currently. it may be advisable to use another file s ystem. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. ext3 is the most p opular filesystem. t he kernel makes it look as if the part existed somewhere. It exists only in the kernel's imagination.
Finally.10.5. The type is selected with the −t fstype option. i. There are also many programs written to add specific options when creating a specific filesy stem.6 for more details about the features of the different filesystem types. Like e verything else. with the bad block list initialized by whatever badblocks found. −c Search for bad blocks and initialize the bad block list accordingly.. To create an ext2 filesystem on a floppy.e. with the output redirected to a file. i. Website: www. Always make sure to back up your data in the event of an emergency.10. one would give the following commands: First. See Section 5. the filesystem was created. Be sure to find out if there is a specific program available for the filesystem type you want to u se. Then bad blocks were searched with badblocks. initialized. Creating a filesystem Filesystems are created. do not get a false sense of security from this.10. see the manual pages for more.e.4. −t fstype Select the type of the filesystem. with the mkfs command. No. However. Linux Administration 55 . This makes data loss much less likely and will likely becom e a standard feature in Linux filesystems. a journaled filesystem is designed to use the filesys tem's logs to recreate unsaved and lost data. bad−blocks. For example mkfs. For more information on determining what block size to use please see Section 5. II Floor. bad block checking). The programs called by mkfs have slightly different command line interfaces.3. −l filename Read the initial bad block list from the name file. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The co mmon and most important options are summarized below.in the power button like mine loves to do. the floppy was formatted (the −n option prevents validation. errors can arise.ext3 adds a −b option to allow the administrator to specify what block size s hould be used.proximo. There is actually a sep arate program for each filesystem type. 5. mkfs is just a front end that runs the appropriate program dependi ng on the desired filesystem type..
proximo.10.5. No. Website: www.3. Larger blo Linux Administration 56 . Filesystem block size The block size specifies size that the filesystem will use to read and write data. The −c option is more convenient than a separate use of badblocks. The example below does that. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. II Floor. The process to prepare filesystems on hard disks or partitions is the same as for floppie s. but badblocks is nec essary for checking after the filesystem has been created. 5. except that the formatting isn't needed.in The −c option could have been used with mkfs instead of badblocks and a separate file.
but when your filesystem contains hundreds or thousands of files. Chapter 5.in ck sizes will help improve disk I/O performance when using large files. Th erefore you would be using a "block size * max # of blocks = max block size" formula. but by the number of blocks.3. Block size can also effect the maximum supported file size on some filesystems. This happens b ecause the disk can read or write data for a longer period of time before having to search for the next block. Website: www. such as databases. it will still consume 4K of space on your harddrive. Comparing Filesystem Features FS Name FAT16 FAT32 HPFS NTFS HFS+ UFS2 ext2 ext3 ReiserFS3 ReiserFS4 XFS JFS VxFS Year Introduced 1983 1997 1988 1993 1998 2002 1993 1999 2001 2005 1994 ? 1991 Original OS MSDOS V2 Windows 95 OS/2 Windows NT Mac OS FreeBSD Linux Linux Linux Linux IRIX AIX SVR4. II Floor. if you are going to have a lot of smaller files on that filesystem. This is beca use many modern filesystem are limited not by block size or file size. if you set your block size to 4096. this can add up.0 Max File Size 4GB 4GB 4GB 16EB 8EB 512GB to 32PB 16GB to 2TB4 16GB to 2TB4 8TB8 ? 9EB 8EB 16EB Max FS Size 16MB to 8GB 8GB to 2TB 2TB 16EB ? 1YB 2TB to 32TB 2TB to 32TB 16TB ? 9EB 512TB to 4PB ? Journaling N N N Y N N N Y Y Y Y Y Y Linux Administration 57 .proximo. No. there the potential for a lot of wasted disk space. or 4K.6. On the downside. like th e /etc. 5. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. For one file that may seem trivial.10. Using Disks and Other Storage Media For example. Filesystem comparison Table 5−1. and you create a file that is 256 b ytes in size.
Figure 5−3 shows three separate filesystems.proximo. http://en. For more detailed information you can visit e_systems .3. II Floor. it has to be mounted. However. Website: www. For example.in ZFS Legend 2004 Solaris 10 1YB 16EB N Table 5−2. as in Figure 5−4.10. respectively. When the lasttwo filesystems are mounted below /home and /usr. we can get a single directory tree. Mounting and unmounting Before one can use a filesystem. the filesystem software has bee n written with these capabilities. There is a current estimate that the worlds printed material is equal to 5 Exabytes. Sizes Kilobyte − KB Megabyte − MB Gigabyte − GB Terabyte − TB Petabyte − PB Exabyte − EB Zettabyte − ZB Yottabyte − YB 1024 Bytes 1024 KBs 1024 MBs 1024 GBs 1024 TBs 1024 PBs 1024 EBs 1024 ZBs It should be noted that Exabytes. Using Disks and Other Storage Media limitations are considered by many as theoretical. Therefore. and Yottabytes are rarely encountered.7. on the first filesystem. if eve r. the mount operation will make it look like the contents of the new filesystem are the contents of an exi sting subdirectory in some already mounted filesystem. some of these filesystem Chapter 5. Zettabytes. each with their own root direct ory. No. The operating system then does vari ous bookkeeping things to make sure that everything works. Since all files in UNIX are in a single directory tr ee. 5.wikipedia. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.org/wiki/Comparison_of_fil Linux Administration 58 .
Chapter 5. /home and /usr have been mounted. II Floor. /dev/hda2. Three separate filesystems.proximo. The second one is the directory below which it will be m ounted. One would then say that /dev/hda2 is mounted on /home''.3. since the heuristic Linux Administration 59 .in Figure 5−3. Website: www. You can also use the −t fstype option to specify the type directly. After these commands the contents of the two filesystems look just like the contents of the /ho me and /usr directories. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. /home. the mounted−on directory gives access to the files on the disk. Note the difference between the device file. The mounted−on directory is c alled the mount point. The device file gives access to the raw contents of the disk. and the mounted−on directory. Using Disks and Other Storage Media Linux supports many filesystem types. mount tries to guess the type of the filesystem. Figure 5−4. and similarly for /usr. just as if it were any other directory. this is sometimes necessary. respectively. No. one would look at the contents of the directory on which it has been mounted. The mounts could be done as in the following example: The mount command takes two arguments. The first one is the device file corresponding t o the disk or partition containing the filesystem. To look at either filesystem.
) There is no harm done with this. will be inaccessible by name while the filesystem is mounted. If /var/tmp didn't exist on the root filesystem. you could use the following command: The mounted−on directory need not be empty. This will make the kernel stop any attempts at writing to the filesystem.3. For instance. II Floor. If you don't intend to write anything to the filesystem. because it contains the root directory) mounted. although it must exist.in s mount uses do not always work. and will also stop t he kernel from updating file access times in the inodes. Read−only mounts are necessary for unwritable m edia. No. The root filesystem is usually first mounted read−only. to mount an MS−DOS floppy. a /var/tmp directory residing on the root filesystem is used instead. some people like to have /tmp and /var/tmp synonymous. it would be impossible to use temporary files before mounting /var. it will make the /var/tmp directory on the root filesystem inaccessible. Any files in it. When /var is mounted. The startup scripts will then run fsc Linux Administration 60 . or set using LILO or rdev. Website: www. and one can rely on it to always be mounted.g. the system does not boot. For example. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. and it can even be useful. CD−ROMs. The alert reader has already noticed a slight logistical problem. If the root filesystem can't be mounted.proximo. How is the first filesystem (c alled the root filesystem. Files that have hard links from other directories can be accessed using those na mes. be fore the /var filesystem is mounted. the answer is that it is done by magic. The root filesystem is magically mo unted at boot time. howev er. (Any files that have already been ope ned will still be accessible. For more information.. since it obviously can't be moun ted on another filesystem? Well. When the system is booted. use the −r switch for mount to do a read−only mount. see the kernel source or the Kernel Hackers' Guide. and make /tmp be a symbolic link to /var/tmp. The name of the filesystem that is magically mounted as root is either compiled into t he kernel. e.
but is the easiest solution. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. which is the case on many non−networked. see the fstab man page for details on the format. a Trojan horse disguised as /bin/sh. this is not very likel y. per Linux Administration 61 . Don't just pop the floppy out of the drive! Because of disk cachi ng.. Since the root filesystem is mounted read−only while it is being checked. or any other often used program. it can be unmounted with umount. On many systems there are other filesystems that should also be mounted automatically at boot time. and if there are no problems. to unmount the directo ries of the previous example. II Floor. then it is rather easy to create a floppy with. since any changes to the filesystem while fsck is running will cause trouble. so removing the floppy from the drive too early might cause the contents to become garbled. The reaso n for this is that if any user can mount a floppy on any directory. It works well if there is no need for security anyway. but if you write. one could use the commands See the man page for further instructions on how to use the command.3.e. No.proximo. fsck can fix any problems without worry. say. These are specified in the /etc/fstab file. This is obviously bad security. only root can do it. see Chapter 8. When a filesystem no longer needs to be mounted. Mounting and unmounting requires super user privileges. However. If you only read from the floppy. • Give the users the root password. they will re−mount it so that writes will also be allow ed.in k to verify its validity. even accidentally. The det ails of exactly when the extra filesystems are mounted depend on many factors. It is imperative that you always unmount a mounted floppy. For example. fsck must not be run on a mounted filesystem. Website: www. since the remount operation will flush any metadata that the filesystem keeps in me mory. the data is not necessarily written to the floppy until you unmount it. and can be configured by each administrator if need be. i. and there are several ways to do this: . it is often necessary to allo w users to use floppies. the result may be catastrophic. u mount takes one argument: either the device file or the mount point.
The user option allows any user to mount the filesystem. options. It requires several seconds of hard thinking on the u sers' behalf. of course) be unmounted with the corresponding umount co mmand. sudoers(5). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If you want to provide access to several types of floppies. • Make the users use mtools.. directory to mount on.in sonal systems. you could have the following to lines in /etc/fstab: Linux Administration 62 . e. to give access to both MS−DOS and ext 2 floppies. it stops mount −a from mounting it). The settings can be different for each mount point. a package for manipulating MS−DOS filesystems. No. you need to give several mount p oints. .proximo. disallows execution of programs (normal or setuid) and interpretation of device file s from the mounted filesystem. The noauto option stops this mount to be done automatically when the system is started (i. This is still bad security. After this. • List the floppy devices and their allowable mount points together with the suitable options in /etc/fstab. any user can mount a floppy with an msdos filesystem with t he following command: The floppy can (and needs to. • Use a program such as sudo to allow users to use mount. backup frequency (used by dump). filesystem type. This works well if MS−DOS floppies are all that is needed. Website: www. See the sudo(8). . but is rather awkward othe rwise. For example.3. 0 means no check). The last alternative can be implemented by adding a line like the following to the /etc/fstab file: The columns are: device file to mount. II Floor. and fsck pass number (to specify the order in which filesystems shoul d be checked upon boot. without mou nting them. and. Furthermore sudo can be configured to only allow users to execute certain comman ds. . becaus e of security reasons. and visudo(8) manual pages. but does n't directly give super user privileges to everyone.
mounting an MS−DOS filesystem gives everyone at least read access to the files in it. and as such. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.10. and to alert the user if there any unrepairable problems. and since errors almost neve r occur if the Linux Administration 63 . they tend to be somewhat error−prone. for example. Filesystem Security TO BE ADDED This section will describe mount options and how to use them in /etc/fstab to provide additi onal system security. and they are usually caused by power failures.9. described in detail on the mount manual page. which is not a g ood idea. This option won't work on all filesystem types. Website: www. but works fin e on the more common ones. Checking filesystem integrity with fsck Filesystems are complex creatures. II Floor. failing hardware. by not shutting down t he system properly. No.proximo. resul ting in more data loss. the code to implement filesystems is debugged quite effectively. you probably want to restrict access to it by usi ng the uid. fsck can take a while to run on big filesystems. gid. 5.10. and umask filesystem options. For MS−DOS filesystems (not just floppies). so there are seldom any problems at all. Use of a corrupted filesystem tends to make things wo rse: if the data structures are messed up.in The "auto" option in the filesystem type column allows the mount command to query the file system and try to determine what type it is itself.3. Most systems are setup to run fsck automatically at boot time. It can be instructed to re pair any minor problems it finds. using the filesystem will probably mess them up even more. Fortunately. If you aren't careful. so that any errors are detect ed (and hopefully corrected) before the system is used. or operator errors. A f ilesystem's correctness and validity can be checked using the fsck command.8. However. 5.
The debugfs progra m by Theodore Ts'o should be useful. If fsck finds unrepairable problems. This allows e2fsck (the version of fsck for the ext2 filesystem) to avoid checking th e filesystem if the flag indicates that the unmount was done (the assumption being that a proper unmount indi cates no problems). if you don't have the know−how yourself. The first is that if the file /etc/fastboot exists. the former can sometimes be arranged via a friend.3. This is because it accesses the raw disk. (See the e2fsck man page for details on how.. if the operating s ystem is confused. The following example will show how this could be done.10. 5. The second is that the ext2 fi lesystem has a special marker in its superblock that tells whether the filesystem was unmounted properly after the previous mount. This list can be fed to fsck to be r ecorded in the filesystem data structures so that the operating system won't try to use the bad blocks for s toring data. Linux Administration 64 . This is done with the badblocks c ommand. Use fsck manually to check other filesystems. a couple of tricks are used to avoid doing the checks i n such cases. It outputs a list of the numbers of all bad blocks it can find. e. There will be trouble. or good backups.proximo. but t he ext2 trick works every time you use e2fsck. and the type of the corrupt filesystem in particular. I'd like to t ell you more about it. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. and can therefore modify the filesystem without the operating system realizing it. fsck must only be run on unmounted filesystems. you need either in−depth knowledge of how filesystems work in general. never on mounted filesystems (with the e xception of the read−only root during startup). floppies.) The automatic checking only works for the filesystems that are mounted automatically at b oot time. Whether the /etc/fastboot trick works on your system depends on your startup scripts.g.in system has been shut down properly. but my lack of education and experience in this regard hinders me. II Floor. Checking for disk errors with badblocks It can be a good idea to periodically check for bad blocks. No. It has to be explicitly bypassed with an option to e2fsck to be avoided. no checks are made. Website: www. the Linux newsgrou ps and mailing lists. or some other source of support.10. The latter is easy (alth ough sometimes tedious) to arrange.
3.go. Some filesystems. Therefore it is not necessary to worry about fragmen tation in a Linux system. Website: www. A copy of it can still be download ed at http://www. Fighting fragmentation? When a file is written to disk.73. like ext3. and has not bee updated since 1998! I only mention it here for references purposes. there was a concern over file fragmentation that l ead to the development of a defragmentation program called. There are many MS−DOS defragmentation programs that move blocks around in the filesyst em to remove fragmentation. even if they can't be stored in consecutive sectors.in If badblocks reports a block that was already used. It was designed for and older ver sion of ext2. the contents of the file may be corrupted. For other filesystems. In the earlier days of the ext2 filesystem. A file that i s not stored in consecutive blocks is fragmented. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.de/linux/src/defrag−0. It is desirable to avoid fragmentation. not just marginal. 5. No.tar. If the block was really bad.11. re−creating Linux Administration 65 . it is HIGHLY recommended that you NOT useit. It takes longer to read a fragmented file. defrag.gz . although it is less of a pro blem in a system with a good buffer cache with read−ahead. Modern Linux filesystem keep fragmentation at a minimum by keeping all blocks in a file clo se together. II Floor. However.proximo. it can't always be written in consecutive blocks.dlr. effectively allocat e the free block that is nearest to other blocks in a file.10. defragmentation must be done by backing up the files ystem. e2fsck will try to move the block to ano ther place. since the disk 's read−write head will have to move more.
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
it, and restoring the files from backups. Backing up a filesystem before defragmenting is a g ood idea for all filesystems, since many things can go wrong during the defragmentation. 5.10.12. Other tools for all filesystems Some other tools are also useful for managing filesystems. df shows the free disk space o n one or more filesystems; du shows how much disk space a directory and all its files contain. These ca n be used to hunt down disk space wasters. Both have manual pages which detail the (many) options which can be used. sync forces all unwritten blocks in the buffer cache (see Section 6.6) to be written to disk. I t is seldom necessary to do this by hand; the daemon process update does this automatically. It can b e useful in catastrophes, for example if update or its helper process bdflush dies, or if you must turn off power now and can't wait for update to run. Again, there are manual pages. The man is your very best frie nd in Linux. Its cousin apropos is also very useful when you don't know what the name of the command yo u want is. 5.10.13. Other tools for the ext2/ext3 filesystem In addition to the filesystem creator (mke2fs) and checker (e2fsck) accessible directly o r via the filesystem type independent front ends, the ext2 filesystem has some additional tools that can be us eful. tune2fs adjusts filesystem parameters. Some of the more interesting parameters are: . • A maximal mount count. e2fsck enforces a check when filesystem has been mounted too m any times, even if the clean flag is set. For a system that is used for developing or testing the system, i t might be a good idea to reduce this limit. . • A maximal time between checks. e2fsck can also enforce a maximal time between two chec ks, even if the clean flag is set, and the filesystem hasn't been mounted very often. This can be disable d, however. . • Number of blocks reserved for root. Ext2 reserves some blocks for root so that if the filesyst em fills up, it is still possible to do system administration without having to delete anything. The res erved
Linux Administration 66
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
amount is by default 5 percent, which on most disks isn't enough to be wasteful. However, f or floppies there is no point in reserving any blocks. See the tune2fs manual page for more information. dumpe2fs shows information about an ext2 or ext3 filesystem, mostly from the super block. Below is a sample output. Some of the information in the output is technical and requires underst anding of how the filesystem works, but much of it is readily understandable even for lay−admins.
Linux Administration 67
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
debugfs is a filesystem debugger. It allows direct access to the filesystem data structures s tored on disk and can thus be used to repair a disk that is so broken that fsck can't fix it automatically. It has also been known to be used to recover deleted files. However, debugfs very much requires that you understan d what you're doing; a failure to understand can destroy all your data. dump and restore can be used to back up an ext2 filesystem. They are ext2 specific versio ns of the traditional UNIX backup tools. See Section 12.1 for more information on backups. 5.11. Disks without filesystems Not all disks or partitions are used as filesystems. A swap partition, for example, will not ha ve a filesystem on it. Many floppies are used in a tape−drive emulating fashion, so that a tar (tape archive) or other file is written directly on the raw disk, without a filesystem. Linux boot floppies don't contain a filesystem, only the raw kernel. Avoiding a filesystem has the advantage of making more of the disk usable, since a filesyst
Linux Administration 68
if the disk c ontains a partially damaged filesystem. There are many factors that must be taken into account depending on the purpose of the machine. The traditional way is to have a (relatively) small root filesystem. Bootable Linux floppies also do not necessarily have a filesystem. Allocating disk space 5. there is no universally correct way to do it . One way to do this is to use dd: Chapter 5. since then you can start again if your fixing breaks things even more. For a simple workstation with limited disk space. although they may. It also makes the disks more easily compatible with other sy stems: for example. the tar file format is the same on all systems. while filesystems are different on most syste ms. II Floor. One reason to use raw disks is to make image copies of them.3. Using Disks and Other Storage Media The first dd makes an exact image of the floppy to the file floppy−image. such as a laptop. A partition for /. Website: www. for most users this is not a recommended sol ution. it is a good idea to make an exact copy of it before trying to fix it. you may have as few a 3 partitions. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. You will quickly get used to disks without filesystems if you need them. and swap. O therwise the command pair is of doubtful usefulness.proximo.in em always has some bookkeeping overhead. No.1.12. For instance. Partitioning schemes When it comes to partitioning your machine. However. and separate partitions for filesystems such Linux Administration 69 .) 5. the second one wr ites the image to the floppy.12. (The user has presumably switched the floppy before the second command. /boot.
and therefore make it easier to recover a crashed system. The reason is to prevent having the root filesystem get filled and cause a system cr ash. One way to avoid this problem is to use to create Logical Volumes. or Physical Extents Volu me Group. Then the P hysical Partitions are added to a Volume Group and broken up into chunks. Not creating separate pa rtitions for these filesystems puts you at risk of having log file fill up our / partition. T he contents of these directories are required at bootup and must always be part of the / par tition. it is less likely to become corrupt when the system crashes. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. 5. Website: www. and excell Linux Administration 70 .in as /usr and /home>.12. II Floor. This i s because both directories typically have data that is constantly changing.3. /etc. Logical Volume Manager (LVM) Using LVM allows administrators the flexibility to create logical disks that can be expanded dynamically as more disk space is required. This is done first by creating partitions with as an 0x8e Linux LVM partition type. a full discussion of LVM is beyond the scope of this guide. You cannot create separate partitions for the following directories: /bin. These Logical Volumes then can be form atted just like a physical partition. No. and /sbin. Creating a separate root filesystem if the root filesystem is small and n ot heavily used. /initrd.proximo. /dev. /lib. It is also recommended that you create separate partitions for /var and /tmp. However. When creating your partitioning scheme. there are some things you need to remember. An example of a server partition is: The problem with having many partitions is that it splits the total amount of free disk space into many small pieces. These extends can then be grouped into Logical Volumes. Right now.2. The big difference is that they can be expanded by adding more extents t o them.
) Next.3. a 345 MB hard disk is really a 330 MB hard disk. By the way.4. when comparing file sizes given in kilobytes or megabytes and disk space give n in megabytes. but the amount they will live happily with varies a lot.org/HOWTO/LVM−HOWTO. while all the rest of the computin g world uses 1024 for both factors. it can be important to know that the two units can be different.5. I created a separate /boot partition to ensure that this filesystem will never get f illed up. Then I created a 5 GB /var partition. Website: www. Examples of hard disk allocation I used to have a 10 GB hard disk. This will help you plan your disk space usage. Some people do only light text processing and will survive nicely with a few megabytes. I created a /boot partition at 128 MG. Swap space allocation is discussed in Section 6. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.tldp. Most people see m to need as much space for their files as possible. II Floor. Since the /var filesystem is where log files and email is stored I wanted to isolate it from my root partition. Programs installed separately may also do the same. I created a 15 GB /home partition. This is handy in th e event of a Linux Administration 71 . and therefore will be bootable.in ent resource for learning more about LVM can be found at http://www. 5. The amount you need for user files depends on what your users wish to do. I'll explain how and why I partitioned those disks.3. Now I am using a 30 GB hard disk. Therefore. Some disk manufacturers lik e to pretend that a kilobyte is 1000 bytes and a megabyte is 1000 kilobytes. First. This is larger than I will need. and big enough t o give me space if I need it.ht ml . Space requirements The Linux distribution you install will give some indication of how much disk space you nee d for various configurations.proximo. (I have had log files grow o vernight and fill my root filesystem in the past. but you should prepare for the future and reserve some extra space for things you will notice later that you need. others do heavy image pr ocessing and will need gigabytes. No.12. 5.12.
at least after the hardware has been properly inst alled (the hardware installation is outside the scope of this book). I created an 8 GB /usr partition and left 2 GB unused. then crea te the partitions and filesystem as described above. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If I ever have to re−install Linux from scratch. I can tell the installation progr am to not format this partition. My Partitions 9 GB 1 GB 5 GB 15 GB 8 GB 2 GB root filesystem swap partition /var filesystem /home filesystem /usr filesystem scratch partition 5. and by analyzing your needs you might notice that you don't need most of them. This is incase I need more space in the future. Using Disks and Other Storage Media Table 5−3.5. some of the fonts for X11. In the end. Linux Administration 72 . I usin g my old 10 GB hard drive. since many programs a re quite large. and add the proper lines to /etc/fstab so that it is mount ed automatically. Tips for saving disk space The best tip for saving disk space is to avoid installing unnecessary programs. No. my partition tables looked like this: Chapter 5. Most Linux di stributions have an option to install only part of the packages they contain.6. Website: www.proximo. For exam ple. Finally since I had 512 MG of RAM I created a 1024 MG (or 1 GB) swap partition. Even if you do need a particular package or program. or some of the libraries for programming. This will help save a lot of disk space. II Floor.12.3. you might not need all of it. as might some of the Elisp files for GNU Emacs. 5. and instead remount it without the data being lost.12. Adding more disk space for Linux Adding more disk space for Linux is easy. You format it if necessary. some on−line documentation might be unnecessary. This left me with roughly a 9 GB root filesystem.in system crash.
they are read back into memory. This happens because the disk can read or write data for a longer period of time before having t o search for the next block. Larger block sizes will help disk I/O performance when using large files.1. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.3. When the ori ginal contents are needed again. then uncom pressed as they are used)..proximo. i. invisibly to t he programs that use them. The purpose and workings and the things the system administrator needs to take into consi deration are described. Compression programs such as gzip or zip will compress (and uncompress) individual files or groups of files. Website: www. Memory Management "Minnet. No. The block size is chunk size that the filesystem will use to read and write data. Am I Swedish or Finnish? I can't remember'' This section describes the Linux memory management features. är jag svensk eller finne. the principle is the same. Most mo dern filesystems will allow you to specify the block size.e. you might look into compression." (Bosse Österberg) A Swedish drinking song. I have lost my memory.. jag har tappat mitt minne.) Another way to save space is to take special care when formatting you partitions. that is. The kernel will write the contents of a currently unu sed block of memory to the hard disk so that the memory can be used for another purpose. 6. The experimental DouBle system will compress all files in a filesystem. virtual memory and th e disk buffer cache. kommer int e ihåg. using a disk as an extension of RAM so that the effec tive size of usable memory grows correspondingly. The gzexe system w ill compress and uncompress programs invisibly to the user (unused programs are compressed. such as databases. The Chapter 6. What is virtual memory? Linux supports virtual memory. This is all made completely transparent to t he user. (rough) translation: ``Memory.in If you cannot uninstall packages. II Floor.. programs running under Linux only see the larger amount of memory available and don't notice that p arts of them reside Linux Administration 73 . (If you are familiar with products such as Stacker for MS−DOS or DriveSpace fo r Windows.
reading and writing the hard disk is slower (on the order of a thousand times slower) than using real memory. A note on operating system terminology: computer science usually distinguishes between swapping (writing the whole process out to swap space) and paging (writing only fixed size parts. and that's what Linux does.2. at a time). it can't reside in a filesystem that has been mounted over NFS due to implementation reason s. so the programs don't run as fast. When you know how much swap space you need. It must reside on a local disk. and possibly install everything from scratch). No.in on the disk from time to time. Of course. you should go for a swap partition.proximo. A swap partition is faster. Chapter 6. You should also know that Linux allows one to use several swap partitions and/or swap files at the same time. instead of keeping the whole amount allocated all the time. The swap file reserves the disk space so that the kernel c an quickly swap out a page without having to go through all the things that are necessary when allocating a dis k sector to a file. but if you are uncertain. you can se t up an extra swap file at such times. but traditional Linux te rminology talks about swapping anyway. The only thing that matt ers to the kernel is that it has no holes. it is in no way special to the kernel. The bit about holes is important. and then make a swap partition when you're co nfident about its size. and that it is prepared for use with mkswap. usually a f ew kilobytes. you can use a swap file first.3. This means that if you only occasionally need an unusual amount of swap space. 6. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. but it is easier to change the size of a swap file (there's no need to repartition the wh ole hard disk. Linux can use either a normal file in the filesystem or a separate partition for swap space. Memory Management Linux Administration 74 . II Floor. The part of the hard disk that is used as virtual memory is called the swap space. Paging is usually more efficient. however. Creating a swap space A swap file is an ordinary file. use the system for a while so that you can get a feel for how much swap you need.
proximo. One good way to create the swap file without holes is through the following command: where /extra−swap is the name of the swap file and the size of is given after the count=. A swap partition is also not special in any way. because the kernel writes out memory pages. use up to 8 swap spaces simultaneously. since it does not check that the file or part ition isn't used for anything else. this will the make partition listings clearer. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. No. that is. it is not good for the kern el to try to use them. II Floor. It is a go od idea to mark swap partitions as type 82 (Linux swap). It is best for the size to be a multiple of 4. even t hough it is not strictly necessary to the kernel. Website: www. You can. the last couple of kilobytes may be unused. it will not contain any filesystem at all. The command to do thi s is mkswap. You can easily overwrite important files and partitions with mkswap! Fortuna tely. You should be very careful when using mkswap. which are 4 kilobyte s in size. After you have created a swap file or a swap partition. If the size is not a multiple of 4. The Linux memory manager limits the size of each swap space to 2 GB. t he only difference is that it is used as a raw partition. this contains some administrative information and is used by the kernel. you should only need to use mkswap when you install your system.3. You create it just like any other partition. but the kernel does not use i t to provide virtual memory. however. you need to write a signature to its b eginning. Linux Administration 75 . used like this: Note that the swap space is still not in use yet: it exists. Because a h ole in a file means that there are no disk sectors allocated (for that place in the file).in The kernel merely uses any sectors that have already been allocated to the file. for a total of 16GB.
the swapon command is usually used only when extra swap is n eeded. That last line (Swap:) shows similar information for the swap spaces. It will tell the total amount of swap spac e used. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo. The same information is available via top. Any pages in use in the swap space are swapped in first. The total column does not sh ow the physical memory used by the kernel.3. This command tells the kernel that the swap space can be used. e xcept for temporary swap spaces. The used column shows the amount of memory used (the second line does not count buffers). Using a swap space An initialized swap space is taken into use with swapon.in 6. Therefore. or using the proc filesystem in file /proc/ meminfo. If this line is all z eroes. if there is not sufficie Linux Administration 76 .3. A swap space can be removed from use with swapoff. The buffers column shows the current size of the disk buffer cache. your swap space is not activated. The shared column shows the amount of memory shared by several processes. which is usually about a megabyte. The first line of output (Mem:) shows the physical memory. the merrier. It is currently difficult to get information on the use of a specific swap space. Website: www. II Floor. You can monitor the use of swap spaces with free. No. The path to the swap space is given as the argument. It is usually not necessary to do it. the more. The startup scripts will run the command swapon −a. which will start swapping on all the s wap spaces listed in /etc/fstab. The free column shows completel y unused memory. so to start swapping on a temporary swap file one might use the following command.
100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Sometimes a lot of swap space can be in use even though there is a lot of free physical m emory. but it can be comforting to know what is happening. that is the sum of the memory requirements of all the programs you want to ru n at the same time. but later a big process that occ upied much of the physical memory terminates and frees the memory. The swapped−out data is not autom atically swapped in until it is needed. Any manually used swap spaces will rema in in use. gcc wants Linux Administration 77 .. No.in nt physical memory to hold them.. Here's how to do it properly: • Estimate your total memory needs. 6. There is no n eed to worry about this. It would be more efficient for them to share a single swap space.proximo. i. All the swap spaces that are used automatically with swapon −a can be removed from use with swapoff −a. You should check (e. you should allocate about 8 MB for it.5.4. never at the same time.html . The Tips−HOWTO at http://www.e. For instance. but meanwhile the system is unusable. Since they each need it only when the y are running. This can happen for instance if at one point there is need to swap. which contains some advice on how toimplement this. it looks at the file /etc/fstab to find what to remove. after a long while it should recove r.g. If there i s not enough virtual memory to hold all of the pages Linux will start to thrash. if you want to run X. but can require a bit o f hacking. they will then be swapped out (to some other swap space).3. Allocating swap space Some people will tell you that you should allocate twice as much swap space as you have physical memory. Website: www. 6.tldp. with free) that there is enough free memor y before removing a swap space from use. so the physical memory may remain free for a long time. This is possible. This can be done by running at the same time all the programs you are likely t o ever be running at the same time. II Floor. This is the largest amount of memory you'll prob ably need at a time. Sharing swap spaces with other operating systems Virtual memory is built into many operating systems. but this is a bogus rule. the swap spaces of all but the currently running one are being wast ed.org/HOWTO/Tips−HOWTO.
. and the usual shells and other small utilities perhaps a few hundred kilobytes (say a megabyte together). since code pages and shared libraries e xist only once.) Also. • Add some security to the estimate in step 1. A couple of megabytes should be fine. you know how much memory you'll be needing in total. because you'll probably forget some programs you want to run. (It is better t o allocate too much than too little swap space. The kernel will use about a megabyte by itself. but there's no need to over−do it and allocate the whol e disk. so that as much physical memory as possible can Linux Administration 78 . However. rough estimates are fine. Website: www. So. but you might want to be on the pessimi stic side. you should probably invest in more physical memory.in several megabytes (some files need an unusually large amount. since it is nicer to deal with even numbers. and so on. you need to allocate space for an image of the physical memory as well. but usually about four should do). No. so the amount compute d in step 2 is what you need and you shouldn't do the subtraction.3. up to tens of megabytes. (On some versions of UNI X. The free and ps commands are useful for estimating the memory needs. • If your calculated swap space is very much larger than your physical memory (more than a couple times larger). see later about adding more swap. . T here is no need to try to be exact. since unused swap space is wasted space. otherwise performance will be too low. and you know how much swap space you need. It's a good idea to have at least some swap space. and to make cert ain that you have some extra space just in case. they are all going to consume memory. even if your calculations indicate that yo u need none.proximo. Linux uses swap space somewhat aggressively. you can round the value up to the next full megabyte. if two people run the same program at the sa me time. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.) . Remember that if there are going to be several people using the system at the sam e time. in order to allocate swap space. the total memory consumption is usually not double. you just need to subtract the size of your physical memory fro m the total memory needed. This is because estimates of program sizes will probably be wrong. • Based on the computations above. II Floor.
g. then read the letter into an editor when replying to it. The buffer cache Reading from a disk is very slow compared to accessing (real) memory. Swap space can be divided among several disks. the data that has been unused for the longest time is discarded and the memory thus freed is used for the new data. then make the mai l program read it again when copying it to a folder. This is called disk buffering. On the one hand.in be kept free. This can sometimes improve performance. You should not believe claims that any one scheme is superior to any other. Some are write−through: the data is written to disk Linux Administration 79 . 6. For example. Disk buffering works for writes as well. unfortunately.proximo. Website: www. the buffer cache usually can not be big enough (it can't hold all the data one ever wants to use). When the cache fills up. and the memo ry used for the purpose is called the buffer cache. without slowing down the other programs. II Floor. On the other hand. when the disk is otherwise idle. not writing it to disk at once. the program that writes runs quicker. This avoids waiting for swapping when it is needed: the swapping can be done earlier. Since memory is. scarce resource.3. a finite. Linux will swap out memory pages that have not been used. but not all of them work according to the above principles. Most operating systems have buffer caches (although they might be called something else). data that is written is often soon read again (e. By reading the information from disk only once and then keeping it in memor y until no longer needed. so putting data that is writte n in the cache is a good idea. Or. nay.6. by only putting the data into the cache. one might first read an e−mail message. consider how often the command ls might be run on a system with many users. You might want to experim ent with a few schemes. then read by the compiler). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. but be aware that doing the experiments properly is quite difficult. The writes can then be done in the background.. one can speed up all but the first read. No. even if the memory is not yet needed for anything. since it won't always be true. a source code file is saved to a file. In addition. it is co mmon to read the same part of a disk several times during relatively short periods of time. depending on the relative speeds of the disks and the access patterns of the disks.
which does a more imperfect sync more frequently to avoid t he sudden freeze due to heavy disk I/O that sync sometimes causes. which are the smallest units of disk I/O (under Linux. Linux has an additional daemon.e. and how often the same data is accessed. In traditional UNIX systems. Write−back is more efficient than write−through. they are usually 1 KB). A small cache is next to usele ss: it will hold so little data that all cached data is flushed from the cache before it is reused. There is usually no reason to worry about it. and non−filesystem disks are cached. This way. or the floppy is removed from the disk drive before th e data in the cache waiting to be written gets written. The only way to know is to experiment. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. of course). II Floor. The cache is called write−back if the writes are done at a la ter time. forces all unwritten data to be written to disk. Website: www. The syn c command flushes the buffer.. Under Linux. because that mig ht make the free Linux Administration 80 . super blocks. but also a bit more prone to errors: if the machine crashes. also directories. This might eve n mean that the filesystem (if there is one) is not in full working order. but blocks. Because of this. the changes in the cache are usually lost. The cache does not actually buffer files. and can be used when one w ants to be sure that everything is safely written. it is not very good to have it too big. perhaps because the unwritten data held important changes to the bookkeeping information. i. the kernel will warn about this. either. so it is usually not necessary to use syn c. but if bdflush happens to die for some reason. No. and you should start it by hand (/sbin/update).in at once (it is kept in the cache as well. or the power is cut at a bad moment.3. you should never turn off the power without using a proper shutdown proc edure or remove a floppy from the disk drive until it has been unmounted (if it was mounted) or after whatev er program is using it has signaled that it is finished and the floppy drive light doesn't shine anymore. The effectiveness of a cache is primarily decided by its size. bdflush.proximo. The critical siz e depends on how much data is read and written. If the cache is of a fixed size. there is a program called update running in the background which does a sync every 30 seconds. bdflush is started by update. other filesystem bookke eping data.
or by servic es your system may host such as email or web pages. you do not need to do anything to make use of the cache. The ability to know what is happening can help determine whether system upgrades are needed. If system resources beco me to low it can cause a lot of problems. 7.1. The top will display a continually updating re port of system resource usage. This chapter will cover how to monitor your system. or if some services need to be moved to another machine. The ability to determine where the bottleneck is can save you a lot of time. System Resources Being able to monitor the performance of your system is essential.in memory too small and cause swapping (which is also slow).3. but also automatically makes the cac he smaller when programs need more memory. Website: www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. is monitoring their sy stems. Except for following the proper procedures for shutdown and removing floppies. System resources can be taken up by individual users. 7. what commands are bein g run. To make the most efficient use of real memory. The top command. Under Linux. No. how to r esolve problems that may arise. it happens complet ely automatically. II Floor.1. Chapter 7. The most common of these commands is top. Whether it's the percentage of system's resources currently used. System Monitoring "That's Hall Monitor to you!"Spongebob Squarepants One of the most important responsibilities a system administrator has. When a performance issue arises. Linux Administration 81 .proximo. Memory. there are 4 main areas to consider: CPU. Disk I/ O.1. and Network. As a system administrator you'll need the ability to find out what is happening on your system at any given time. you do not need to worry about it. and in some cases. Linux automatically uses all free RAM for buffer cache. or who is logged on.
in The top portion of the report lists information such as the system time. uptime. k to kill processes. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. You can modify the output of top while is is running. Below that is a list of the processes sorted by CP U utilization. Hit i again to see them again. and r to renice them. physical ans swap memory usage. CPU usage. No. you can also modify processes from within the top comman d. S will sort by how long they processes have been running. You can use u to view processes owned by a specific user.3. and number of processes. If you hit an i.proximo. top will no longer disp lay idle processes. These directories ar e associated with Linux Administration 82 . Hitting M will sort by memory usage. In addition to viewing options. For more in−depth information about processes you can look in the /proc filesystem. Website: www. II Floor. and P will sort by CPU usage again. In the /proc filesystem you will find a series of sub−directories with numeric names.
the following is only a partial output.in the processes ids of currently running processes. DOING SO MAY CAUS E SYSTEM PROBLEMS! 7.1. For 2. To do this you would use the ps −ef command. YOU MUST TAKE EXTREME CAUTION TO NOT MODIFY THESE FILES. This is a grea t command to monitor your disk I/O usage.3. 7.4 kernels the devices is names using the device's major and minor number. (Screen output from this command is too large to include. A common use would be to list all processes currently running. No. In each directory you will find a series of fi les containing information about the process. The ps command The ps will provide you a list of processes currently running. Website: www.proximo. II Floor. The iostat command. There is a wide variety of o ptions that this command gives you.3. In this cas e the device listed The iostat man page contains a detailed explanation of what each of these columns mean.2. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The iostat will display the current CPU load average and disk I/O information.1.) Linux Administration 83 .
memor Linux Administration 84 . This is the process that generated.in The first column shows who owns the process. II Floor.3. or started. The Thi rd column is the parent process ID. With this information you can see exacly what is running on your system and kill run−a way processes. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. 7. if applicable. The eighth column is the comm and itself. of date if the process has been runnin g long enough. The sixth column is the tty associated with the process.proximo. The seventh column is the cumulitive CPU usage (total amount of CPU time is has used while running). No. Website: www.4. or those that are causing problems. The fifth column is the start time.1. The vmstat command The vmstat command will provide a report showing statistics for system processes. the process. The second column is the process ID. The forth colu mn is the CPU usage (in percent).
Linux Administration 85 .in y. cs: The number of context switches per second. I/O. and the CPU. Swap si: Amount of memory swapped in from disk (kB/s). 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. CPU These are percentages of total CPU time. so: Amount of memory swapped to disk (kB/s). buff: the amount of memory used as buffers (kB). FIELD DESCRIPTIONS Procs r: The number of processes waiting for run time. but Linux never desperation swaps. free: the amount of idle memory (kB). b: The number of processes in uninterruptable sleep. II Floor. No. bo: Blocks received from a block device (blocks/s).proximo. System in: The number of interrupts per second. Website: www. swap. including the clock. w: The number of processes swapped out but otherwise runnable. IO bi: Blocks sent to a block device (blocks/s). Memory swpd: the amount of virtual memory used (kB).3. These statistics are generated using data from the last time the command was run to the present. In the case of the command never being run. This field is calculated. The following was taken from the vmstat man page. the data will be from the last reboot until the pre sent.
but you are being told that it is in use. System Monitoring Or suppose you want to see all files in use by a particular process. An exa mple of this is if you wish to unmount a filesystem. You could use this command and grep for the name of the filesystem to see who is using it. this list can be very long. Most of us have a limited amount of space. II Floor.1.proximo.2. It's a good resource for learning what tools are out there andhow to do a number of tasks. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Simply type in df and you'll be show n disk usage for all your mounted filesystems in 1K blocks 61 Linux Administration 86 . Filesystem Usage Many reports are currently talking about how cheap storage has gotten. 7.2. 7.1. Since Linux considers ever ythihng a file. Chris Karakas has wrote a refer ence guide titled GNU/Linux Command−Line Tools Summary . this command can be useful in diagnosing problems. and need to be able to monitor it and control how it's used. Finding More Utilities To learn more about what command line tools are available. Website: www.3. No. The df command The df is the simplest tool available to view disk usage. However. The lsof command The lsof command will print out a list of every file that is in use.in us: user time sy: system time id: idle time 7.6.5. To do this you would use lsof −p −processid−. Chapter 7. 7.1. but if you're like mo st of us it isn't cheap enough.
in You can also use the −h to see the output in "human−readable" format. Alternately.proximo. Unless you specify a filename du will ac t recursively. In addition to space usage. Linux Administration 87 . M egs. you could use the −i option to view the number of used and ava ilable inodes. or Gigs depending on the size of the filesystem. Website: www. II Floor.2. This will be in K. For example: Unless you specify a filename du will act recursively.3. you can also use the −B to specify bloc k size. No. 7.2. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The du command Now that you know how much space has been used on a filesystem how can you find out w here that data is? To view usage by a directory or file you can use du.
II Floor. Quotas For more information about quotas you can read The Quota HOWT O . No.in If you just want a summary of that directory you can use the −s option. 7. Y ou are going to want to see who is on the system.3. The who command The easiest way to see who is on the system is to do a who or w. Website: www. Maybe you notice that a lot of RAM is being used. or a lot of CPU activity. what they are running.2.proximo. and what kind of resources they a re using. Source Unknown From time to time there are going to be occasions where you will want to know exactly what people are doing on your system.3. 7. Monitoring Users Just because you're paranoid doesn't mean they AREN'T out to get you.3.1. The −−> who is a simpl e tool that lists out who is logged −−> on the system and what port or terminal they are logged on at. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076..3. Linux Administration 88 . 7..
3. bu t what if we want to see what they are doing? We could to a ps −u aweeks and get the following outpu t From this we can see that the user is doing a ps ssh.3. but also the commands they are running. No.184.108.40.206. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. nice and renice To Be Added Chapter 8. The ps command −again! In the previous section we can see that user aweeks is logged onto both pts/1 and pts/2. and have another terminal open sitting idle at a bash prompt.4.3. The skill command To Be Added 7. II Floor. This is a much more consolidated use of the ps than discussed previously. 7. 7. The w command Even easier than using the who and ps −u commands is to use the w.3. Website: www.in 7.proximo. Boots And Shutdowns Linux Administration 89 . w will print out not only who is on the system. I'm working in this document :−). From this we can see that I have a kde session running.
No... you make a grown man cry (Rolling Stones) This section explains what goes on when a Linux system is brought up and taken down. and how it should be done properly.. start it up. you've got to Never. and then runs i nit. the computer (its BIOS) read s in the first sector (called the boot sector) of a floppy or hard disk. files might be corrupted or lost. but the first piece of code that the computer loads must be very small (a few hundred bytes). The bootstrap loader is contained within thi s sector. init starts other processes to allow users to log in. but the a ct itself slightly more realistic. the computer first loads a small piece of code called the bootstrap loa der.3.. never. It loads the operating system from elsewhere on the disk (or from some other place). which in turn loads and starts the operating system. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.. The reason for this two step process is that the operating system is big and com plicated. never never stop Start it up Ah. If proper procedures are not followed. then filesystems and swap areas are un Linux Administration 90 . An overview of boots and shutdowns The act of turning on a computer system and causing its operating system to be loaded is called booting. II Floor. Different computers do the bootstrapping differently. During bootstrapping.. After Linux has been loaded. and do things. you've got to. never. it initializes the hardware and device drivers. 8. to av oid making the firmware unnecessarily complicated. In order to shut down a Linux system.in Start me up Ah. The bootstrap loader is usually stored in a fixed locat ion on a hard disk or a floppy. first all processes are told to terminate (this makes t hem close any files and do other necessary things to keep things tidy). For PCs. never You make a grown man cry. The details of this part will be discussed b elow. The name comes from an image of the computer pulling itself up from its bootstraps. Website: www.proximo.1.
the kernel is just stored in consecutive sectors. each with their own boot sectors. or GRUB. otherwise the first hard disk. however) and will then read its very first sector. and finally a message is printed to the console that the power can be turned off. there is no filesystem. This is called the boot sector. so the code Linux Administration 91 . and therefore poss ibly unusable. terrible things can and will happen.proximo. The details vary. to boot fr om a floppy with a filesystem. Website: www. which means that all data in it is lost and the filesystem on disk is inconsistent. it is also called the master boot record. however. if there is a floppy inserted. for a hard disk. since it is generally not useful to have a separate partition for just the kernel image. I t will choose a disk drive (typically the first floppy drive. of course) to a predetermined place in memory. II Floor. most importantly. and will then start the actual booting. If the proper procedur e is not followed. The boot process in closer look When a PC is booted.in mounted. 8. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.3. the order might be configurable. since this simplifies the boot process. the LInux LOader. the boot sector contains code that just reads the first few hundred blocks (depending on the actual kernel si ze. It is possible. sinc e a hard disk can contain several partitions. or POST for short. When booting from the hard disk. the code in the master boot record will examine the partit ion table (also in the master boot record). Chapter 8. the GRand Unifying Bootloader. read the boot sector from that partition. however. When booting Linux from a floppy dis k. the BIOS will do various tests to check that everything looks all righ t. The code in the partiti on's boot sector does what a floppy disk's boot sector does: it will read in the kernel from the partition and s tart it. On a Linux boot floppy. and then start the code in that boot sector. identify the active partition (the partition that is marked to be boot able). No. Boots And Shutdowns The boot sector contains a small program (small enough to fit into one sector) whose respo nsibility is to read the actual operating system from the disk and start it. the filesystem buffer cache might not be flushed.2. if one is installed in the computer. by using LILO. This process is called the power on self test .
Linux asks you which mode you want to use. for example. see the LILO or GRUB documentation for more information. by whatever means. . it has to find the se ctors wherever the filesystem has put them. with an optional timeout that will cause the default kernel to be booted. or even other operating systems than Linux. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.) When booting. For a list of possible options you can read http://www. It is also possible to configure the boot loader to be able to boot one of several kernels. There are several ways around this problem. and it is possible for the user to choose which kernel or operating system is to b e booted at boot time. Alternatively. so it will first uncompress itself. it is possible to preset a video mode. LILO will ask what is to be booted and not boot the default right awa y. Most Lin ux distributions will setup the bootloader for you during the install process.3. GRUB or rdev. It is also possible to give a kernel command line argument. but generally booting from the hard disk is nicer. The beginning of t he kernel image contains a small program that does this.proximo.in in the partition's boot sector can't just read the disk in sequential order. II Floor. can be configured so that if one holds down the alt. No. and is started f or real. (The details about how to do this are irrelevant for this discu ssion. the kernel checks what other hardware there is (hard disks. Linux Administration 92 . • The Linux kernel is installed compressed.org/HOWTO/BootPrompt−HO WTO. LILO. it is most thorough. During the kernel compilation. the bootloader can be configured so that it will always ask.• After this. floppies. but the most commo n way is to use a boot loader like LILO or GRUB. Booting from floppy and from hard disk have both their advantages.tldp. so that this is never asked. shift. network ada pters. roughly the following things happen: . since it avoids the hassle of playing around with floppies. This can also be done with LILO. • If you have a super−VGA card that Linux recognizes and that has some special text modes ( such as 100 columns by 40 rows). the bootloader will normally go right ahead and read in and boot the default kernel. It is also faster.html . however. After the Linux kernel has been read into the memory. etc). or ctrl k ey at boot time (when LILO is loaded). . after the name of the kernel o r operating system.
The root filesystem is usually mounted read−only (this can be set in the same way as the place).3. A Word About Bootloaders Linux Administration 93 . • After this. • After this.The exact texts are different on different systems. .1 for more information (not yet written). it is not a good idea to check a filesystem that is mounted read−write. It will at le ast startsome essential background daemons. depending on the hardware. • init then switches to multi−user mode. No. the boot is complete. init may also start some other programs. it outputs messag es about . .proximo. Website: www. while it does this. This makes it possible to check the filesystem while it is mounted. and the system is up and running normally. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. .3.in and configures some of its device drivers appropriately. anyway). 8. The exact things it doe s depends on how it is configured. or any time with rdev or the bootloader. .2.• Then the kernel will try to mount the root filesystem. The filesystem type is detected automatically. for example because you didn't remember to include the corresp onding filesystem driver in the kernel. see Section 2. depending on how it is configured. the kernel panics and halts the system (there isn't much it c an do. the versio n of Linux being used. II Floor. the kernel starts the program init (located in /sbin/init) in the background (this w ill always become process number 1).1. and starts a getty for virtual consoles and serial line s. init does various startup chores. and how it has been configured. If the mounting of the root filesystem fails. The place is configurable at compilatio n time. . getty is the program which lets people log in via virtual consoles and serial terminals.
but you should change to root's home directory or the root directory. log out on all virtual consoles. the usual way of using shutdow n is to quit all running programs.html For more information on GRUB. log in as root on one of them (or stay log ged in as root if you already are. By u sing the proper shutdown sequence. you can read http://www. Linux Administration 94 . though you usually don't on a single user system). use the command shutdown −h +time mes sage.org/HOWTO/LILO. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Another reason against just flipping the power switch is that in a multi−tasking system t here can be lots of things going on in the background.html 8.proximo. Chapter 8. to a void problems with unmounting).org/software/grub/grub.in TO BE ADDED This section will give an overview of the difference between GRUB and LILO. Thi s is because Linux has a disk cache that won't write things to disk at once. Website: www. you ensure that all background processes can save their data.tldp. If you fail do so. Alternatively.3. Boots And Shutdowns The command for properly shutting down a Linux system is shutdown. It is usually used in one of two ways. More about shutdowns It is important to follow the correct procedures when you shut down a Linux system. II Floor. and message is a short explanation of why th e system is shutting down. For more information on LILO. If you are running a system where you are the only user. where time is the time in minutes until the system is halted. if your system has many users. This gre atly improves performance but also means that if you just turn off the power at a whim the cache may ho ld a lot of data and that what is on the disk may not be a fully working filesystem (because only some things h ave been written to the disk). No. and shutting the power can be quite disastrous. your filesystems probably will become trashed and the files probably will become scrambled.gnu. but only at intervals.3. you can visit http://www. then give the command shutdown −h now (substitute now with a plus sign and a number in minutes if you want a delay.
3. this is equivalent to usi ng shutdown.) Linux Administration 95 . If there are no running programs. and generally everything settles down. and the kernel and the update program sti ll run normally. II Floor. daemons are shut down. that usually gave sufficient time for most disk I/O to be finished. Then. When that is done. and just about everythi ng you can do is hope that nothing has been too severely damaged and turn off the power. In the old days. all filesystem ar e unmounted. some people like to shut down using the command sync three times. For instance. with shorter and shor ter intervals as the time runs out. Website: www. should you move your fingers towards the power switch. user processes (if anybody is still logged in) are killed. When the real shutting down starts after any delays.proximo. Sometimes. then turn off the power. and that they'd bett er get lost or lose The warning is automatically repeated a few times before the boot. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. it does not unmount any filesystems and this can lead to problems with the ext2 fs ``clean filesystem'' flag. all filesystems (except the root one) a re unmounted. although rarely on any good system. (In case you're wondering: the reason for three syncs is that in the early days of UNIX. it is impossible to shut down properly. and only then. init prints out a message that you c an power down the machine. it is probably a good idea to wait a couple of minutes to give update a chance to flush the buffe r cache. The triple−sync method is not recommended. if the kernel panics and crashes and burns and generally misbehaves. However. If the troubles ar e a bit less severe (say. it might be completely impo ssible to give any new commands. w hen the commands were typed separately. No.in This will warn everybody that the system will shut down in ten minutes. and only cut the power after that. wait ing for the disk I/O to stop. hence shutting down properly is somewhat difficult. somebody hit your keyboard with an axe).
some such boot disks contain only the kernel. Boots And Shutdowns instead of merely halting it. Systems that are physically accessible to anyo ne might even be configured to do nothing when ctrl−alt−del is pressed. Rebooting Rebooting means booting the system again. II Floor. for example. The action on ctrl−alt−del is configurable.6.5.in 8. Most Linux systems run shutdown −r now when ctrl−alt−del is pressed on the keyboar d. Website: www. for e xample. For example.3. you need a n alternative way of booting that will always work (as long as the hardware works). but root can use the console. A simpler way is to ask shutdown to reb oot the system. you might have to restore some files from backups made with softw are not on the installation disks. This is useful for system administration tasks that can't be done while the system is running normally. The Bootdisk HOWTO Linux Administration 96 . 8. No. This is accomplished by using the −r option to shutdown.proximo. However. Chapter 8. and then turning it back on. Single user mode The shutdown command can also be used to bring the system down to single user mode. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. This reboots the system. turning power off. you might make your system unbootable. This can be accomplished by first shutting it down completely. I t is a good idea to do this. and it might be better to all ow for some delay before the reboot on a multiuser machine. if you make a mistake in configuring LILO. Thus. it might be necessary to create a custom root floppy as well. and assume you will be us ing the programs on the distribution's installation disks to fix whatever problem you have. 8. Most Linux distributions allow one to create an emergency boot floppy during installation. this mean s booting from the floppy drive. Emergency boot floppies It is not always possible to boot a computer from the hard disk. Sometimes those programs aren't enough. i n which no one can log in. For typical PCs. however. by giving the command shutdown −r now.4. For these situations.
Chapter 9. You can't use the floppy drive you use to mount the root floppy for anything else. This chapter explains how init is configured and how you can make use of the different run levels. init has many important duties. Thus. you can configure yo ur boot floppy to load the root disk to a ramdisk (the boot floppy's kernel needs to be specially configured for this). Usually. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. or if you want to change the default run level. which is the first user level process started by the k ernel.1. dial−in (not dial−out) modems. has started running.proximo. of course.) This chapter describes the init process. but that you still can mostly ignore. init "Uuno on numero yksi" (Slogan for a series of Finnish movies.tld p. Website: www.html . You must. II Floor. No. When the kernel has started itself (has been loaded into memory. init is always the first process (its process number is always 1). and if th Linux Administration 97 . If the kernel can't find init. However. if you have enough memory. This can b e inconvenient if you only have one floppy drive. 9. remember to keep youremergency boot and root floppies up to dat e.3. The kernel looks for init in a few locations that have been historically used for it.in by Graham Chapman contains instructions for doing this. implementing run l evels. and has initialized all device drivers and data structures and such). it tries to run /bin/sh. but the pr oper location for it (on a Linux system) is /sbin/init. the floppy drive is free to mount other disks. A good Linux distribution will come with a configuration for init that will work for most systems. init comes first init is one of those programs that are absolutely essential to the operation of a Linux syste m. You can find this HOWTO at http://www. such as starting getty (so that users can log in). and on these systems there is nothing you need to do about init. it finishes its own part of the boot process by starting a user level program. Once the root floppy has been loaded into the ramdisk. and taking care of orphaned processes. you only need to worry about init if you hook up serial terminals. init.org/HOWTO/Bootdisk−HOWTO/index.
init reads the /etc/inittab configuration file. cleaning up /tmp. init also adopts orphan processes: when a process starts a child proce ss and dies before its child. There are a few variants of init available. /etc/inittab can contain empty lines. it will re−read it. This difference is not essential. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. starting various services. init The fields are described below. The pr imary difference is run levels: System V has them. the child immediately becomes a child of init. When init starts. For other lines. This is important for various technica l reasons. and starting a getty for each te rminal and virtual console where users should be able to log in (see Chapter 10). II Floor. but it is good to know it. We'll look at sysvinit only.proximo. The BSD versions of Unix have a different init.in at also fails. We'll start with the simple case of configuring g etty lines. The /etc/inittab file is a bit complicated. In addition. id This identifies the line in the file. 9. No. the startup of the system fails. BSD does not (at least traditionally). Lines in /etc/inittab consist of four colon−delimited fields: Chapter 9. While the system is running. For getty lines. and lines that begin with a number sign (`#'). such as checking filesystems. since it makes it easier to understand process lists and process tree grap hs. Most Linux distributions use sysvinit (written by Miquel van Smoo renburg). init restarts getty for each terminal after a user has logged out (so that the next user can log in).2. which is based on the System V init design. Website: www. Configuring init to start getty: the /etc/inittab file When it starts up. these are both ignored. if sent the HUP signal (kill −HUP 1). it doesn't matter (except for l ength restrictions).3. it finishes the boot process by doing a number of administrative tasks. After the system is properly up. it specifies the terminal it runs on ( the characters after /dev/tty in the device file name). but it should be Linux Administration 98 . this feature makes it unnecessary to boot the system to make changes to the init configuration take effect.
a nd getty. 3. without changing run level Linux Administration 99 . it fails. e. If you wanted to add terminals or dial−in modem lines to a system. Others have all subsystems always running or start and stop them individually. 4. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. whether X is running. and so on. e. The last field is the command that runs getty on the first virtual terminal. To start a getty on the first virtual terminal (/dev/tty1). one for each terminal or dial−in line. one would write the following line: The first field says that this is the line for /dev/tty1. respawn to run the command in the n ext field again. For more details. runlevels The run levels the line should be considered for. when it exits..in unique. log out. To pr event this. The run levels are given as single digits. or once to run it just once. whether the network is operational. init starts it. If a command fails when it starts. and init is configured to restart it. Website: www. Different versions of getty are run differently. inittab. it fails.g. init starts it. it fails.g. and if the frequency grows to high.) action What action should be taken by the line. in all the normal multi−user run lev els (2−5). and 5. Run levels are identified by numbers.3. II Floor. see the manual pages init. No. you'd add more lines to /etc/inittab. process The command to run. and so on. ad infinitum. The third field means that the command should be run again.proximo. after it exits (so that one can log in. (Run levels are described in the next section. The second field says that it applies to r un levels 2. without delimiters.3. and make s ure it is the correct manual page. it will use a lot of syste m resources: init starts it. and then log in again). it will del ay for five minutes before restarting again. 9. Consult your manual page. init will keep track of how often it restarts a command. Run levels A run level is a state of init and the whole system that defines what system services are o perating. Some system administrators use run levels to define which subs ystems are working..
d.d/rcN. The number following the K or S indicates the order the scripts will be run. but it might b e easiest to follow the way your Linux distribution does things. If the name o f the link starts with a K.d/rc3.d.d directories. Here is a sa mple of what an /etc/init. Website: www. (Replace t he N with the run−level number. Table 9−1.) In each run−level you will find a series of if links pointing to start−up scripts located in /etc/ init. the service will be killed (if running).d may look like. Most distributions locate these directories either at /etc/init. II Floor. since run levels are too coarse for controlling their systems.d or /etc/rcN. Single−user mode (for special administration). Run level numbers Chapter 9. The names of these links all start as either K or S. followed by a number. No.in s.3. run−levels 2 through 5 can be modified to suit your own tastes. init 0 1 2 3 4 5 6 Halt the system.proximo. The following table defines how most Linux Distributions define the different run le vels. Linux Administration 100 . You need to decide for yourself. However. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If the name of the link starts with an S. then that indicates the service will be started when you go into that run level. Services that get started at a certain runtime are determined by the contents of the various rcN. Local Multiuser with Networking but without network service (like NFS) Full Multiuser with Networking Not Used Full Multiuser with Networking and X Windows(GUI) Reboot.
proximo. the second one means that this applies for run level 2. and stops services that shouldn't be running in the new run level any more . T he third field means that init should run the command in the fourth field once. It starts se rvices that aren't already running.d/rc command runs whatever commands are n ecessary to start and stop services to enter run level 2. init The command in the fourth field does all the hard work of setting up a run level. Website: www. The /etc/init. Exactly what the command is.3. depends on the Linux distribution.in How run levels start are configured in /etc/inittab by lines like the following: The first field is an arbitrary label. and that init should wait for it to complete. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. when the run level is ent ered. and how run levels are configured. II Floor. No. When init starts. it looks for a line in /etc/inittab that specifies the default run level: You can ask init to go to a non−default run level at startup by giving the kernel a command line argument of Linux Administration 101 . Chapter 9.
A running system can be taken to single user mode by using telinit to request run level 1. No. and for d etails on how to use the above ones. to be ignored. in which only the system administ rator is using the machine and as few system services.4. II Floor. (Or to start nethack. Note that the system administrator can configure the reaction to ctrl−alt−del to be some thing else instead. ctrlaltdel Allows init to reboot the system. for example. if the system is in a public location. as possible are running. This assumes the us e of a UPS. Kernel command line arguments can be given via LILO. and that can't happen. such as running fsck on a /usr partition. the telinit command can change the run level.. See your inittab manual page for all possibilities. 9.g. Some examples: powerwait Allows init to shut the system down. Linux Administration 102 . and software that watches the UPS and informs init that the power is off. e. This command usually cleans up /tm p. unless just about all system services are killed.in single or emergency. These special features are marked by special keywords in the third field. init runs the relevant command from /etc/inittab. The list above is not exhaustive. for example. Special configuration in /etc/inittab The /etc/inittab has some special features that allow init to react to special circumstan ces. when the power fails. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. 9. Booting in single user mode An important run level is single user mode (run level 1).) sysinit Command to be run when the system is booted.proximo. When the run level is changed. Single user mode is necessary for a few administrative tasks. since this requires that the partition be unmounted. including logins. While the system is running. when the user presses ctrl−alt−del on the console keyboard.5. T his allows you to choose the single user mode (run level 1).3. Website: www.
Chapter 9. it can be entered by giving the word single or emergency on the kernel command line: the kernel giv es the command line to init as well. and so on are described in some detail. The various interactions of background processes.proximo. If these match. init The bootup scripts init runs will automatically enter single user mode. login Linux Administration 103 . getty outputs a welcome message (stored in /etc/issue). b efore anything mounts or otherwise touches a broken /usr partition (any activity on a broken filesystem is likely to break it more. 10. and prompts the user for the password. (This will break if /etc/passwd has been broken by filesystem problems.in At bootup. Logging In And Out "I don't care to belong to a club that accepts people like me as a member. so fsck should be run as soon as possible). and finally runs the login program. init makes sure there is a getty program for the terminal connection (or console).3. but it's good to be prepared. Otherwise. (The kernel command line is entered in a way that depends on how you boot the system. log files. getty listens at the terminal and waits for the user to notif y that he is ready to login in (this usually means that the user must type something). of course. a properly configured system will ask for the root password before st arting the shell in single user mode. Such breakage is relatively rare." (Groucho Marx) This section describes what happens when a user logs in or out. II Floor.) Booting into single user mode is sometimes necessary so that one can run fsck by hand.3. Logins via terminals Section 2. if the automatic fsc k at bootup fails. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.) Chapter 10. and in that cas e you'd better have a boot floppy handy. When it notices a user. and usually involves a broken hard disk or an experimental kernel release.2 shows how logins happen via terminals. This is an attempt to prevent the system from using a filesystem that is so broken that fs ck can't fix it automatically. and init understands from that word that it shouldn't use the default run level. and prompts for the username.1. First. it would be simple to just enter a suitable line to LILO to get in as root. configuration files. As a security measure. login gets the username as a parameter. Website: www. No.
proximo. II Floor.in starts the shell configured for the user. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. else it just exits and terminates the process (perhap s after giving the user another chance at entering the username and password). init notices that the process terminated. getty also adapts to the speed and other settings of the connection. Website: www. Note that the only new process is the one created by init (using the fork system call). login. There are several versions of getty and init in use. which is important especially for dial−in connections. Figure 10−1. Logins via terminals: the interaction of init. getty. No. It is a good idea to learn Linux Administration 104 . where these parameters may change from call to call. A separate program.3. all with their good and bad points. and starts a new getty for the terminal. is needed for serial lines. and the shell . since it can be (and tra ditionally was) complicated to notice when a terminal becomes active. for noticing the user. get ty and login only replace the program running in the process (using the exec system call).
100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The virtual connections are established when there are two programs on different computers that wish t o communicate. a sort of imaginary cable. 10. II Floor. The original process remains and continues to listen for new logins. Logging In And Out other communications. In addition to logins. This way. it is not practical to start a get ty for each potential login.in about the versions on your system. The two most important ones are telnet and rlogin. That's a complicated and over−abstracted description of the reality. It might. Logins via the network Two computers in the same network are usually linked via a single physical cable. using just a single cable.3. It woul Linux Administration 105 . It is even possible to have several computers use the same cable. No.proximo. there is more than one communication protocol for network logins. There is a single process inetd (corresponding to getty) that handles all network logins. it starts a new process to handle that single login. and other network services). and the other computers ignore those connecti ons that they don't take part in. Gopher. you probably don't have to worry about getty. If you don't have dial−ins. but init is still important. the operating systems of both computers can have several virtual connections share the same p hysical cable. o nly imaginary. To make things a bit more complicated. it notices that it gets a new virtual connection to some other c omputer). As far as the programs at either end of the virtual con nection are concerned. the programs in each computer that take part in the communication are li nked via a virtual connection.e. several programs can communicate without having to know o f or care about the Chapter 10. Website: www.. the virtual connections exist between two computers.2. there is a huge number of potential virtual communications. they have a monopoly on their own cable. HTTP. However. however. and also about the other versions (you could use the Lin ux Software Map to search them). When the y communicate over the network. since the cable is not real. be g ood enough to understand the important reason why network logins are somewhat different from normal lo gins. there are many o ther virtual connections that may be made (for FTP. Since it is in principle possible to login from any computer in a network to any other comput er. Because of this. Wh en it notices an incoming network login (i.
so i t must be cleaned regularly. login outputs its contents to the terminal before it quits. see the Linux Network Administrators' Guide for more informa tion. No. w. Access control The user database is traditionally contained in the /etc/passwd file. Linux Administration 106 . it is cleared when the system is booted.4. Website: www. Both of these can be useful when tracking down intruders. 10. so instead there is o nly one listener that can recognize the type of the connection and can start the correct type of program to provid e the service. That file is typically created by shutdow n and relatives. and other similar commands look in utmp to see who are logged in. for example by having a weekly cron job to clear it. This file is valid only until the syste m is next rebooted or shut down. The last comman d browses wtmp. If the file /etc/nologin exists. 10.in d be ineffective to have a separate process listening for a particular type of connection. Some systems use shad ow passwords. If it does e xist. X and xdm XXX X implements logins via xdm. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. login checks for this file. logins are disabled. It also logs all login s by root. login logs all failed login attempts in a system log file (via syslog). II Floor. also: xterm −ls TO BE ADDED 10. All successful logins are recorded into /var/log/wtmp. Both utmp and wtmp are in a binary format (see the utmp manual page). These can be disabled by creating a file called .5.hushlogin in the user's home directory. Currently logged in people are listed in /var/run/utmp. It lists each user and the t erminal (or network connection) he is using. and of setting up an initial environment for the user by setting permissions for the serial line and starting the shell. and will refuse to accept a login if it exists. The who.3. it is unfortunatel y not convenient to examine them without special programs.3. Part of the initial setup is outputting the contents of the file /etc/motd (short for message of the day) and checking for electronic mail. What login does The login program takes care of authenticating the user (making sure that the username a nd password match). along with some other useful information.proximo. This single listener is called inetd. This file will grow without limit.
root usually can't login via most terminals or the network. While crack can be run by intruders.profile in the user's home directory. especially by s etting the PATH to include local command directories in addition to the normal ones.group.3. The user database contains not only the passwords. and use the su command to become root.e.. they might also automatically copy the data base from one central location to all other computers. it can also be run by the system administrat or to avoid bad passwords. so that anyone can read it. /etc/profile allows the system administrator to have set up a common user environment. i. On the other hand. not easily guessed. II Floor. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. any password it can find is b y definition not a good one. witho ut trying to actually log into the computer. . It is. if necessary.profil e allows the user to customize the environment to his own tastes by overriding. see the documentation of each shell for further information. 10. and login shells. they execute . it automatically executes one or more pre−defined fil es. the Bourne shell (/bin/sh) and its deriva tives execute /etc/profile. only via terminals listed in the /et c/securetty file. Good passwords can also be enforced by the passwd program. however. No. since cracking passwords requires quite a lot of computation. for example. This does have the drawba ck that anyone with access to the encrypted password can use various cryptographic methods to guess it.proximo.in and have moved the passwords to /etc/shadow. The crack program can be used to crack passwords. in addition. possible to log in via any terminal as any other user. installing shadow pass words later onto a system that did not support them can be difficult. Sites with many computers that share th e accounts use NIS or some other method to store the user database. This other information needs to be p ublic. Most shells first run some global file. Shell startup When an interactive login shell starts. Website: www. home directories. there can be a /etc/shadow. The user group database is kept in /etc/group. it is important to make sure that all passwords in a system are g ood. but also some additional information ab out the users. This makes it necessary to get physical access to one of these terminals. Therefore the password is stored encrypted. the default Linux Administration 107 . such as their real names.6. which only root can read (the password is still stored encrypted). this is in fact m ore effective in CPU cycles. However. Shadow passwords try to avoid this by moving the password into ano ther file. Different shells execute different files. for systems with shadow passwords. With or without passwords.
and that name is used to log in. Chapter 11. for example. how to modify the properties of thos e accounts. Two command line alternatives are adduser and useradd. No. you need to add information about the user to the user database. resources.2. so that their private files can be kept private. and proc essing time might have a price per second. Different Linux systems have different tools for doing this. What's an account? When a computer is used by many people it is usually necessary to differentiate between th e users. each user is given a uniqu e username. the user id or uid. these programs make everything seem trivial. Each user is identified by a unique i nteger." (Old. and in a commercial system each accoun t usually has some money attached to it. and information belonging to one user.3. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. There are several such programs available. This is important even if the comput er can only be used by a single person at a time. Managing user accounts "The similarities of sysadmins and drug dealers: both measure stuff in Ks. disk space might have a price per megabyte and day. there may be a GUI tool as well. because numbers are faster and easier for a computer to process than textual name s. Creating a user The Linux kernel itself treats users are mere numbers. 11. and that money vanishes at different speeds depending on how mu ch the user stresses the system.1.) This chapter explains how to create new user accounts. An account is all the files. Section 11. 11. There's more to a user than just a name. However. Linux Administration 108 . tired computer joke.in environment. The da tabase contains additional information as well. For example. as with most microcomputers. a nd both have users. Whatever the program. and crea te a home directory for him. The term hints at banks. To create a user. to each user id. and set up a suitable initial environm ent for him. Even if the details are many and intricate.proximo. II Floor. and how to remove the accounts. Most Linux distributions come with a program for creating accounts. the username. however.2. Thus. Website: www. the result is that there is little if any manual work to be done. A separate database outside the kernel assigns a textual name. It may also be necessary to educate the user.
2.3.2. but if you use t he Network filesystem (NFS). /etc/passwd and other informative files The basic user database in a Unix system is the text file.in 4 describes how todo it by hand. No. which only root can read. As mentioned. The file has one line per userna me. Picking numeric user and group ids On most systems it doesn't matter what the numeric user and group ids are. which lists all valid usernames and their associated information. /etc/passwd (called the passwor d file). . can't get at the password.2.proximo. • • • • Username.1. Normal programs. Most Linux systems use shadow passwords. /etc/shadow. Initial environment: /etc/skel Linux Administration 109 . • Full name or other description of account. This newer method of storing the password: the encrypted password is sto red in a separate file. you'll have to be invent a mechanism for synchronizing account in formation. 11. Numeric user id. II Floor. or whatever). Managing user accounts . . However. you should try to avoid re−using numeric uids (and textual usernames). and is divided into seven colon−delimited fields: . 11. Numeric group id. . Any program that needs to verify a user is setuid. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Previously this was where the user's password was stored. Website: www. because t he new owner of the uid (or username) may get access to the old owner's files (or mail. One alternative is to the NIS system (see XXX network−admin−guide). The format is explained in more detail on the passwd manual page. and can theref ore access the shadow password file. . If you are using NFS. you need to have the same uid and gid on all systems. you can let your account creation tool pick them automatically. which only use the other fields in the password file . The /etc/passwd file only contains a sp ecial marker in the second field. • Home directory. Chapter 11. previously passwords were store d in the /etc/passwd file. This is because NF S also identifies users with the numeric uids. If you aren't using NFS. 11. .2.3. • Login shell (program to run at login).
but usually the following commands do th e right . However. . The system administrator can create files in /etc/skel that will provide a nice default environ ment for users. For exam ple. if the name of the friendly editor changes. • Edit /etc/passwd with vipw and add a new line for the new account. since it will be next t o impossible to update existing users' files. • Create the home directory of the user with mkdir. 11. to set up an anonymous FTP server (so that anyone can download files from it. II Floor. • Copy the files from /etc/skel to the new home directory. you Linux Administration 110 . it is usually best to try to keep /etc/skel as small as possible. with a s cript. Whenever possible. the account will work.3. it is better to put global configuration into global files. so that other commands won't try to update it at the same time. he might create a /etc/skel/. . You shouldn't set it until e verything else has been done. This way it is possible to update it without breaking users' own setups. otherwise the user may inadvertently log in while you're still copying the files. if you need to create a new group as well. The system administrator could try to do it automatically. The −R option is most useful.profile. Be careful with the syn tax. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. For example. but that is almost certain going to break someone's file.2. such as /etc/pr ofile. it is initialized with files from the /etc/sk el directory. . The correct permissions vary a little from one site to another. No. Managing user accounts After you set the password in the last step. Do not edit directly with an editor! vipw locks the file. so that it is impossible to log i n. • Fix ownerships and permissions with chown and chmod. You should make the password field be `*'. Website: www. Chapter 11. edit /etc/group with vigr.4. follow these steps: . It is sometimes necessary to create dummy accounts that are not used by people. • Similarly.in When the home directory for a new user is created.profile that sets the EDITOR environment v ariable to some editor that is friendly towards new users.proximo. Creating a user by hand To create a new account manually. all ex isting users would have to edit their . . • Set the password with passwd. For example. without having to get an account first).
note that the above command will take a long time. Other tasks need to be done by hand.e. Such tasks tend to be rare. Remember that users may have files outside their home directory. if you change the username. Removing a user To remove a user. Likewise. It may sometimes be necessary to disable the se commands (with chmod) for normal users. you need to e dit /etc/passwd directly (with vipw. unless you also create a mail alias. to add or remove the user to more groups.. remember). For example. to change the username. If yo Linux Administration 111 . II Floor. cron an d at jobs. Changing user properties There are a few commands for changing various properties of an account (i. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Indeed. passwd Change the password. The find command can fi nd them: Chapter 11. so that no−one can use the account. it is usually not necessary to set the pas sword (last step above). e−mail will no longer reach the user. to prevent the user from using th e account while it is being removed. No. for example in an environment with many novice users.4. and should be done with cautio n: for example. before you start removing stuff. chsh Change the login shell. print jobs. you first remove all his files. 11. The super−user may use these commands to change the properties of any account. In such cases. Managing user accounts However.3. you n eed to edit /etc/group (with vigr). Then you remove the relevant lines from /etc/passwd and /et c/group (remember to remove the username from all groups it's been added to). and all other references to the user.3.proximo. It may be a good i dea to first disable the account (see below). however. if you have large disks. mail aliases. it is better not to.in need to create an account called ftp. Website: www. th e relevant field in /etc/passwd): chfn Change the full name field. since root can become any user. mailboxes. 11. Norm al users can only change the properties of their own account. unless they first bec ome root.
the user might not have paid his fees. A simple way to create the special programs is to write `tail scripts': The first two characters (`#!') tell the kernel that the rest of the line is a command that nee ds to be run to interpret this file. or the system administrator may suspect that a cracker has got the password of that account. It would also be possible to change the username or password to something else. Tail scripts should be kept in a separate directory. For exam ple. However. If user billg is suspected of a security breach.5. Some Linux distributions come with special commands to do this. No. Website: www. 11. so that their names don't interfere with n ormal user commands. The best way to disable an account is to change its shell into a special program that just pri nts a message. the system administrator would do something like this: The purpose of the su is to test that the change worked. whoever tries to log into the account. People are indeterministically unreliable. but then t he user won't know what is going on. will fail. Chapter 12. and will know why.3. Software is deterministically unreliable. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The tail command in this case outputs everything except the first line to t he standard output. you need to be careful so that you won't trash the network or the server. Confused users mean more work. Linux Administration 112 . Disabling a user temporarily It is sometimes necessary to temporarily disable an account. The message can tell the user to contact the system administrator so that any problems may be dealt with. it is easy to do it by hand as well. without removing it. II Floor.in u mount network disks. Backups Hardware is indeterministically reliable. of course. look for deluser or userd el. This way.proximo. and the commands might not do everything.
or natural disasters. It is important to do backups properly.proximo. When it comes to backups. not a rule. Like everything else that is related to the physical world. when trying to restore. Best of all. e.in Nature is deterministically reliable. The most critical piece of hardware for storing data is the hard disk. it might destroyed as well. By having several copies of the data. that you forgot to back up something i mportant. they will either make a mistake.g. it is a small miracle that anything works at all. This chapter explains about why. II Floor. There are basically four reasons why you might lose data: hardware failures. Part of doing backups well is to make sure they work. Since it is an investment.3. 12. On the importance of being backed up Your data is valuable. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. but the last known tape drive reading the kind of tapes you used was the one that now has a bucketful of water in it. which relies on tiny magnetic fields remaining intact in a world filled with electromagnetic noise. you don't want t o notice that your backups didn't work. Or you might notice. No. i t does not matter as much if one is destroyed (the cost is only that of the restoration of the lost data from the ba ckup). how. Nature migh t not be evil. Modern softwa re doesn't even tend to be reliable. you should protect it and take steps to avoid losing it. Website: www. Backups are a way to protect the investment in data.. paranoia is in the job description. It will cost you time and effort re−create it.1. but it can wreak havoc even when being good. Linux Administration 113 . it can still break se emingly spontaneously. leaving you with the smoki ng ashes of hard work. sometimes it can't even be re−created. you might have a bad crash just as you're ma king the backup. backups will fail sooner or later. Although modern hardware tends to be quite reliable. and that costs money o r at least personal grief and tears. and how to restore thing s from backups. or they will be malicious and destroy data on purpose. like the user database on a 15000 user site. All in all. software bugs . all your backups might be working perfectl y. human action. Humans are quite unre liable. and when to make backups. a rock solid program is an exception. Adding insult to injury. if you have only one backup medium. if it is the results of some ex periments.
very available. as long as it needs no supervision. speed. cpio. if backups can be done without interaction. The typical alternatives are floppies and tapes. 12. Backups the same computer as the disk you are backing up. No. Reliability is extremely important. Availability is obviously necessary. Selecting the backup tool There are many tools that can be used to make backups. they can be better in other ways. There are other alternatives. and usability. if the backup can't be done when the computer would otherwise be idle. fairly fast. A bac kup medium must be able to hold data without corruption for years. II Floor. A backup medium mustn't be hard or boring to use. since a broken backup can make a grown man cry. Speed is usually not very important. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. They are usually not very good on availability. fairly reliable. but not very usable for large amounts of data.3. making restoration of a single file quick) and tapes (contain a lot of data).proximo. Cost is important. since you should preferably have several times more backup storage than what you need for the data. Otherwise you may not be able to restore your backups after a disaster. Selecting the backup medium The most important decision regarding backups is the choice of backup medium. n ot very fast. depending on the size of the tape. and on computers other than yo ur own. It doesn't matter if a backup takes two hours. Website: www. The easier it is to make back ups. reliability. quite available. Tapes are cheap to somewhat expensive.2. On the other hand. then speed is an issue. but as a backup medium it is not very reliable. L ess obvious is the need for the medium to be available even in the future. Floppies are very cheap. and. A hard disk is typically very reliable. magneto−optical disks can have good sides of bot h floppies (they're random access.3. Usability is a large factor in how often backups are made. A cheap medium is usually a must. You need to consider cost. The way you use the medium affects it reli ability as a backup medium. quite comfor table. since you can't use a backup medium if it doesn't exist. availability. and dump. The traditional UNIX tools used fo r backups are tar. For example.in 12. In addition. but if that is not a problem. if it is in Chapter 12. the better. fairly reliable. there are large number of third party packages (both freewa Linux Administration 114 .
Directly reading the filesystem is also more effective. since there is more data to write to the tape and a full backup might not fit onto one tape (or floppy).in re and commercial) that can be used. Reading the filesystem directly has some advantages. since the kernel device drivers take care of the low level device handling and the devices all tend to look alike to us er level programs. then back up everything that has be en modified since the previous backup. Both are capable of using almost any media. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. The choice of backup medium can affect the choice of tool. you could use tape 1 for the firs t full backup (say. backups are a bit more work.4. dump also directly supports backup levels (which we'll be discussing below). tar and cpio are really for archiving files. A full backup is often more laborious than incremental ones. and so on). with tar and c pio this has to be implemented with other tools. The Linux S oftware Map lists many of the freeware ones. Linux Administration 115 . Some UNIX versions of tar and cpio may have problems with unusual files (symbolic links. II Floor. you would have to mount the filesystem read−only fir st. files with very long pathnames. Restoring from incremental backups can be many times more work than from a full one.3. The first backup is called a full backup. but the Linux versions should handle all files correctl y. It makes it possible to back files up without affecting their time stamps. device files.proximo. Simple backups A simple backup scheme is to back up everything once. the subsequent ones are incre mental backups. if everything needs to be backed up. since it can be d one with much less disk head movement. No. and retrieving files from them. Restoration can be optimized so that you always back up ev erything since the previous full backup. Website: www. 12. A comparison of the third party backup tools is beyond the scope of this book. Both are capab le of storing files on tapes. although they work for backups as well. It is a lso written specifically for backups. tar and cpio are similar. and mostly equivalent from a backup point of view. this way. the Linux dump program understands the ext2 filesystem only. but there should never be a ne ed to restore more than a full backup and an incremental backup. If you want to make backups every day and have six tapes. dump is different in that it reads the filesystem directly and not via the filesystem. The major disadvantage is that it makes the backup program specific to one filesystem type. for tar and cpio.
Wh en you need to make the next full backup. and also very long paths. you want to keep tape 1 somewhere else. You don't want to overwrite tape 1 until you've got a new full backup. (Linux only uses GNU tar. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. or else use another w indow or virtual terminal and do it when tar asks for a new floppy. No. Making backups with tar A full backup can easily be made with tar: The example above uses the GNU version of tar and its long option names. 12. or an old version of a file. The traditional v ersion of tar only understands single character options.3. The n you make a new full backup on tape 6 (second Friday). This way you can have full backups from several previou s weeks.) If your backup doesn't fit on one tape. so that when your other backup tapes are destroyed in the fire.4. which is good if you want to find an old.in on a Friday). After you've made a full backup to tape 6. lest something happens while y ou're making the full backup. you still have at least something left. Linux Administration 116 . After you've made a backup. If you have more than six tapes.proximo. you need to use the −−multi−volume (−M) option: Note that you should format the floppies before you begin the backup. The GNU version can also handle backups that don't fi t on one tape or floppy. you can use the extra ones for full backups.1. you fetch tape 1 and leave tape 6 in its place. now deleted file. you should check that it is OK. Each time y ou make a full backup. and tapes 2 to 5 for the incremental backups (Monday through Thursday). you use the oldest tape. Website: www. and start doing incremental ones with tapes 2 to 5 ag ain. II Floor. not all traditional versions can do these things. using the −−compare (−d) opti on: Failing to check a backup means that you will not notice that your backups aren't working u ntil after you've lost the original data.
tar can't notice when a file's inode information has changed. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. No.proximo. for example. or when its name has been changed. Website: www. II Floor. th at its permission bits have been changed. S cripts and programs for doing this can be found on Linux ftp sites.3. This can be worked around us ing find and comparing current filesystem state with lists of files that have been previously backed up. Restoring files with tar The −−extract (−x) option for tar extracts files: You also extract only specific files or directories (which includes all their files and subdirecto ries) by naming on the command line: Linux Administration 117 .2.4. 12.in An incremental backup can be done with tar using the −−newer (−N) option: Unfortunately.
A longer backup hist ory is useful. The purpose for doing this is that it allows a longer backup history cheaply. to use random access database techniques when using a tape drive or so me other sequential medium. and the different levels of incremental back ups levels 1. This can be genera lized to any number of levels. Linux Administration 118 .5. This can be a big problem. 12. multilevel backups are more appropriate. No. Multilevel backups The simple backup method outlined in the previous section is often quite adequate for per sonal use or small sites. it will exist again after yo u have done the restore. It is not possible. 2. but only a week per new tape. if the file has sensitive data that should no longer be available. so for large volumes it is rather slow. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. which might be too expensive. In the exampl e in the previous section. The simple method has two backup levels: full and incremental backups. however. Even a version of a file tha t is not very up to date is better than no file at all. A full backup would be level 0.proximo. tar doesn't handle deleted files properly. This could be extended by having more tapes. and you have deleted a file between the two backups. the backup history went back to the previous full backup. II Floor.3. 3. etc.in Note that tar always reads the backup volume sequentially. At each incremental backup level you back up everything that has changed since the previous backup at the same or a previous level. If you need to restore a filesystem from a full and an incremental backup. since deleted or corrupted files are often not noticed for a long time. Website: www. For more heavy duty use.
Website: www. The most you have to backup is two day's w orth of work. 8. 4. Table 12−1. Backup levels can also be used to keep filesystem restoration time to a minimum. To minimize the number of tapes needed to restore. we've been able to extend the backup history from two weeks (after all daily tapes have been used) to two months. A better scheme is suggested by the dump manual page and described by the ta ble XX (efficient−backup−levels). 6. you could use a smaller level for each incremental tape. Use the following succession of backup levels: 3. tapes 3 to 6 for we ekly backups (other Fridays. II Floor. 9 . 5. etc. if we buy ten tapes. an d tapes 7 to 10 for daily backups (Monday to Thursday). then the time to make the backups increases (each backup copies everything sin ce the previous full backup). The number of tapes for a restore depends on how long you keep between full backups.proximo. and which backups can be restor ed from at the endof the month. 9. This keeps both the backup and restore times low. However. an d keep down the number of backups to restore. A sample multilevel backup schedule. note that there can be five Fridays in one month. No. For example. but what we can restore is often good e nough. If you ha ve many incremental backups with monotonously growing level numbers. Instead you can use level numbers that aren't monotonous. we could use tapes 1 and 2 for monthly backups (first Friday each month). but it i s less than in the simple schemes. With only four more tapes. It is true that we can't restore every version of each file during those two months.in With multiple levels the backup history can be extended more cheaply. Figure 12−1 shows which backup level is used each day. 2. Efficient backup scheme using many backup levels Tape 1 Level 0 Backup (days) n/a Restore tapes 1 Linux Administration 119 .3. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. you need to restore all of t hem if you need to rebuild the whole filesystem. so we need four more tapes). 7. Figure 12−1.
5. Some programs have support for for c ompression built Linux Administration 120 . it is never a good idea to back it up. 2. 2. the backups can be compressed.proximo. 5. 7 1. 7. 5. 9. Website: www. . 6 1. 7. 2 1. To reduce the space neede d. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. 7. .in 2 3 4 5 6 7 8 9 10 11 3 2 5 4 7 6 9 8 9 9 9 1 2 1 2 1 2 1 2 1 1 1 1. You must decide if it is worth it. lest you need to do al l the work to configure them all over again. 12.. Especia lly the /proc/kcore file is unnecessary. You must decide what you consider important. which can cost quite a lot of money.. 11. Chapter 12. Gray areas include the news spool. 9. The major exception is software that can be easil y reinstalled. 2. Compressed backups Backups take a lot of space. log files. 3 1. 10. and many other things in /var.. 5. 5. dump has built−in support for backup levels. 9 1. bu t possibly other things scattered all over the filesystem). 7.3. 5. 2. 4 1. 5. 2. Another major exception is the /proc filesystem. Backups The obvious things to back up are user files (/home) and system configuration files (/etc. For tar and cpio it must be implemented with shell scripts. 12. There are several ways of doing this. 9. 2. A fancy scheme can reduce the amount of labor needed.6. 2. it' s pretty large as well. 7. What to back up You want to back up as much as possible.7.. 2. since it is just an image of your current physical memory. 5 1. but it does mean there are more th ings to keep track of. 11 1. 10. No. but even they may have configuration files that it is important to back up. since that o nly contains data that the kernel always generates automatically. 10 1. 8 1. 2. II Floor.
Chapter 13. you don't need to do anything about time. Website: www. Unfortunately. Backups must be reliable. cron & at − refer to other HOWTO's for details.) This chapter explains how a Linux system keeps time. for example. The afio program (a variant of cpio) can do this. such as alternating light and dark periods caused by the rotation of the planet. This can be avoided by buffering the output (either internally. but no method can handle a large number of errors. Due to the nature of how compressio n works. The lost file would have been corrupted anyway. II Floor. The total time taken by two successive periods is const ant. if the backup pr ogram if smart enough.3. but all other files are unharmed. No. Lunchtime double so.in in. This means tha t if the backup is compressed the way GNU tar does it. 14. all the rest of the compressed data will be unusable.proximo. compressed backups can cause trouble. Some backup progr ams have some built in error correction." (Douglas Adams. Usually. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. before writing it to the backup medium. An alternative way is to compress each file separately. with the whole output compressed as a unit. Discuss non−crontab cron jobs such at those in the /etc direct ory. or by using another program). and what you need to do to avoid cau sing trouble. Compression takes some time. Linux Administration 121 . but it is good to understand it. which may make the backup program unable to write data fast enough for a tape drive. This still means that the one file is l ost. the −−gzip (−z) option for GNU tar pipes the whole backup through the gz ip compression program. but even that might not work well enough. One simple constant is noon. a single error makes all the rest of the backup lost.'Mark Twain'" Basic discussion on scripting. This s hould only be a problem on slow computers. so this situation is not much worse than not using compression at all. Chapter 14. The concept of localtime Time measurement is based on mostly regular natural phenomena.1. Keeping Time "Time is an illusion. Task Automation −−To Be Added "Never put off until tomorrow what you can do the day after tomorrow. and this method of compression is not a g ood idea. if a single bit is wrong. but the lengths of the light and dark period vary.
formerly known as Greenwich Mean Time or GMT. The hardware and software clocks Linux Administration 122 . and then m ove the clocks back during winter. No. All the system administrator needs to do is to select the appropriate time zone. II Floor. do not agree when the clo cks should be moved. 14. so a global standard for measuring time has been defined. you'll notice the need for a commo n time.proximo. Also. they move their clocks to have more natural light while they work. Helsinki. Other countries do not do this. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. noon happens at different times in different places. Other than setting the system t ime zone and upgrading the time zone data files. Those that do.2. that is. In the US and some other countries.3. so that there is no confusion about when things should happen. and that can easil y be updated when the rules change. however. While geography would allow all places that have noon at the same time have the same time zone.in Noon is the time of the day when the Sun is at its highest position. It is better to talk about the local time in. For various reasons. England). and they change the rules from year to year. this is important since many people work with computers i n different countries over the Internet. make sure you'll upgrade at least that part of your Linux system. Linux has a time zone package that knows about all existing time zones. say. Website: www. The abbreviations are not unique. As soon as you need to communicate with distant places. Since (according to rec ent research) the Earth is round. politics makes it difficult. the local time zones have a name and a three letter abbreviat ion. As long as you stay in the same place. This leads to the concep t of local time. Humans measure time in many units. Each local time is called a time zone. This time is called universal time (UT or UTC. there is little need to bother about time. it doesn't matter that local times differ. many countries us e daylight savings time. since it used to be local time in Greenwich. and should not be used unless the country is also na med. Time zones are best named by the location or by telling the difference between local and uni versal time. When the rules for daylight savings time change in your local t ime zone. since not all coun tries in Eastern Europe follow the same rules. than about East European time. they can express times in universal time. In modern times. most of which are tied to natural phenomena like no on. This makes time zone conversions defi nitely non−trivial. most of the places in the world communicate with most other places in the world. each user can set his own time zone. When people with different local times need to communicate.
Linux maintains its own clock because looking at the hardware is slow and complicated. If you fail to find the zoneinfo directory in either the /usr/lib or /usr/share directories. The hardware clock can be in local time or in universal time. This way. including MS−DOS. The syntax of the TZ variable is described in the tzset manual page. Unfortunately. For example. the system time zone is determined by the symbolic link /etc/localtime. What happens when you have a users located in a different timezone? A user can change hi s private time zone by setting the TZ environment variable. For example: Linux Administration 123 . assume the hardware clock shows local time. but if the hardware clock shows local time.in A personal computer has a battery driven hardware clock. some PC operating systems. the kernel does not need to know a bout time zones at all. This link points to a time zone data file that describes the local time zone. either do a find /usr −print | grep zoneinfo or consult your distribution's documentation. 14. On a Debian system the /etc/localtime link would point to /usr/lib/zoneinfo/US/Eastern. After this. It is usually better to have it i n universal time. Each process handles time zone conversions itself (using standard tools that are part of the time zone package). The hardware clock can be set from the BIOS setup screen or from whatever operating system is running. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. If it is unset. Showing and setting time In Linux. The time zone data files are located at either /usr/lib/zoneinfo or /usr/share/zoneinfo depending on what distribution of Linux you use. The kernel clock always shows universal time. No.3. The Linux kernel keeps track of time independently from the hardware clock.proximo. on a SuSE system located in New Jersey the /etc/localtime link would point t o /usr/share/zoneinfo/US/Eastern. Linux can handle either. the system time zone is assumed. Wind ows. and OS/2. because then you don't need to change the hardware clock when daylight savings time be gins or ends (UTC does not have DST). then it must be modified when daylight savings time begins or ends (otherwise it wo uldn't show local time). The date command shows the current date and time.3. The simplicity results in higher reliability and makes it easier to update the time zone information. both clocks run independently . Website: www. Linux sets its own clock to the same time as the hardware clock. The battery ensures that the cloc k will work even if the rest of the computer is without electricity. During the boo t. II Floor.
If you change the clock. You must u se the −u option correctly. If the system has too many processes running. the syntax is a bit arcane. When the clock is wrong The Linux software clock is not always accurate. it may take too long to service the timer interrupt. No. Refer the the time man page. The clock commands synchronizes the hardwar e and software clocks.in That time is Sunday. II Floor. you first set the software clock with date. Big jumps or bac kward jumps are more dangerous than smaller or forward ones. Only root can set th e time. Beware of the time command. This is not used to get the system time. in the time zone called ``EET date is also used to set the kernel's software clock: See the date manual page for more details. For example. On one early Unix system. at about ten before ten at the evening. the cron daemon runs commands periodically. 14. 1996. If you don't. Linux Administration 124 . someone set the clock twenty years into the future. and then the hardware clock with clock −w. your computer will be quite confused about what the time is. Instead it's use d to time how long something takes. The clocks should be changed with care. 14th of July. to read the hardware clock and set the software cl ock.proximo. it can be confused of whether it needs to run the commands or not. The −u option to clock tells it that the hardware clock is in universal time. and cron wanted to run all the periodic commands for twenty years all at o nce. but you should still be careful. Many parts of a Unix system require the clocks to work correctly. the clock is the same for everyone. It is kept running by a periodic timer interr upt generated by PC hardware. Website: www. If you need to set both clocks. It is used when the system boots. date only shows or sets the software clock. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.3. While each user can have his own time zone. Current versions of cron can handle this correctly.4.
Chapter 14. No. The hardware clock runs independently and is usually more accurate. If you need to adjust the hardware clock. and do it from there. and proper time stamp control.gov/about. Keeping Time For more casual Linux users. this is just a nice luxury.deb or . At my home all our clocks are set bas ed upon what my Linux system says the time is. it is usually simplest to reboot.time. if some part of the system starts acting funny. This avoids all trouble that changing system time might cause. For larger organizations this "luxury" can become essential. For more information on this command read man hwclock. Another method would be to use either hwclock −w or hwclock −−systohc to sync the hardware clock to the software clock. If you boot your computer often (as is the case for most systems that aren't serve rs). Visit http://www. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Some SAN's require NTP be co nfigured and running properly to allow for proper synchronization over filesystem usage.3. It is a method of verifying and correcting your computer's time by synchronizing it wi th a another system. Network Time Protocol (or NT P) does exactly that. 14. Some SANs (and some applications) can become confused when dealing with files that have timestamps that are in the future. Website: www.html for more info. set the new time with date and clock (in that order). either a . You can use that to install NTP. Most Linux distributions come with a NTP package of some kind.5. II Floor. NTP − Network Time Protocol A networked computer (even if just over a modem) can check its own clock automatically b y comparing it to the time on another computer known to keep accurate time. If you want to sync your software clock to your hardware clock then you w ould use hwclock −s or hwclock −−hwtosys. or you can download the source files from http://www. it will usually keep fairly accurate time. go into the BIOS setup screen. If doing it via BIOS is not an option.rpm packa ge.in and the software clock starts slipping behind.org/downloa Linux Administration 125 .proximo.ntp. With NTP your system's time can be maintained to within milliseconds of Coordinat ed Universal Time. but be prepared to reboot. Another example of how important NTP can be is with a SAN. B eing able to search log files for events based upon time can make life a lot easier and take a lot of the "g uess work" out of debugging.
and who can effect it. You can accidental restrict yourself from synchronizing and waste time debugging why. I won't go into too much detail on how to configure NTP. An example of a basic ntp.conf or /etc/xntp. one that it wishes to synchronize with.in ds.html andcompile it yourself. Instead I'll just cover the basics. The pseudo IP is used in case of network proble ms or if the remote NTP server goes down. II Floor. Linux Administration 126 . Either way. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.proximo.conf file dependin g on what distribution of Linux you have.0). You should also list a location for a drift file. One will act as a primary server and the other as a backup. The restrict option can be used to provide better control and security over what NTP ca n do.6.1. 14. It is recommended that you list at least 2 remote servers that you can synchronize against. the basic configuration is the same.conf file will simply list 2 servers. NTP will synchronize against itself until the it can start synch ronizing with the remote server again.127.3. Website: www.conf file would look like: The most basic ntp. Basic NTP configuration The NTP program is configured using either the /etc/ntp. and a pseudo IP address for itself (in this case 127. For example: It is advised that you wait until you have NTP working properly before adding the restri ct option. No. Over time NTP will "learn" the system clock' s error rate and automatically adjust for it.
Be patient! A simple test is to change your syste m clock by 10 minutes before you go to bed and then check it when you get up. Website: www. it immediately corrects it. There are 2 main disadvantages of using using this method. 14. they should just setup a cron job job to periodically run the ntpdate command. The first is that ntpdate does a "brute force" method of changing the time. if you are using time sensitive security software. In some environments. A slightly more different version of ntpdc −c kerninfo is ntptime Linux Administration 127 . No. II Floor. you can inadvertent ly kill someones access. The ntpdc −c loopinfo will display how far off the system time is in seconds.7. based upon t he last time the remote server was contacted.in NTP slowly corrects your systems time. For example. ntpdc −c kerninfo will display the current remaining correction.3. this can cause problems if time drastically changes. The time should be co rrect. Many people get the idea that instead of running the NTP daemon. The NTP daemon slowly changes the time to avoid causing this kind of disruption. The ntpq −p comm and will print out your system's current time status. The other reason is that the NTP daemon can be configured to try to learn your systems ti me drift and then automatically adjust for it. NTP Toolkit There are a number of utilities available to check if NTP is doing it's job.proximo. So if your comp uter's time is off my 5 minutes. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
Yet another way to see how well NTP is working is with the ntpdate −d command. This will contact an NTP server and determine the time difference but not change your system's time.
Linux Administration 128
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
If you want actually watch the system synchronize you can use ntptrace.
If you need your system time synchronized immediately you can use the ntpdate remote− servername to force a synchronization. No waiting!
14.8. Some known NTP servers A list of public NTP servers can be obtained from: http://www.eecis.udel.edu/~mills/ntp/se rvers.html . Pleaseread the usage information on the page prior so using a server. Not all servers have the available bandwidth to allow a large number of systems synchronizing against them. Therefore it is a good idea to c ontact a system's administrator prior to using his/her server for NTP services. 14.9. NTP Links More detailed information on NTP can be obtained from the NTP homepage:http://www.ntp. org. Or from http://www.ntp.org/ntpfaq/NTP−a−faq.htm Chapter 15. System Logs −−To Be Added Log info, rotation, monitoring, etc.. Chapter 16. System Updates −−To Be Added
Linux Administration 129
No.3, II Floor, 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Website: www.proximo.in
"A lie gets halfway around the world before the truth has a chance to get its pants o n." Winston Churchill Discussion on how and when to update the system.
Chapter 17. The Linux Kernel Source
"Black holes are where God divided by zero. " Steven Wright BASIC info on the kernel source and compiling it. It will also provide some info on kdb debu gger. Refer to other kernel HOWTO's for more info.
Chapter 18. Finding Help
"Help me if you can I'm feeling down. And I do appreciate you being 'round." − The Beatles Help is out there. You just have to know where to look. With Linux there are an amazing nu mber of places you can go. There are mailing lists, IRC channels, web pages with public forums, and many other resources available. This chapter will try to help you get the most out of your quest for help. 18.1. Newsgroups and Mailing Lists This guide cannot teach you everything about Linux. There just isn't enough space. It is alm ost inevitable that at some point you will find something you need to do, that isn't covered in this (or any othe r) document at the LDP. One of the nicest things about Linux is the large number of forums devoted to it. There are f orums relating to almost all facets of Linux ranging from newbie FAQs to in depth kernel development issues. To receive the most from them, there are a few things you can do. 18.1.1. Finding The Right Forum The first thing to do is to find an appropriate forum. There are many newsgroups and mailin g lists devoted to Linux, so try to find and use the one which most closely matches your question. For exampl e, there isn't much point in you asking a question about sendmail in a forum devoted to Linux kernel developm ent. At best the people there will think you are stupid and you will get few responses, at worst you may rece ive lots of highly
Linux Administration 130
Write in clear. and that understanding will allow you to ask a more informed and sensible question.1. you have searched the web. http://www. There are also archives of newsgroups and mailing lists and it is entirely possible that your questio n has been asked and answered previously.in insulting replies (flames). There are no such words as ``u'' or ``b4. you have found your appropriate forum. You aren't ready yet. 18.google. That is considered shouting and looks very ru Linux Administration 131 . Writing Your Post Okay.'' Try to make yourself loo k like an educated and intelligent person rather than an idiot. 18.1. Your news client probably has a l ist of the newsgroups available to you.3.proximo. Stop. you have read the relevant HOWTOs and FA Qs. Similarly do not type in all capitals LIKE THIS. you may think you are ready to post your question. I promise. Now you can start wri ting your post. It will help. No. Finding Help to be someone who is willing to make an effort rather than a lazy idiot who requires spoonfe eding. This shows you Chapter 18.se ndmail. Website: www.google. searching for `Winmodem Linux PPP Setup' on google didn't return anything of use either''. It is always a good idea to make it clear that you already have read up on the subject by saying something like ``I have read the Winmodem−HOWTO and the PPP FAQ.com or a similar search engine should be so mething you trybefore posting a question. the latter is likely to meet with either st ony silence or outright derision. if any of them relate to the thing you are having a problem with then re ad them first. Have you already looked for the answer yourself? There are a huge nu mber of HOWTOs and FAQs available. what they will do is give you a better understanding of the subject area.mail. II Floor.3. but you still have not found the answer you need. but if not then a full list of newsgroups is available at http://gr oups.2. Even if they don't contain the answer to your problem. A quick look through the newsgroups available finds comp.com/groups?group=*. which looks like an appropriate place to ask a sendmail question. This is incredibly important. The former is likely to receive help if anyone knows the answer. but neither contained what I was loo king for. grammatical and correctly spelt English. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. It marks you as a precise and considered thinker. Before You Post Now that you have found your appropriate forum.
The point of most Linux forums is that everybody ca n learn something from each other. Follow Up After your problem has been solved. There are limits h owever. If you are having problems with your mail client it is unlikely that a dump of your kernel boot log (dmesg) would be of help. A question like ``My linux has stopped working. they usually don't.4. they will reach a wider audience that way. Whilst with some effort. If you send them HTML mail it of ten gets deleted unread. 18.1. Don't ask for replies by private email. People will appreciate this as it not only gives a sense of closure about the proble m but also helps the next time someone has a similar question. the discussion that followed your question and you r final solution. It will help you formulate your q uestion to maximize your chances of getting the answer you are looking for.1. but IRC can also be an excellent way of finding the answers you need. 18. Asking for private replies simply removes value from the newsgroup or m ailing list. post a short followup explaining what the problem was and how you solved it.in de. they will see you had the same problem.proximo.3. Website: www. More Information This short guide is simply a paraphrase and summary of the excellent (and more detailed) d ocument ``How To Ask Questions The Smart Way'' by Eric S Raymond. Formatting Your Post Do not post in HTML. 18. Try not to include irrelevant information either. Itis recommend that you read it before you post anything. II Floor. Provide clear details stating what the problem is and what you have already tried to do to f ix it.6. 18. they can read HTML email. Where has it stopp ed working? In what way has it stopped working? You need to be as precise as possible. No. Many Linux users have mail clients which can't easily read HTML email . When they look at the archives of the newsgr oup or mailing list. what can I do?'' is totally useless.catb.2. Most IRC networks have busy #linux channels and if the answer to your question is c Linux Administration 132 .org/~esr/faqs/smart −questions.5. Send plain text emails. http://www.1. However it does require some practice in asking que stions in the right way. IRC IRC (Internet Relay Chat) is not covered in the Eric Raymond document.html . 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.
18.2. This is inviolable. This breaks some old er terminals and is just plain ugly to look at. The rule about typi ng in clear and grammatical English still applies. but you have no right to get one. at worst you will be derided then kicked out. If you ask the question in the right way then you will probably get one. Finding Help 18.2. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. Do not type like a ``1337 H4X0R d00d!!!''.proximo.2. especially not you. wit h a the following additions Chapter 18. Be polite. There is no way of knowing that you are who you say you are. At best you will only look like an idiot. the Spanish one might be #linuxes or #linuxlatino. If you arrive in a channel and start spewing colour or bold then ex pect to be kicked out.1. Treat others as you would like to be treated.2. in English Most #linux channels are English channels. Don't go slapping anyone with large trouts. Colours Do not use colours. Most of the larg er IRC networks also have #linux channel in other languages. underline or strange (non ASCII) characters. Type Properly. 18. Port scanning Never ever ask anyone to port scan you. No. Would you believe this has been done before on ce or twice? And that we it wasn't funny the first time? 18. or that the IP that you are connected from belongs to y Linux Administration 133 . nobody is paying them. This makes them l ook foolish rather than dragging you down to their level. Website: www. If you think people are not being pol ite to you then don't start calling them names or getting annoyed. Speak English whilst in them. The people in Linux IRC channels are all there o n their own time. It looks silly and there by makes you look silly.4.2. for example the French language channel mi ght be called #linuxfr. Most of what has been said about newsgroups and mailing lists is still relevant for IRC. Even if other people are.3. or try to ``hack'' you.3. Be Polite Remember you are not entitled to an answer.in ontained in the man pages. become even politer. bold. or in the HOWTOs then expect to be told to go read them. II Floor. If you can't find the right cha nnel then asking in the main #linux channel (preferably in English) should help you find the one you are looki ng for.
2. and very few DOs. Even if you see other people being off topic.9. Don't be in hacker/cracker/phreaker/warezer channels whilst in a #linux channel.in ou. No. Warezing Don't ask about exploits. Probably the best thing you can do is to go into a #linux channel. Keep it in the Channel Don't /msg anyone unless they ask you to.2. The channel is a ``Linux'' channel. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076. CTCP stands for Client To Client Protocol.2. this does not mean that you should be. See the documentation for your IRC for more de tails.5. unless you are looking for a further way to be unceremoniously kic ked out. Stay On Topic Stay on topic. even if they ask you to.8.2. 18. It is liable to get you kicked out very quickly. they will notice they are being scanned. Don't ever port scan anyone. 18. Website: www. II Floor. Don't put people in the position where they have to say no to a request like this. 18. CTCPs If you are thinking of mass CTCP pinging the channel or CTCP version or CTCP anything. It is a method wh ereby you can find out things about other peoples' clients.3. Round Up Apologies if that seems like a lot of DON'Ts. sit there and watch. It diminishes the usefulness of the channel and s ome people just prefer that you not do it. Most people log TCP connectio ns. Phreaking. For some reason the people in charge of #linux channels seem to hate people who like causing destruction to people's m achines or who like to steal software.6. 18. They ar e probably channel regulars and different conventions apply to them.2. gettin Linux Administration 134 .proximo. The DOs were already prett y much covered in the section on newsgroups and mailing lists. Hacking. the n think again.7. In some jurisdictions port scanni ng may be illegal and it is certainly against the Terms of Service of most ISPs. If you are not familiar with IRC. Most people will report you to your ISP for this (it is trivial to find out who that is). Can't imagine why. You have no way to tell that they are who they say they are or that the IP they are connected from is their own IP. not a ``What Uncle Bob Got Up To Last W eekend'' channel. Cracking. 18.
We recommend this License prin cipally for works whose purpose is instruction or reference. Further Reading There are excellent FAQs about how to get the most of IRC #linux channels. This License is a kind of "copyleft". Appendix A. How to find this will usually be in the channel topic (which you can see at any time using the /topic command. PREAMBLE The purpose of this License is to make a manual. It complements the GNU General Public License. II Floor. this License preserves fo r the author and publisher a way to get credit for their work. or other functional and useful do cument "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it. which means that derivative works of the document mus t themselves be free in the same sense.2. with or without modifying it. which is a copyleft license designed for free software.proximo.quartz. 18. because free software needs free documentation: a free program should come with manuals providing the same freedom s that the software does. GNU Free Documentation License A.net. Most #linux ch annels have an FAQ and/or set or channel rules. while not being considered responsible for modif ications made by others. either commercially or noncommercially. This can help you to recognize the correct tone you should be using. No.in g the feel for a half hour before you say anything. 100 Feet Ring Road BTM Layout II Stage Bangalore‐560076.1. regardless of subject matter or whether it is published as a printed book. But this License is not limited to software manuals. textbook. Secondarily. Make sure you read the rules if there are any and follo w them. it can be used for any textual wor k. One fairly generic set of rules and advice is the ``Undernet #linux FAQ'' which can be found at http://linuxfaq.3. Website: www. Linux Administration 135 .10.nz . We have designed this License in order to use it for manuals for free software.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.