[
Lev
el-Be
gin
ner
]
Li
nuxS
erver
F
undament
als
S
tud
entMa
ter
ial
(
Vol
ume1-No
tesa
ndWo
rkb
ook
)
L
INUX
h
ttp
://
mic
rol
in
k.e
du.
et/
Table of Contents
1. Introduction to Unix and Linux ...................................................................... 1
1.1. Unix History ............................................................................................ 1
1.2. Licensing .................................................................................................. 3
1.3. Current Distributions ............................................................................... 4
2. Getting help ..................................................................................................... 11
2.1. man pages .............................................................................................. 11
2.2. online help ............................................................................................. 13
3. Working with directories ............................................................................... 15
3.1. working with directories ........................................................................ 15
3.2. practice : working with directories ........................................................ 21
3.3. solution : working with directories ........................................................ 22
4. Working with files .......................................................................................... 24
4.1. working with files .................................................................................. 24
4.2. practice : working with files .................................................................. 30
4.3. solution : working with files .................................................................. 31
5. Working with filecontents .............................................................................. 33
5.1. file contents ............................................................................................ 33
5.2. practice : file contents ............................................................................ 37
5.3. solution : file contents ............................................................................ 38
6. The Linux file system tree ............................................................................. 39
6.1. file system tree ....................................................................................... 39
6.2. practice : file system tree ....................................................................... 51
6.3. solution : file system tree ....................................................................... 53
7. Introduction to the shell ................................................................................. 55
7.1. introduction to the shell ......................................................................... 55
7.2. practice: introduction to the shell .......................................................... 60
7.3. solution: introduction to the shell .......................................................... 61
8. Shell control operators ................................................................................... 63
8.1. control operators .................................................................................... 63
8.2. practice: control operators ..................................................................... 66
8.3. solution: control operators ..................................................................... 67
9. Shell variables ................................................................................................. 68
9.1. shell variables ........................................................................................ 68
9.2. practice: shell variables .......................................................................... 73
9.3. solution: shell variables ......................................................................... 74
10. Shell arguments ............................................................................................. 76
10.1. shell arguments .................................................................................... 76
10.2. practice: shell arguments ..................................................................... 79
10.3. solution: shell arguments ..................................................................... 80
11. Shell history ................................................................................................... 81
11.1. shell history .......................................................................................... 81
12. Shell globbing ................................................................................................ 84
12.1. file globbing ......................................................................................... 84
12.2. practice : shell globbing, options and history ...................................... 87
iii
Linux Fundamentals
12.3. solution: shell globbing, options and history ....................................... 89
13. Shell I/O redirection ..................................................................................... 91
13.1. shell i/o redirection .............................................................................. 91
13.2. practice : i/o redirection ....................................................................... 95
13.3. solution : i/o redirection ....................................................................... 96
14. Pipes and filters ............................................................................................. 97
14.1. pipes ..................................................................................................... 97
14.2. filters .................................................................................................... 98
14.3. some pipeline examples ..................................................................... 105
14.4. practice : pipes and filters .................................................................. 107
14.5. solution : pipes and filters .................................................................. 108
15. Basic Unix tools ........................................................................................... 110
15.1. common tools ..................................................................................... 110
15.2. compression tools ............................................................................... 113
15.3. practice : basic Unix tools .................................................................. 115
15.4. solution : basic Unix tools ................................................................. 116
16. Introduction to vi ........................................................................................ 118
16.1. about vi(m) ......................................................................................... 118
16.2. introduction to using vi(m) ................................................................ 118
16.3. practice : vi(m) ................................................................................... 125
16.4. solution : vi(m) ................................................................................... 126
17. Understanding scripts ................................................................................. 127
17.1. introduction to scripting ..................................................................... 127
17.2. practice : introduction to scripting ..................................................... 130
17.3. solution : introduction to scripting ..................................................... 131
17.4. scripting tests and loops ..................................................................... 132
17.5. practice : scripting tests and loops ..................................................... 135
17.6. solution : scripting tests and loops ..................................................... 136
17.7. parameters and options ...................................................................... 138
17.8. practice : parameters and options ....................................................... 142
17.9. solution : parameters and options ...................................................... 143
17.10. more scripting .................................................................................. 144
17.11. practice : more scripting ................................................................... 147
17.12. solution : more scripting .................................................................. 148
18. Introduction to users .................................................................................. 150
18.1. identify yourself ................................................................................. 150
18.2. users ................................................................................................... 152
18.3. passwords ........................................................................................... 154
18.4. home directories ................................................................................. 159
18.5. user shell ............................................................................................ 160
18.6. switch users with su ........................................................................... 161
18.7. run a program as another user ........................................................... 162
18.8. practice: users ..................................................................................... 164
18.9. solution: users .................................................................................... 165
18.10. shell environment ............................................................................. 167
19. Introduction to groups ............................................................................... 170
19.1. about groups ....................................................................................... 170
19.2. groupadd ............................................................................................. 170
iv