Table of Contents
Introduction.........................................................................................................................................................1
1. Why this guide?...................................................................................................................................1
2. Who should read this book?.................................................................................................................1
3. New versions and availability..............................................................................................................1
4. Revision History..................................................................................................................................2
5. Contributions.......................................................................................................................................3
6. Feedback..............................................................................................................................................3
7. Copyright information.........................................................................................................................3
8. What do you need?...............................................................................................................................4
9. Conventions used in this document.....................................................................................................4
10. Organization of this document...........................................................................................................5
Chapter 1. What is Linux?.................................................................................................................................7
1.1. History..............................................................................................................................................7
1.1.1. UNIX.......................................................................................................................................7
1.1.2. Linus and Linux.......................................................................................................................8
1.1.3. Current application of Linux systems.....................................................................................9
1.2. The user interface..............................................................................................................................9
1.2.1. Is Linux difficult?....................................................................................................................9
1.2.2. Linux for non-experienced users...........................................................................................10
1.3. Does Linux have a future?..............................................................................................................10
1.3.1. Open Source..........................................................................................................................10
1.3.2. Ten years of experience at your service................................................................................11
1.4. Properties of Linux.........................................................................................................................12
1.4.1. Linux Pros.............................................................................................................................12
1.4.2. Linux Cons............................................................................................................................13
1.5. Linux Flavors..................................................................................................................................14
1.5.1. Linux and GNU.....................................................................................................................14
1.5.2. GNU/Linux............................................................................................................................15
1.5.3. Which distribution should I install?......................................................................................15
1.6. Summary.........................................................................................................................................16
1.7. Exercises.........................................................................................................................................16
Chapter 2. Quickstart.......................................................................................................................................18
2.1. Logging in, activating the user interface and logging out..............................................................18
2.1.1. Introduction...........................................................................................................................18
2.1.2. Graphical mode.....................................................................................................................18
2.1.3. Text mode..............................................................................................................................20
2.2. Absolute basics...............................................................................................................................21
2.2.1. The commands......................................................................................................................21
2.2.2. General remarks....................................................................................................................21
2.2.3. Using Bash features...............................................................................................................22
2.3. Getting help.....................................................................................................................................23
2.3.1. Be warned..............................................................................................................................23
2.3.2. The man pages.......................................................................................................................23
2.3.3. More info...............................................................................................................................25
2.4. Summary.........................................................................................................................................28
2.5. Exercises.........................................................................................................................................29
Introduction to Linux
i
Table of Contents
Chapter 2. Quickstart
2.5.1. Connecting and disconnecting...............................................................................................29
2.5.2. Passwords..............................................................................................................................29
2.5.3. Directories.............................................................................................................................30
2.5.4. Files.......................................................................................................................................30
2.5.5. Getting help...........................................................................................................................31
Chapter 3. About files and the file system......................................................................................................32
3.1. General overview of the Linux file system.....................................................................................32
3.1.1. Files.......................................................................................................................................32
3.1.2. About partitioning.................................................................................................................33
3.1.3. More file system layout.........................................................................................................37
3.2. Orientation in the file system..........................................................................................................40
3.2.1. The path.................................................................................................................................40
3.2.2. Absolute and relative paths...................................................................................................41
3.2.3. The most important files and directories...............................................................................41
3.2.4. The most important configuration files.................................................................................44
3.2.5. The most common devices....................................................................................................46
3.2.6. The most common variable files...........................................................................................47
3.3. Manipulating files...........................................................................................................................48
3.3.1. Viewing file properties..........................................................................................................48
3.3.2. Creating and deleting files and directories............................................................................50
3.3.3. Finding files...........................................................................................................................53
3.3.4. More ways to view file content.............................................................................................57
3.3.5. Linking files..........................................................................................................................58
3.4. File security.....................................................................................................................................60
3.4.1. Access rights: Linux's first line of defense............................................................................60
3.4.2. The tools................................................................................................................................62
3.5. Summary.........................................................................................................................................67
3.6. Exercises.........................................................................................................................................68
3.6.1. Partitions................................................................................................................................68
3.6.2. Paths......................................................................................................................................68
3.6.3. Tour of the system.................................................................................................................69
3.6.4. Manipulating files..................................................................................................................69
3.6.5. File permissions.....................................................................................................................69
Chapter 4. Processes.........................................................................................................................................71
4.1. Processes inside out........................................................................................................................71
4.1.1. Multi-user and multi-tasking.................................................................................................71
4.1.2. Process types.........................................................................................................................71
4.1.3. Process attributes...................................................................................................................73
4.1.4. Displaying process information.............................................................................................74
4.1.5. Life and death of a process....................................................................................................76
4.1.6. SUID and SGID.....................................................................................................................78
4.2. Boot process, Init and shutdown.....................................................................................................80
4.2.1. Introduction...........................................................................................................................80
4.2.2. The boot process....................................................................................................................80
4.2.3. GRUB features......................................................................................................................80
Introduction to Linux
ii
Table of Contents
Chapter 4. Processes
4.2.4. Init.........................................................................................................................................81
4.2.5. Init run levels.........................................................................................................................83
4.2.6. Shutdown...............................................................................................................................84
4.3. Managing processes........................................................................................................................84
4.3.1. Work for the system admin...................................................................................................84
4.3.2. How long does it take?..........................................................................................................85
4.3.3. Performance...........................................................................................................................86
4.3.4. Load.......................................................................................................................................86
4.3.5. Can I do anything as a user?..................................................................................................86
4.4. Scheduling processes......................................................................................................................91
4.4.1. Use that idle time!.................................................................................................................91
4.4.2. The sleep command...............................................................................................................91
4.4.3. The at command....................................................................................................................92
4.4.4. Cron and crontab...................................................................................................................92
4.5. Summary.........................................................................................................................................94
4.6. Exercises.........................................................................................................................................95
4.6.1. General..................................................................................................................................95
4.6.2. Booting, init etc.....................................................................................................................95
4.6.3. Scheduling.............................................................................................................................96
Chapter 5. I/O redirection................................................................................................................................97
5.1. Simple redirections.........................................................................................................................97
5.1.1. What are standard input and standard output?......................................................................97
5.1.2. The redirection operators.......................................................................................................97
5.2. Advanced redirection features......................................................................................................100
5.2.1. Use of file descriptors..........................................................................................................100
5.2.2. Examples.............................................................................................................................101
5.3. Filters............................................................................................................................................101
5.3.1. More about grep..................................................................................................................102
5.3.2. Filtering output....................................................................................................................102
5.4. Summary.......................................................................................................................................103
5.5. Exercises.......................................................................................................................................103
Chapter 6. Text editors...................................................................................................................................105
6.1. Text editors...................................................................................................................................105
6.1.1. Why should I use an editor?................................................................................................105
6.1.2. Which editor should I use?..................................................................................................105
6.2. Using the Vim editor.....................................................................................................................106
6.2.1. Two modes..........................................................................................................................106
6.2.2. Basic commands..................................................................................................................107
6.2.3. The easy way.......................................................................................................................108
6.3. Linux in the office.........................................................................................................................108
6.3.1. History.................................................................................................................................108
6.3.2. Suites and programs............................................................................................................108
6.3.3. Remarks...............................................................................................................................109
6.4. Summary.......................................................................................................................................109
6.5. Exercises.......................................................................................................................................110
Introduction to Linux
iii
Table of Contents
Chapter 7. Home sweet /home.......................................................................................................................111
7.1. General good housekeeping..........................................................................................................111
7.1.1. Introduction.........................................................................................................................111
7.1.2. Make space..........................................................................................................................111
7.2. Your text environment..................................................................................................................114
7.2.1. Environment variables.........................................................................................................114
7.2.2. Shell setup files...................................................................................................................116
7.2.3. A typical set of setup files...................................................................................................117
7.2.4. The Bash prompt.................................................................................................................120
7.2.5. Shell scripts.........................................................................................................................121
7.3. The graphical environment...........................................................................................................123
7.3.1. Introduction.........................................................................................................................123
7.3.2. The X Window System.......................................................................................................124
7.3.3. X server configuration.........................................................................................................125
7.4. Region specific settings................................................................................................................126
7.4.1. Keyboard setup....................................................................................................................126
7.4.2. Fonts....................................................................................................................................126
7.4.3. Date and time zone..............................................................................................................127
7.4.4. Language.............................................................................................................................127
7.4.5. Country-specific Information..............................................................................................128
7.5. Installing new software.................................................................................................................128
7.5.1. General................................................................................................................................128
7.5.2. Package formats..................................................................................................................128
7.5.3. Automating package management and updates..................................................................131
7.5.4. Upgrading your kernel.........................................................................................................132
7.5.5. Installing extra packages from the installation CDs............................................................133
7.6. Summary.......................................................................................................................................134
7.7. Exercises.......................................................................................................................................135
7.7.1. Shell environment................................................................................................................135
7.7.2. Graphical environment........................................................................................................136
Chapter 8. Printers and printing...................................................................................................................137
8.1. Printing files..................................................................................................................................137
8.1.1. Command line printing........................................................................................................137
8.1.2. Formatting...........................................................................................................................138
8.2. The server side..............................................................................................................................139
8.2.1. General................................................................................................................................139
8.2.2. Graphical printer configuration...........................................................................................140
8.2.3. Buying a printer for Linux...................................................................................................140
8.3. Print problems...............................................................................................................................140
8.3.1. Wrong file............................................................................................................................140
8.3.2. My print hasn't come out.....................................................................................................140
8.4. Summary.......................................................................................................................................142
8.5. Exercises.......................................................................................................................................142
Chapter 9. Fundamental Backup Techniques..............................................................................................144
9.1. Introduction...................................................................................................................................144
9.1.1. Preparing your data.............................................................................................................144
Introduction to Linux
iv