Introduction-To-Linux.pdf

(1563 KB) Pobierz
Introduction to Linux
Introduction to Linux
A Hands on Guide
Machtelt Garrels
Xalasys.com
Version 1.17 20050301 Edition
Copyright © 2002, 2003, 2004, 2005 Machtelt Garrels
First published December 2002
37378835.002.png
Introduction to Linux
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 .........................................................................................................................4
8. What do you need?. ..............................................................................................................................5
9. Conventions used in this document. ....................................................................................................5
10. Organization of this documen. ..........................................................................................................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
i
37378835.003.png
Introduction to Linux
Table of Contents
2.5.1. Connecting and disconnecting.. .............................................................................................29
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. .....................................................................................................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. ........................................................................................................36
3.2. Orientation in the file system. .........................................................................................................39
3.2.1. The path. ................................................................................................................................39
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. ...................................................................................................45
3.2.6. The most common variable files. ..........................................................................................46
3.3. Manipulating files. ..........................................................................................................................47
3.3.1. Viewing file properties. .........................................................................................................47
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. ...............................................................................................................................61
3.5. Summary. ........................................................................................................................................66
3.6. Exercises. ........................................................................................................................................68
3.6.1. Partitions. ...............................................................................................................................68
3.6.2. Paths. .....................................................................................................................................68
3.6.3. Tour of the system. ................................................................................................................68
3.6.4. Manipulating files.. ................................................................................................................69
3.6.5. File permissions. ....................................................................................................................69
Chapter 4. Processes. ........................................................................................................................................70
4.1. Processes inside out. .......................................................................................................................70
4.1.1. Multi−user and multi−tasking. ..............................................................................................70
4.1.2. Process types. ........................................................................................................................70
4.1.3. Process attributes. ..................................................................................................................72
4.1.4. Displaying process information. ............................................................................................73
4.1.5. Life and death of a process. ...................................................................................................75
4.1.6. SUID and SGID. ....................................................................................................................77
4.2. Boot process, Init and shutdown. ....................................................................................................79
4.2.1. Introduction. ..........................................................................................................................79
4.2.2. The boot process. ...................................................................................................................79
4.2.3. GRUB features. .....................................................................................................................79
ii
37378835.004.png
Introduction to Linux
Table of Contents
4.2.4. Init. ........................................................................................................................................80
4.2.5. Init run levels. ........................................................................................................................82
4.2.6. Shutdown. ..............................................................................................................................83
4.3. Managing processes. .......................................................................................................................83
4.3.1. Work for the system admin. ..................................................................................................83
4.3.2. How long does it take?. .........................................................................................................84
4.3.3. Performance.. .........................................................................................................................85
4.3.4. Load. ......................................................................................................................................85
4.3.5. Can I do anything as a user?. .................................................................................................85
4.4. Scheduling processes. .....................................................................................................................90
4.4.1. Use that idle time!. ................................................................................................................90
4.4.2. The sleep command. ..............................................................................................................90
4.4.3. The at command. ...................................................................................................................91
4.4.4. Cron and crontab. ..................................................................................................................91
4.5. Summary. ........................................................................................................................................93
4.6. Exercises. ........................................................................................................................................94
4.6.1. General. .................................................................................................................................94
4.6.2. Booting, init etc.. ...................................................................................................................94
4.6.3. Scheduling. ............................................................................................................................95
Chapter 5. I/O redirection. ...............................................................................................................................96
5.1. What are standard input and standard output?. ...............................................................................96
5.1.1. The redirection operators.. .....................................................................................................96
5.1.2. Advanced redirection features. ..............................................................................................99
5.1.3. Filters. ..................................................................................................................................100
5.2. Summary. ......................................................................................................................................101
5.3. Exercises. ......................................................................................................................................101
Chapter 6. Text editors. ..................................................................................................................................103
6.1. Text editors. ..................................................................................................................................103
6.1.1. Why should I use an editor?. ...............................................................................................103
6.1.2. Which editor should I use?. .................................................................................................103
6.2. Using the Vim editor. ....................................................................................................................105
6.2.1. Two modes. .........................................................................................................................105
6.2.2. Basic commands. .................................................................................................................105
6.2.3. The easy way. ......................................................................................................................106
6.3. Linux in the office. ........................................................................................................................106
6.3.1. History. ................................................................................................................................106
6.3.2. Suites and programs. ...........................................................................................................107
6.3.3. Remarks. ..............................................................................................................................107
6.4. Summary. ......................................................................................................................................108
6.5. Exercises. ......................................................................................................................................108
Chapter 7. Home sweet /home. ......................................................................................................................109
7.1. General good housekeeping. .........................................................................................................109
7.1.1. Introduction. ........................................................................................................................109
7.1.2. Make space. .........................................................................................................................109
iii
37378835.005.png
Introduction to Linux
Table of Contents
7.2. Your text environment. .................................................................................................................112
7.2.1. Environment variables. ........................................................................................................112
7.2.2. Shell setup files. ..................................................................................................................114
7.2.3. A typical set of setup files. ..................................................................................................115
7.2.4. The Bash prompt. ................................................................................................................117
7.2.5. Shell scripts. ........................................................................................................................118
7.3. The graphical environment. ..........................................................................................................121
7.3.1. Introduction. ........................................................................................................................121
7.3.2. The X Window System. ......................................................................................................121
7.3.3. X server configuration. ........................................................................................................123
7.4. Sound and video. ...........................................................................................................................124
7.4.1. Sound card configuration. ...................................................................................................124
7.4.2. If automatic sound card detection fails. ...............................................................................124
7.4.3. Sound and video playing. ....................................................................................................124
7.5. Region specific settings. ...............................................................................................................127
7.5.1. Keyboard setup. ...................................................................................................................127
7.5.2. Fonts. ...................................................................................................................................127
7.5.3. Time zone. ...........................................................................................................................127
7.5.4. Language. ............................................................................................................................128
7.5.5. Specific information for Belgium.. ......................................................................................128
7.5.6. Other countries. ...................................................................................................................128
7.6. Installing new software. ................................................................................................................128
7.6.1. General. ...............................................................................................................................128
7.6.2. Package formats. .................................................................................................................129
7.6.3. Automating package management and updates. .................................................................131
7.6.4. Upgrading your kerne.. .......................................................................................................133
7.6.5. Installing extra packages from the installation CDs. ...........................................................133
7.7. Summary. ......................................................................................................................................134
7.8. Exercises. ......................................................................................................................................135
7.8.1. Shell environmen.. ..............................................................................................................135
7.8.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
iv
37378835.001.png
Zgłoś jeśli naruszono regulamin