OReilly - Linux Cookbook (2004).pdf

(8284 KB) Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The Linux Cookbook: Tips and Techniques for Everyday Use:
The Linux Cookbook: Tips and Techniques for Everyday Use:
Table of Contents
The Linux Cookbook: Tips and Techniques for Everyday Use .....................................................................1
Preface. ...............................................................................................................................................................3
1.0 Format of Recipes . ...........................................................................................................................4
1.1 Assumptions, Scope, and Exclusions ..............................................................................................5
1.2 Typographical Conventions . ............................................................................................................6
1.3 Versions, Latest Edition, and Errata . ...............................................................................................7
1.4 Acknowledgments. ...........................................................................................................................8
PART ONE: Working with Linux. ................................................................................................................10
2. Introduction. ................................................................................................................................................11
2.1 Background and History . ...............................................................................................................11
2.1.1 What's Unix?. .................................................................................................................11
2.1.2 What's Free Software? . ..................................................................................................12
2.1.3 What's Open Source? . ....................................................................................................13
2.1.4 What's Linux? . ...............................................................................................................14
2.1.5 What's Debian? . .............................................................................................................14
2.1.6 Unix and the Tools Philosophy. .....................................................................................15
2.2 What to Try First. ...........................................................................................................................17
2.3 If You Need More Help . ................................................................................................................18
3. What Every Linux User Knows. ................................................................................................................20
3.1 Controlling Power to the System . ..................................................................................................20
3.1.1 Powering Up the System. ...............................................................................................21
3.1.2 Turning Off the System . ................................................................................................21
3.2 Accounts and Privileges. ................................................................................................................21
3.2.1 Logging In to the System. ..............................................................................................22
3.2.2 Logging Out of the System . ...........................................................................................24
3.3 Console Basics . ..............................................................................................................................24
3.3.1 Switching between Consoles . ........................................................................................25
3.3.2 Scrolling the Console Text . ...........................................................................................26
3.3.3 Keys for Console Manipulation . ....................................................................................26
3.4 Running a Command . ....................................................................................................................27
3.5 Changing Your Password . .............................................................................................................28
3.6 Listing User Activity . ....................................................................................................................29
3.6.1 Listing Your Username. .................................................................................................29
3.6.2 Listing Who Is on the System. .......................................................................................30
3.6.3 Listing Who Is on and What They're Doing . .................................................................30
3.6.4 Listing the Last Times a User Logged In . .....................................................................31
3.7 Listing System Activity . ................................................................................................................32
3.7.1 Listing Your Current Processes . ....................................................................................32
3.7.2 Listing All of a User's Processes . ..................................................................................33
3.7.3 Listing All Processes on the System. .............................................................................33
3.7.4 Listing Processes by Name or Number.. ........................................................................34
3.8 Help Facilities . ...............................................................................................................................34
3.8.1 Finding the Right Tool for the Job. ................................................................................35
i
826863532.129.png 826863532.140.png 826863532.151.png 826863532.162.png 826863532.001.png 826863532.012.png 826863532.023.png 826863532.034.png 826863532.044.png 826863532.055.png 826863532.066.png 826863532.077.png 826863532.088.png 826863532.089.png 826863532.090.png 826863532.091.png 826863532.092.png 826863532.093.png 826863532.094.png 826863532.095.png 826863532.096.png 826863532.097.png 826863532.098.png 826863532.099.png 826863532.100.png 826863532.101.png 826863532.102.png 826863532.103.png 826863532.104.png 826863532.105.png 826863532.106.png 826863532.107.png 826863532.108.png 826863532.109.png 826863532.110.png 826863532.111.png 826863532.112.png 826863532.113.png 826863532.114.png 826863532.115.png 826863532.116.png 826863532.117.png
 
The Linux Cookbook: Tips and Techniques for Everyday Use:
Table of Contents
3.8.2 Listing a Description of a Program. ...............................................................................36
3.8.3 Listing the Usage of a Tool.. ..........................................................................................36
3.8.4 Reading a Page from the System Manual . .....................................................................37
3.8.5 Using the GNU Info System . .........................................................................................38
3.8.6 Reading System Documentation and Help Files ...........................................................40
4. The Shell . .....................................................................................................................................................42
4.1 Keys for Command Line Editing. ..................................................................................................42
4.1.1 Passing Special Characters to Commands . ....................................................................44
4.1.2 Letting the Shell Complete What You Type .................................................................45
4.1.3 Repeating the Last Command You Typed. ....................................................................46
4.1.4 Running a List of Commands . .......................................................................................47
4.2 Redirecting Input and Output. ........................................................................................................47
4.2.1 Redirecting Input to a File . ............................................................................................48
4.2.2 Redirecting Output to a File.. .........................................................................................48
4.2.3 Redirecting Error Messages to a File. ............................................................................49
4.2.4 Redirecting Output to Another Command's Input . ........................................................49
4.3 Managing Jobs . ..............................................................................................................................50
4.3.1 Suspending a Job ...........................................................................................................50
4.3.2 Putting a Job in the Background . ...................................................................................51
4.3.3 Putting a Job in the Foreground . ....................................................................................52
4.3.4 Listing Your Jobs. ..........................................................................................................52
4.3.5 Stopping a Job.. ..............................................................................................................53
4.4 Command History. .........................................................................................................................53
4.4.1 Viewing Your Command History. .................................................................................54
4.4.2 Specifying a Command from Your History.. .................................................................55
4.5 Recording a Shell Session. .............................................................................................................55
4.6 Customizing Your Shell. ................................................................................................................56
4.6.1 Changing the Shell Prompt . ...........................................................................................57
4.6.2 Making a Command Alias . ............................................................................................58
4.6.3 Adding to Your Path . .....................................................................................................59
4.6.4 Customizing Future Shells. ............................................................................................59
5. The X Window System ...............................................................................................................................62
5.1 Running X . .....................................................................................................................................62
5.1.1 Starting X . ......................................................................................................................65
5.1.2 Stopping X . ....................................................................................................................65
5.2 Running a Program in X . ...............................................................................................................66
5.2.1 Specifying Window Size and Location . ........................................................................67
5.2.2 Specifying Window Colors.. ..........................................................................................69
5.2.3 Specifying Window Font . ..............................................................................................69
5.2.4 Specifying Additional Window Attributes . ...................................................................70
5.3 Manipulating X Client Windows . ..................................................................................................70
5.3.1 Moving a Window . ........................................................................................................71
5.3.2 Resizing a Window . .......................................................................................................71
5.3.3 Destroying a Window . ...................................................................................................71
5.3.4 Minimizing a Window . ..................................................................................................72
ii
826863532.118.png 826863532.119.png 826863532.120.png 826863532.121.png 826863532.122.png 826863532.123.png 826863532.124.png 826863532.125.png 826863532.126.png 826863532.127.png 826863532.128.png 826863532.130.png 826863532.131.png 826863532.132.png 826863532.133.png 826863532.134.png 826863532.135.png 826863532.136.png 826863532.137.png 826863532.138.png 826863532.139.png 826863532.141.png 826863532.142.png 826863532.143.png 826863532.144.png 826863532.145.png 826863532.146.png 826863532.147.png 826863532.148.png 826863532.149.png 826863532.150.png 826863532.152.png 826863532.153.png 826863532.154.png 826863532.155.png 826863532.156.png 826863532.157.png 826863532.158.png 826863532.159.png 826863532.160.png 826863532.161.png 826863532.163.png 826863532.164.png 826863532.165.png
 
The Linux Cookbook: Tips and Techniques for Everyday Use:
Table of Contents
5.3.5 Maximizing a Window . .................................................................................................72
5.4 Moving around the Desktop. ..........................................................................................................72
5.5 Running a Shell in X. .....................................................................................................................73
5.6 Configuring X . ...............................................................................................................................74
5.6.1 Switching between Video Modes . .................................................................................74
5.6.2 Running X Clients Automatically.. ................................................................................75
5.6.3 Changing the Root Window Parameters.. ......................................................................75
5.6.4 Choosing a Window Manager . ......................................................................................76
PART TWO: Files.. .........................................................................................................................................78
6. Files and Directories . ..................................................................................................................................79
6.1 Naming Files and Directories . .......................................................................................................83
6.1.1 Making an Empty File . ..................................................................................................84
6.1.2 Making a Directory . .......................................................................................................84
6.1.3 Making a Directory Tree.. ..............................................................................................85
6.2 Changing Directories . ....................................................................................................................85
6.2.1 Changing to Your Home Directory ...............................................................................86
6.2.2 Changing to the Last Directory You Visited . ................................................................86
6.2.3 Getting the Name of the Current Directory . ..................................................................86
6.3 Listing Directories . ........................................................................................................................87
6.3.1 Listing File Attributes . ...................................................................................................88
6.3.2 Listing Directories Recursively . ....................................................................................89
6.3.3 Listing Newest Files First . .............................................................................................90
6.3.4 Listing Hidden Files.. .....................................................................................................90
6.3.5 Listing Directories in Color . ..........................................................................................91
6.3.6 Listing Directory Tree Graphs . ......................................................................................91
6.3.7 Additional Directory Listing Options . ...........................................................................92
6.4 Copying Files and Directories . ......................................................................................................93
6.5 Moving Files and Directories.. .......................................................................................................94
6.5.1 Changing File Names to Lowercase . .............................................................................95
6.5.2 Renaming Multiple Files with the Same Extension.. .....................................................96
6.6 Removing Files and Directories.. ...................................................................................................97
6.6.1 Removing a File with a Strange Name . .........................................................................98
6.6.2 A Safe Way to Remove a File .......................................................................................99
6.7 Giving a File More than One Name. ..............................................................................................99
6.8 Specifying File Names with Patterns . ..........................................................................................100
6.9 Browsing Files . ............................................................................................................................102
7. Sharing Files . .............................................................................................................................................103
7.1 Groups and How to Work in Them. .............................................................................................103
7.1.1 Listing the Groups a User Belongs To.. .......................................................................103
7.1.2 Listing the Members of a Group. .................................................................................104
7.2 File Ownership. ............................................................................................................................105
7.2.1 Determining the Ownership of a File . .........................................................................105
7.2.2 Changing the Ownership of a File . ..............................................................................105
7.3 Controlling Access to Files. .........................................................................................................106
iii
826863532.166.png 826863532.167.png 826863532.168.png 826863532.169.png 826863532.170.png 826863532.171.png 826863532.002.png 826863532.003.png 826863532.004.png 826863532.005.png 826863532.006.png 826863532.007.png 826863532.008.png 826863532.009.png 826863532.010.png 826863532.011.png 826863532.013.png 826863532.014.png 826863532.015.png 826863532.016.png 826863532.017.png 826863532.018.png 826863532.019.png 826863532.020.png 826863532.021.png 826863532.022.png 826863532.024.png 826863532.025.png 826863532.026.png 826863532.027.png 826863532.028.png 826863532.029.png 826863532.030.png 826863532.031.png 826863532.032.png 826863532.033.png 826863532.035.png 826863532.036.png 826863532.037.png 826863532.038.png 826863532.039.png 826863532.040.png 826863532.041.png
 
The Linux Cookbook: Tips and Techniques for Everyday Use:
Table of Contents
7.3.1 Listing the Permissions of a File. .................................................................................107
7.3.2 Changing the Permissions of a File . ............................................................................108
7.3.3 Write−Protecting a File. ...............................................................................................108
7.3.4 Making a File Private. ..................................................................................................109
7.3.5 Making a File Public. ...................................................................................................109
7.3.6 Making a File Executable . ...........................................................................................110
8. Finding Files . .............................................................................................................................................111
8.1 Finding All Files That Match a Pattern . ......................................................................................111
8.2 Finding Files in a Directory Tree. ................................................................................................112
8.2.1 Finding Files in a Directory Tree by Name . ................................................................112
8.2.2 Finding Files in a Directory Tree by Size. ...................................................................114
8.2.3 Finding Files in a Directory Tree by Modification Time . ...........................................115
8.2.4 Finding Files in a Directory Tree by Owner. ...............................................................116
8.2.5 Running Commands on the Files You Find.. ...............................................................117
8.2.6 Finding Files by Multiple Criteria . ..............................................................................117
8.3 Finding Files in Directory Listings . .............................................................................................120
8.3.1 Finding the Largest Files in a Directory . .....................................................................120
8.3.2 Finding the Smallest Files in a Directory . ...................................................................121
8.3.3 Finding the Smallest Directories.. ................................................................................121
8.3.4 Finding the Largest Directories . ..................................................................................121
8.3.5 Finding the Number of Files in a Listing.. ...................................................................122
8.4 Finding Where a Command Is Located . ......................................................................................123
9. Managing Files . .........................................................................................................................................124
9.1 Determining File Type and Format.. ............................................................................................124
9.2 Changing File Modification Time . ..............................................................................................125
9.3 Splitting a File into Smaller Ones. ...............................................................................................126
9.4 Comparing Files. ..........................................................................................................................127
9.4.1 Determining Whether Two Files Differ.. .....................................................................127
9.4.2 Finding the Differences between Files . .......................................................................127
9.4.3 Patching a File with a Difference Report.. ...................................................................128
9.5 Compressed Files . ........................................................................................................................129
9.5.1 Compressing a File . .....................................................................................................129
9.5.2 Decompressing a File. ..................................................................................................129
9.6 File Archives. ...............................................................................................................................130
9.6.1 Creating a File Archive. ...............................................................................................131
9.6.2 Listing the Contents of an Archive . .............................................................................131
9.6.3 Extracting Files from an Archive.. ...............................................................................132
9.7 Tracking Revisions to a File . .......................................................................................................133
9.7.1 Checking In a File Revision.. .......................................................................................133
9.7.2 Checking Out a File Revision . .....................................................................................135
9.7.3 Viewing a File's Revision Log. ....................................................................................136
PART THREE: Text. ....................................................................................................................................137
10. Viewing Text. ...........................................................................................................................................138
iv
826863532.042.png 826863532.043.png 826863532.045.png 826863532.046.png 826863532.047.png 826863532.048.png 826863532.049.png 826863532.050.png 826863532.051.png 826863532.052.png 826863532.053.png 826863532.054.png 826863532.056.png 826863532.057.png 826863532.058.png 826863532.059.png 826863532.060.png 826863532.061.png 826863532.062.png 826863532.063.png 826863532.064.png 826863532.065.png 826863532.067.png 826863532.068.png 826863532.069.png 826863532.070.png 826863532.071.png 826863532.072.png 826863532.073.png 826863532.074.png 826863532.075.png 826863532.076.png 826863532.078.png 826863532.079.png 826863532.080.png 826863532.081.png 826863532.082.png 826863532.083.png 826863532.084.png 826863532.085.png 826863532.086.png 826863532.087.png
 
Zgłoś jeśli naruszono regulamin