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