Linux System Administrator Guide Version0.9
Linux System Administrator Guide Version0.9<br><br>Table of Contents<br>About This Book.................................................................................................................................................1<br>1. Acknowledgments................................................................................................................................1<br>1.1. Joanna's acknowledgments.........................................................................................................1<br>1.2. Stephen's acknowledgments.......................................................................................................1<br>1.3. Alex's Acknowledgments...........................................................................................................2<br>2. Revision History..................................................................................................................................2<br>3. Source and pre-formatted versions available......................................................................................2<br>4. Typographical Conventions.................................................................................................................3<br>Chapter 1. Introduction......................................................................................................................................4<br>1.1. Linux or GNU/Linux, that is the question........................................................................................5<br>1.2. Trademarks.......................................................................................................................................5<br>Chapter 2. Overview of a Linux System...........................................................................................................7<br>2.1. Various parts of an operating system................................................................................................7<br>2.2. Important parts of the kernel.............................................................................................................7<br>2.3. Major services in a UNIX system.....................................................................................................8<br>2.3.1. init............................................................................................................................................9<br>2.3.2. Logins from terminals.............................................................................................................9<br>2.3.3. Syslog......................................................................................................................................9<br>2.3.4. Periodic command execution: cron and at............................................................................10<br>2.3.5. Graphical user interface.........................................................................................................10<br>2.3.6. Networking............................................................................................................................10<br>2.3.7. Network logins......................................................................................................................11<br>2.3.8. Network file systems.............................................................................................................11<br>2.3.9. Mail.......................................................................................................................................11<br>2.3.10. Printing................................................................................................................................12<br>2.3.11. The filesystem layout..........................................................................................................12<br>Chapter 3. Overview of the Directory Tree....................................................................................................13<br>3.1. Background.....................................................................................................................................13<br>3.2. The root filesystem.........................................................................................................................14<br>3.3. The/etc directory............................................................................................................................15<br>3.4. The/dev directory...........................................................................................................................17<br>3.5. The/usr filesystem..........................................................................................................................19<br>3.6. The/var filesystem..........................................................................................................................19<br>3.7. The/proc filesystem........................................................................................................................20<br>Chapter 4. Hardware, Devices, and Tools......................................................................................................22<br>4.1. Hardware Utilities...........................................................................................................................22<br>4.1.1. The MAKEDEV Script.........................................................................................................22<br>4.1.2. The mknod command............................................................................................................22<br>4.1.3. The lspci command...............................................................................................................23<br>4.1.4. The lsdev command...............................................................................................................23<br>4.1.5. The lsusb command...............................................................................................................23<br>4.1.6. The lsraid command..............................................................................................................23<br>4.1.7. The hdparm command...........................................................................................................23<br>4.1.8. More Hardware Resources....................................................................................................23<br>i<br><br>The Linux System Administrator's Guide<br>Table of Contents<br>Chapter 4. Hardware, Devices, and Tools<br>4.2. Kernel Modules...............................................................................................................................23<br>4.2.1. lsmod.....................................................................................................................................24<br>4.2.2. insmod...................................................................................................................................24<br>4.2.3. depmod..................................................................................................................................24<br>4.2.4. rmmod...................................................................................................................................24<br>4.2.5. modprobe...............................................................................................................................24<br>Chapter 5. Using Disks and Other Storage Media.........................................................................................25<br>5.1. Two kinds of devices......................................................................................................................25<br>5.2. Hard disks.......................................................................................................................................26<br>5.3. Storage Area Networks - Draft......................................................................................................28<br>5.4. Network Attached Storage - Draft.................................................................................................28<br>5.4.1. NFS........................................................................................................................................29<br>5.4.2. CIFS.......................................................................................................................................29<br>5.5. Floppies...........................................................................................................................................29<br>5.6. CD-ROMs......................................................................................................................................30<br>5.7. Tapes...............................................................................................................................................31<br>5.8. Formatting.......................................................................................................................................31<br>5.9. Partitions.........................................................................................................................................32<br>5.9.1. The MBR, boot sectors and partition table............................................................................33<br>5.9.2. Extended and logical partitions.............................................................................................33<br>5.9.3. Partition types........................................................................................................................34<br>5.9.4. Partitioning a hard disk..........................................................................................................35<br>5.9.5. Device files and partitions.....................................................................................................36<br>5.10. Filesystems....................................................................................................................................36<br>5.10.1. What are filesystems?..........................................................................................................36<br>5.10.2. Filesystems galore...............................................................................................................37<br>5.10.3. Which filesystem should be used?......................................................................................39<br>5.10.4. Creating a filesystem...........................................................................................................39<br>5.10.5. Filesystem block size...........................................................................................................40<br>5.10.6. Filesystem comparison........................................................................................................41<br>5.10.7. Mounting and unmounting..................................................................................................42<br>5.10.8. Filesystem Security.............................................................................................................45<br>5.10.9. Checking filesystem integrity with fsck..............................................................................45<br>5.10.10. Checking for disk errors with badblocks...........................................................................46<br>5.10.11. Fighting fragmentation?....................................................................................................46<br>5.10.12. Other tools for all filesystems...........................................................................................47<br>5.10.13. Other tools for the ext2/ext3 filesystem............................................................................47<br>5.11. Disks without filesystems.............................................................................................................48<br>5.12. Allocating disk space....................................................................................................................49<br>5.12.1. Partitioning schemes............................................................................................................49<br>5.12.2. Logical Volume Manager (LVM).......................................................................................50<br>5.12.3. Space requirements..............................................................................................................50<br>5.12.4. Examples of hard disk allocation........................................................................................50<br>5.12.5. Adding more disk space for Linux......................................................................................51<br>5.12.6. Tips for saving disk space...................................................................................................51<br>ii<br><br>The Linux System Administrator's Guide<br>Table of Contents<br>Chapter 6. Memory Management...................................................................................................................52<br>6.1. What is virtual memory?.................................................................................................................52<br>6.2. Creating a swap space.....................................................................................................................52<br>6.3. Using a swap space.........................................................................................................................53<br>6.4. Sharing swap spaces with other operating systems........................................................................54<br>6.5. Allocating swap space.....................................................................................................................55<br>6.6. The buffer cache.............................................................................................................................56<br>Chapter 7. System Monitoring.........................................................................................................................58<br>7.1. System Resources...........................................................................................................................58<br>7.1.1. The top command..................................................................................................................58<br>7.1.2. The iostat command..............................................................................................................59<br>7.1.3. The ps command...................................................................................................................60<br>7.1.4. The vmstat command............................................................................................................61<br>7.1.5. The lsof command.................................................................................................................61<br>7.1.6. Finding More Utilities...........................................................................................................62<br>7.2. Filesystem Usage............................................................................................................................62<br>7.2.1. The df command....................................................................................................................62<br>7.2.2. The du command...................................................................................................................62<br>7.2.3. Quotas....................................................................................................................................63<br>7.3. Monitoring Users............................................................................................................................63<br>7.3.1. The who command................................................................................................................63<br>7.3.2. The ps command -again!......................................................................................................64<br>7.3.3. The w command....................................................................................................................64<br>7.3.4. The skill command................................................................................................................64<br>7.3.5. nice and renice.......................................................................................................................64<br>Chapter 8. Boots And Shutdowns....................................................................................................................65<br>8.1. An overview of boots and shutdowns.............................................................................................65<br>8.2. The boot process in closer look......................................................................................................65<br>8.2.1. A Word About Bootloaders...................................................................................................67<br>8.3. More about shutdowns....................................................................................................................67<br>8.4. Rebooting........................................................................................................................................68<br>8.5. Single user mode.............................................................................................................................69<br>8.6. Emergency boot floppies................................................................................................................69<br>Chapter 9. init....................................................................................................................................................70<br>9.1. init comes first................................................................................................................................70<br>9.2. Configuring init to start getty: the/etc/inittab file..........................................................................70<br>9.3. Run levels.......................................................................................................................................71<br>9.4. Special configuration in/etc/inittab................................................................................................73<br>9.5. Booting in single user mode...........................................................................................................73<br>Chapter 10. Logging In And Out.....................................................................................................................75<br>10.1. Logins via terminals......................................................................................................................75<br>10.2. Logins via the network..................................................................................................................76<br>10.3. What login does............................................................................................................................77<br>10.4. X and xdm.....................................................................................................................................78<br>iii<br><br>The Linux System Administrator's Guide<br>Table of Contents<br>Chapter 10. Logging In And Out<br>10.5. Access control...............................................................................................................................78<br>10.6. Shell startup..................................................................................................................................78<br>Chapter 11. Managing user accounts..............................................................................................................79<br>11.1. What's an account?........................................................................................................................79<br>11.2. Creating a user..............................................................................................................................79<br>11.2.1./etc/passwd and other informative files...............................................................................79<br>11.2.2. Picking numeric user and group ids....................................................................................80<br>11.2.3. Initial environment: /etc/skel...............................................................................................80<br>11.2.4. Creating a user by hand.......................................................................................................80<br>11.3. Changing user properties..............................................................................................................81<br>11.4. Removing a user...........................................................................................................................81<br>11.5. Disabling a user temporarily.........................................................................................................82<br>Chapter 12. Backups.........................................................................................................................................83<br>12.1. On the importance of being backed up.........................................................................................83<br>12.2. Selecting the backup medium.......................................................................................................83<br>12.3. Selecting the backup tool..............................................................................................................84<br>12.4. Simple backups.............................................................................................................................85<br>12.4.1. Making backups with tar.....................................................................................................85<br>12.4.2. Restoring files with tar........................................................................................................86<br>12.5. Multilevel backups........................................................................................................................87<br>12.6. What to back up............................................................................................................................88<br>12.7. Compressed backups.....................................................................................................................89<br>Chapter 13. Task Automation --To Be Added.............................................................................................90<br>Chapter 14. Keeping Time...............................................................................................................................91<br>14.1. The concept of localtime...............................................................................................................91<br>14.2. The hardware and software clocks................................................................................................92<br>14.3. Showing and setting time..............................................................................................................92<br>14.4. When the clock is wrong...............................................................................................................93<br>14.5. NTP - Network Time Protocol.....................................................................................................93<br>14.6. Basic NTP configuration...............................................................................................................94<br>14.7. NTP Toolkit..................................................................................................................................95<br>14.8. Some known NTP servers.............................................................................................................97<br>14.9. NTP Links.....................................................................................................................................97<br>Chapter 15. System Logs --To Be Added......................................................................................................98<br>Chapter 16. System Updates --To Be Added................................................................................................99<br>Chapter 17. The Linux Kernel Source..........................................................................................................100<br>Chapter 18. Finding Help...............................................................................................................................101<br>18.1. Newsgroups and Mailing Lists...................................................................................................101<br>18.1.1. Finding The Right Forum..................................................................................................101<br>iv<br><br>The Linux System Administrator's Guide<br>Table of Contents<br>Chapter 18. Finding Help<br>18.1.2. Before You Post................................................................................................................101<br>18.1.3. Writing Your Post.............................................................................................................101<br>18.1.4. Formatting Your Post........................................................................................................102<br>18.1.5. Follow Up..........................................................................................................................102<br>18.1.6. More Information..............................................................................................................102<br>18.2. IRC..............................................................................................................................................102<br>18.2.1. Colours..............................................................................................................................103<br>18.2.2. Be Polite............................................................................................................................103<br>18.2.3. Type Properly, in English..................................................................................................103<br>18.2.4. Port scanning.....................................................................................................................103<br>18.2.5. Keep it in the Channel.......................................................................................................103<br>18.2.6. Stay On Topic....................................................................................................................104<br>18.2.7. CTCPs...............................................................................................................................104<br>18.2.8. Hacking, Cracking, Phreaking, Warezing.........................................................................104<br>18.2.9. Round Up..........................................................................................................................104<br>18.2.10. Further Reading...............................................................................................................104<br>Appendix A. GNU Free Documentation License.........................................................................................105<br>A.1. PREAMBLE................................................................................................................................105<br>A.2. APPLICABILITY AND DEFINITIONS....................................................................................105<br>A.3. VERBATIM COPYING..............................................................................................................106<br>A.4. COPYING IN QUANTITY.........................................................................................................106<br>A.5. MODIFICATIONS......................................................................................................................107<br>A.6. COMBINING DOCUMENTS.....................................................................................................108<br>A.7. COLLECTIONS OF DOCUMENTS..........................................................................................109<br>A.8. AGGREGATION WITH INDEPENDENT WORKS.................................................................109<br>A.9. TRANSLATION..........................................................................................................................109<br>A.10. TERMINATION........................................................................................................................109<br>A.11. FUTURE REVISIONS OF THIS LICENSE.............................................................................110<br>A.12. ADDENDUM: How to use this License for your documents...................................................110<br>Glossary (DRAFT, but not for long hopefully)............................................................................................111<br>Index-Draft..........................................................................................................................................115<br>A....................................................................................................................................................115<br>B....................................................................................................................................................115<br>C....................................................................................................................................................115<br>D....................................................................................................................................................116<br>E.....................................................................................................................................................117<br>F.....................................................................................................................................................117<br>G....................................................................................................................................................120<br>H....................................................................................................................................................120<br>I......................................................................................................................................................120<br>K....................................................................................................................................................120<br>L.....................................................................................................................................................121<br>M...................................................................................................................................................121<br>N....................................................................................................................................................121<br>O....................................................................................................................................................121<br>v<br><br>The Linux System Administrator's Guide<br>Table of Contents<br>Glossary (DRAFT, but not for long hopefully)<br>P.....................................................................................................................................................121<br>R....................................................................................................................................................122<br>S.....................................................................................................................................................122<br>T.....................................................................................................................................................122<br>V....................................................................................................................................................122<br>W...................................................................................................................................................122 <br> <br>





剩余129页未读,继续阅读











评论0