Beruflich Dokumente
Kultur Dokumente
n + 1, Inc
May 10, 2010
Copyright (c) 2010 n + 1, Inc. Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or any later version published
by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no BackCover Texts. A copy of the license is included in the section entitled GNU Free Documentation
License.
Page 2
c
2010
n + 1, Inc All Rights Reserved
Contents
1
Introduction to Linux
11
1.1
12
1.1.1
13
1.1.2
14
1.1.3
15
1.1.4
Linux Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
17
1.2.1
Multi-user Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
1.2.2
User Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
1.2.3
System Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
1.2.4
21
1.3
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
1.4
23
1.4.1
su . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24
1.4.2
passwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
1.2
1.5
2
27
2.1
28
2.1.1
29
CONTENTS
2.2
2.3
2.4
2.5
2.6
3
Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
2.2.1
ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
33
2.3.1
cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
34
2.3.2
mv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
35
2.3.3
rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
Viewing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37
2.4.1
38
2.4.2
39
2.4.3
wc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
40
41
2.5.1
42
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
43
45
3.1
History of vim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
46
3.2
Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
47
3.3
48
3.4
Movement commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
49
3.5
Insertion commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
50
3.6
Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
51
3.7
52
3.8
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
53
55
4.1
56
4.1.1
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
57
4.1.2
Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
58
Page 4
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
4.1.3
Pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
4.2
Filename Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
60
4.3
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
61
4.4
Quoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
62
4.5
aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
63
4.6
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
64
File Permissions
65
5.1
66
5.1.1
67
5.1.2
68
File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
69
5.2.1
chmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71
5.3
umask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
72
5.4
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
73
5.2
Text Processing
75
6.1
76
6.1.1
Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
6.1.2
Character Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
78
6.1.3
Quantifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
6.1.4
Parenthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
80
6.2
sed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
81
6.3
tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
83
6.4
sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
84
6.5
uniq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
6.6
cut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86
6.7
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
Page 5
c
2010
n + 1, Inc All Rights Reserved
CONTENTS
7
89
7.1
Disk Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
7.2
91
7.3
Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
92
7.3.1
93
7.3.2
94
7.3.3
95
7.4
Archiving Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
96
7.5
Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
97
8.2
Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.1.1
States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.1.2
8.1.3
Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.1.4
8.3
9
Package Management
9.1
99
109
RPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.1.1
9.1.2
9.1.3
9.2
Yum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.3
10 Secure Shell
Page 6
117
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
10.1 Secure Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
10.1.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
10.1.2 Using SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
10.1.3 File Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
10.2 SSH Key Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
10.3 Lab Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
11 Mounting Filesystems
125
133
Page 7
147
c
2010
n + 1, Inc All Rights Reserved
CONTENTS
Page 8
c
2010
n + 1, Inc All Rights Reserved
List of Tables
2.1
File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
2.2
29
2.3
31
2.4
34
2.5
35
2.6
36
2.7
40
2.8
42
3.1
48
3.2
Movement Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
49
3.3
Paging Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
49
3.4
Insertion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
50
3.5
Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
51
3.6
Search Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
52
4.1
Wildcards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
60
5.1
Fields in /etc/passwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
5.2
Fields in /etc/group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
6.1
76
LIST OF TABLES
6.2
78
6.3
79
6.4
84
6.5
85
6.6
86
7.1
90
7.2
91
7.3
93
7.4
94
7.5
95
7.6
96
8.1
9.1
9.2
9.3
9.4
Page 10
c
2010
n + 1, Inc All Rights Reserved
Chapter 1
Introduction to Linux
Objectives
Understand the History of Unix and Linux
Understand the licensing and distribution of Linux
Be able to obtain basic system and user info
Obtain help for commands in multiple ways
Be able to become root and run basic account administration commands
11
Page 12
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 13
c
2010
n + 1, Inc All Rights Reserved
Page 14
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 15
c
2010
n + 1, Inc All Rights Reserved
Page 16
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 17
c
2010
n + 1, Inc All Rights Reserved
Page 18
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 19
c
2010
n + 1, Inc All Rights Reserved
It is also useful to know information about other users on the system. The primary command for
determing who is logged in is called, amazingly enough, who. This command will show all the
users logged in, their terminals, and the time of login.
$ who
robc
robc
robc
Page 20
:0
pts/1
pts/2
2009-08-10 08:41
2009-10-09 08:53 (:0.0)
2009-10-09 09:06 (:0.0)
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
$ cal
May 2009
Su Mo Tu We Th Fr
1
3 4 5 6 7 8
10 11 12 13 14 15
17 18 19 20 21 22
24 25 26 27 28 29
31
Sa
2
9
16
23
30
$ cal 8 2009
August 2009
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Page 21
c
2010
n + 1, Inc All Rights Reserved
Page 22
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 23
c
2010
n + 1, Inc All Rights Reserved
1.4.1 su
The su command allows a user to switch to another user account. When the command is run, the
UID and GID values of the new user are substituted for the current user values.
To change to the guest user, a user would use the following command:
$ su guest
The user will be prompted for guests password. When a user first logs in, a number of initialization
scripts are run that set up the environment for the user. When the su command is used, this
environment does not chanege. However, you often want the environment of the new account. To
get the scripts run for that user, the dash option is added to the command.
$ su - guest
To run just a single command as another user, the -c option is used. This will login as the new user,
run the command, and then exit back to the original user.
A common use of the su command is for a user with root access, to change from their regular
account to the root account. When switching to root, no user name is necessary on the command
line.
$ su For security reasons, it is best for a user, even with superuser access, to use their regular account
for most tasks. Changing to the root user only for specific tasks is the best procedure.
Page 24
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
1.4.2 passwd
The passwd command is used to change a users password. If a regular user uses the command, it
changes their password. It first prompts for the current password. To make sure it is actually the
user changing the password, they must remember their current password.
If the root user runs the passwd command with a user as a parameter, root is prompted for a new
password without needing to know the users password. In both cases, the passwd command
verifies that the password is of sufficient strength. However, root can override this feature and use
a poor password anyway, although this is not recommended.
Page 25
c
2010
n + 1, Inc All Rights Reserved
Page 26
c
2010
n + 1, Inc All Rights Reserved
Chapter 2
27
Description
ext3
XFS
JFS
ReiserFS
SMB
NTFS
Windows filesystem
Table 2.1: File Systems
Page 28
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
/bin
/boot
/dev
Device files
/etc
System configuration
/home
/lib
Shared libraries
/media
/mnt
/opt
Add-on software
/root
/sbin
/tmp
Temporary files
/usr
/var
Page 29
c
2010
n + 1, Inc All Rights Reserved
2.2 Navigation
The pwd command is used to show the current directory of the user. It will show an absolute path
name starting with the root directory (/). For example, after logging on, a user is initially located in
their home directory.
$ pwd
/home/user
The cd command is used to change directories. To change to any directory, the user can type the
cd command with any full path name, starting with the root directory. This is called an absolute
path name. An absolute path name always begins with /. The cd command can also be used with
relative path names, which are directory instructions relative to the current directory. If there is a
subdirectory under /home/user called docs, a user in /home/user can change directory to docs in
two ways.
$ cd /home/user/docs
$ cd docs
Both of the previous commands would change the user to the docs directory. In any directory,
there are two special files. The first is the . directory. This is a reference to the current directory.
The second is the .. directory. This is a reference to the parent directory. To change to the parent
directory, the user can type cd ... Multiple .. directories can be strung together to change up many
levels in the file system. To change from /home/user/docs to /etc, the following command can be
used.
$ cd ../../../etc
The first three ..s move up 3 levels in the file sytem, the the etc goes down into the etc directory.
There are some other special characters that can be used with cd. The cd command typed by itself
always takes the user to their home directory. The command cd will also change directories to
the users home directory. The command cd username will change to that users home directory.
Finally, the command cd - will return to the previous directory. It works like the return button on a
remote control, allowing the user to bounce back and forth between two directories.
Page 30
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
2.2.1 ls
The ls command lists the contents of a directory. By default, it lists the current directory but can
also be used to list other directories. There are a number of important options, shown in the table
below:
Option
Description
-a
-l
Long listings
-d
-r
Reverse sort
-t
-S
-R
The ls command shows a simple list of files with no detail about the files. With the long listing
option, ls -l shows a list of files with details about the file. The command ls -a shows hidden files.
In Linux, a hidden file is any file that begins with a dot (.). There is nothing special about hidden
files other than the name. The general purpose of hidden files are for configuration files stored in
user home directories. These files are necessary but clutter up a file listing, so they are named with
a dot so they dont show up in normal listings.
There are a couple of sorting options with ls. The command ls -lt gives a long listing sorted by
modification time. The command ls -lS sorts by size.
Page 31
c
2010
n + 1, Inc All Rights Reserved
2
7
1
1
1
1
1
1
1
1
robc
root
root
robc
robc
robc
robc
root
robc
robc
robc
4096 Mar
root
4096 Jun
root
1268 Mar
robc
24 Jun
robc
176 Jun
robc
124 Jun
robc
2659 Aug
root
35 Mar
robc 391751 Mar
robc
4118 Dec
5
26
8
15
15
15
25
8
5
14
15:29
2009
14:20
2009
2009
2009
2009
14:20
15:29
12:49
.
..
.bash_history
.bash_logout
.bash_profile
.bashrc
emailform.php
.lesshst
linux_foundations.pdf
.viminfo
$ ls -latr
total 460
-rw-r--r--rw-r--r--rw-r--r-drwxr-xr-x
-rw-rw-r--rw-------rw-r--r-drwx------rw-------rw-------
1
1
1
7
1
1
1
2
1
1
robc
robc
robc
root
robc
robc
robc
robc
root
root
robc
124 Jun
robc
176 Jun
robc
24 Jun
root
4096 Jun
robc
2659 Aug
robc
4118 Dec
robc 391751 Mar
robc
4096 Mar
root
35 Mar
root
1268 Mar
15
15
15
26
25
14
5
5
8
8
2009
2009
2009
2009
2009
12:49
15:29
15:29
14:20
14:20
.bashrc
.bash_profile
.bash_logout
..
emailform.php
.viminfo
linux_foundations.pdf
.
.lesshst
.bash_history
Page 32
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 33
c
2010
n + 1, Inc All Rights Reserved
2.3.1 cp
The copy command, cp allows a user to make a copy of a file or directory. The syntax of the copy is
as follows:
cp options source target
Some of the common options are shown below:
Option
Description
-i
Interactive
-r
Recursive
Table 2.4: Options for the cp command
If the target file name already exists, the source file will copy over the top of the target. The
interactive option exists in order to prompt the user if the target already exists. This prevents
accidently copying over a needed file. If the target is a directory, the file is copied into the directory,
not over the top of the directory.
$ ls
filea
$ cp filea fileb
$ ls
filea fileb
$ cp -i filea fileb
cp: overwrite fileb?
$ cp filea
Page 34
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
2.3.2 mv
The mv command is very similar to the cp command, only it moves a file instead of copying it. Like
with copy, move will overwrite a target file without prompting.
Option
Description
-i
Interactive
-r
Recursive
Table 2.5: Options for the mv command
$ ls
filea fileb
$ mv filea filec
$ ls
fileb filec
$ mv -i fileb filec
mv: overwrite filec?y
$ ls
filec
$ mv filec
Page 35
c
2010
n + 1, Inc All Rights Reserved
2.3.3 rm
The remove command, rm, deletes a file or directory. Unlike other operating systems, when a file
is deleted, there is no reasonable way to get it back. The rm command should be used with care. If
the rm command is used on a directory, it will not delete the directory unless the recursive option
is used. This will remove all files in the directory and will recurse all subdirectories, deleting all the
files from them, before removing the subdirectories and the target directory. The interactive option
will prompt before removing any file, just to make sure. There is also a -f option, which will force
deletion without any prompting.
Option
Description
-i
Interactive
-r
Recursive
-f
Force
Table 2.6: Options for the rm command
$ ls -l
-rw-rw-r--rw-rw-r--rw-rw-r-drwxrwxr-x
1
1
1
2
$ rm filea
$ ls
fileb filec
robc
robc
robc
robc
robc
0
robc
0
robc
0
robc 4096
May
May
May
May
3
3
3
3
19:16
19:11
19:17
19:17
filea
fileb
filec
testdir
testdir
$ rm -i fileb
rm: remove regular empty file fileb?y
$ ls
filec testdir
$ rmdir testdir
rmdir: testdir: Directory not empty
$ ls testdir
filed
$ rm -r testdir
$ ls
filec
Page 36
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 37
c
2010
n + 1, Inc All Rights Reserved
Page 38
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
[01/May/2010:18:24:28 -0400]
- [01/May/2010:18:30:32 -0400]
- [01/May/2010:18:30:33 -0400]
- [01/May/2010:18:30:33 -0400]
- [01/May/2010:18:30:33 -0400]
- [01/May/2010:18:30:34 -0400]
- [01/May/2010:18:30:34 -0400]
- [01/May/2010:18:30:34 -0400]
- [01/May/2010:18:30:34 -0400]
- [01/May/2010:18:30:34 -0400]
$ head -n 5 sample
207.46.199.42 - - [01/May/2010:18:24:28 -0400]
208.138.254.150 - - [01/May/2010:18:30:32 -0400]
208.138.254.150 - - [01/May/2010:18:30:33 -0400]
208.138.254.150 - - [01/May/2010:18:30:33 -0400]
208.138.254.150 - - [01/May/2010:18:30:33 -0400]
$ tail -3 sample
67.195.111.185 - - [01/May/2010:19:09:34 -0400]
67.195.111.185 - - [01/May/2010:19:09:35 -0400]
207.46.199.190 - - [01/May/2010:19:15:32 -0400]
The tail command also has the very useful -f option. This option shows the last lines of the file
and they continues to run. As new lines are added to a file, they are displayed on STDOUT. This
command is very useful for watching log files to track down problems. To end the tail -f command,
hit Ctrl-C.
Page 39
c
2010
n + 1, Inc All Rights Reserved
2.4.3 wc
The word count file doesnt display a file, but does show statistics on the content of the file. Without
any options, it shows the number of lines, words, and characters in a file. The options shown in the
table below give counts on just one of the stats.
Option
Description
-l
Count of lines
-w
Count of words
-c
Count of characters
Table 2.7: Options for the wc command
$ wc /usr/share/dict/words
98569 98568 931467 /usr/share/dict/words
Page 40
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 41
c
2010
n + 1, Inc All Rights Reserved
Description
-name
File name
-type
File type
-user
File owner
-perm
File permission
-mtime
Page 42
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
cd
pwd
cd /
pwd
ls
cd
pwd
Part 2. Type the command ls -Fa. How many files and directories are in your home directory? How
many hidden files?
Part 3. Use the touch command to create 3 files named filea, fileb, and filec. Use the comman ls -l.
What size are these files? When were they last modified?
Part 4. Create a directory called test. Change into that directory. Use the ls command with and
without the -l option. What is the difference? What are the files named . and ..?
Part 5. Copy file file /usr/share/dict/words into the test directory. How large is this file? View the
first and last 10 lines of this file. Use cat and less to view the file words. Why is one better than the
other?
Part 6. Make a directory under your home directory called test2 and another called test3. Copy the
words file from test to test2. Make sure it is in both test and test2. Is it the same size? Move words
from test2 to test3. Is it still in directory test2? Remove the directories test2 and test3 using rmdir.
What do you need to do to remove test3?
Part 7. Use the find command to find all files under your home directory that were modified in the
last hour.
Part 8. Use the locate command to find files with words in their name. Why didnt the copy inside
your test directory show up?
Page 43
c
2010
n + 1, Inc All Rights Reserved
Page 44
c
2010
n + 1, Inc All Rights Reserved
Chapter 3
45
Page 46
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
3.2 Modes
The vim editor is modal, within vim commands must be issued to change between modes. There
are three modes: insert, command, and last line. Command mode is the default mode and is used
to issue commands. To enter command mode from insert mode, press the ESC key. From within
command mode, there are a number of different insertion commands that will enter insertion mode.
Each of these commands has a special effect, we will see their usage in a later section. Last line
mode echoes commands at the bottom of the screen, on the last line. Many of these commands
begin with a colon (:) and are called ex commands, named after the editor they originally came
from. Other last line commands begin with a backslash (/), question mark (?), or exclamation point
(!). The last line command is executed by pressing the Enter key.
When using vim, there are a few basics to remember. First, once in vim, the entire window is used.
If the number of lines in the file are less than the number of lines on the screen, the remaining lines
are displayed as a tilde ( ).
Secondly, the bottom of the file displays the file name followed by the total number of lines and
characters in the file. On the right side is the cursor location described as line number, column
number. The cursor location changes as the cursor is moved around the file. On the far right is the
completion percentage of the document of the current screen shot. It will read Top if at the top of
the Document, Bot if at the bottom and All if the entire document is shown on screen.
Finally, all commands are case sensitive. For example, w and W both move the cursor forward one
word, but the uppercase W ignores most punctuation.
Page 47
c
2010
n + 1, Inc All Rights Reserved
Description
:w
:w filename
:wq
:w!
:wq!
:q!
ZZ
Same as :wq
Table 3.1: Saving and Exiting Commands
Note that vim does not allow the user to quit a file if changes have been made. Only the :q! command
allows the user to quit the file without saving the edits made from the last time the file was saved.
Page 48
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
Move cursor up
While in command mode, there are other commands that allow you to move in larger steps. The
parenthesis move the cursor to the next or previous sentence. The brackets move to the next or
previous paragraph. The command G moves the cursor to the last line of the file, while putting a
number before G moves to that specific line number.
Prefacing a command with a number causes the command to repeat itself that number of times.
For example, to move forward three sentences, the command 3) would be executed. Not only do
these numeric prefaces work when moving the cursor, they also work with insertion, deletion, and
changing text commands.
Control key commands move the cursor by larger chunks of text. The table below shows the control
key movement commands.
Command
Description
Ctrl-F
Ctrl-B
Ctrl-D
Ctrl-U
Page 49
c
2010
n + 1, Inc All Rights Reserved
Description
Insert at cursor
Overwrite text
Table 3.4: Insertion Commands
The i command is the primary insertion command. It changes modes from command to insertion
and allows insertion of text at the point of the cursor. The a command is similar but appends text
after the point of the cursor. I and A work similarly to the lowercase equivalents only they start the
insertion at the beginning of the line and append at end of line respectively. The o and O commands
enter insertion mode on a blank line after or before the current line.
There are two more commands that are similar to the insertion commands. The r command allows
you to replace the single character under the cursor. For example, if you placed the cursor on the
letter t and then hit rc, that would replace the t with a c. The R command puts vim into Replace
mode, which types over the current text. Hitting esc exits back to command mode.
Page 50
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
dd
Delete line
yy
Copy line
Paste buffer
Delete character
dw
yw
Join lines
Undo command
Table 3.5: Editing Commands
Page 51
c
2010
n + 1, Inc All Rights Reserved
Description
/pattern
?pattern
The Search and Replace syntax is shown in the following table. The command begins with a :, an
optional range, and an s. Without a range, the Search and Replace is done on the current line only. If
the range is a percent sign, then the entire document is searched. Otherwise a pair of line numbers
separated by a comma gives the range to search.
Following the s, there are 3 slashes. Between the first two is the pattern to search for and between
the second and third is the pattern to replace it with. After the final slash, there is an optional g
for global. Without it, only the first match is replaced. With it, all of the matches in the range are
replaced.
:s/pattern/replace/
Page 52
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
#move
#move
#move
#move
#move
#move
#same
#move
Page 53
c
2010
n + 1, Inc All Rights Reserved
/Fro
n
nnnnn
l
2x
i
or
ESC
jj
:s/Fro/For/
:81,87s/Fro/For/
/tyrant
w
w
D
J
:wq
Part 3. Open memo.txt in vim. Change the memo so that your name is in the From field. Update
the date. Correct the misspellings of the words teh to the and ani to any. Use search and
replace on teh and change ani by hand. Save file as memo2.txt. Exit from vim.
Page 54
c
2010
n + 1, Inc All Rights Reserved
Chapter 4
55
Page 56
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
4.1.1 Channels
All programs in Linux have at least 3 communication channels associated with them. Every channel
also has a number associated with the channel. Many programs may open other communication
channels which also have numbers assigned to them at the time.
The first channel that all programs have is called STDIN and has a channel number of zero. This
communication channel is where the program gets input. It is usually from the keyboard.
The second channel is STDOUT and has a channel number of one. This is where the program sends
output. This is usually the terminal.
The third channel that all programs have associated with them is STDERR. This is where programs
send error messages. Like STDOUT, it usually sends these messages to the terminal.
Any other channels opened by a program are connected to file handles. These additional channels
have numbers starting with three.
Page 57
c
2010
n + 1, Inc All Rights Reserved
4.1.2 Redirection
File redirection allows the user to redirect the communication channels associated with programs
to files or other programs. The chart below shows the major file redirection characters.
> STDOUT to file
< STDIN from file
>> STDOUT append to file
2> STDERR to file
2>> STDERR append to file
&> STDOUT and STDERR to file
$ echo "This is a test" > echo.txt
$ cat echo.txt
This is a test
$ who >> whofile
$ cat <whofile
robc
:0
robc
pts/1
robc
pts/2
robc
pts/3
Page 58
2010-02-10
2010-03-09
2010-03-09
2010-03-10
08:41
08:53 (:0.0)
09:06 (:0.0)
08:15 (:0.0)
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
4.1.3 Pipe
The pipe character is an additional redirection character that affects two commands at once. It connects the STDOUT channel from the first command to the STDIN channel of the second command.
This allows the formation of complicated processes from a series of simple commands.
For example, often a command returns more than a screen full of information, Piping the output to
less allows the user to read the results one page at a time.
$ ls -l | wc -l
169
Building complex commands from a series of simple commands via the pipe is a common task of
Linux system administrators. It is part of the Unix design principles discussed previously.
Page 59
c
2010
n + 1, Inc All Rights Reserved
Description
Matches anything
[...]
The most commonly used wildcard is the asterisk (*). This will match anything. The question mark
(?) matches any single character. The braces ([...]) match a character class. This can contain any
characters to be matched and ranges of characters can be represented with a dash.
Some examples of wildcards are shown below:
$ ls file*
file1 file10
file11
file12
file2
file3
file4
file8
file9
filea
fileb
The previous example would match all files beginning with file. The following would match all
files beginning with file and containing exactly one more character.
$ ls file?
file1 file2
file3
file4
file8
file9
filea
fileb
filec
This next example matches any filename beginning with file and then ending with a single digit.
$ ls file[0-9]
file1 file2 file3
file4
file8
file9
The previous example matches file1 and file9 but not file11.
Page 60
c
2010
n + 1, Inc All Rights Reserved
filec
LINUX FOUNDATIONS
4.3 Variables
There are two types of variables used by the shell. They are shell variables and environment
variables. Shell variables are only available to the current shell, if another shell is opened, those
variables will not exist there. Environment variables, on the other hand, exist across shells.
The export command is used to turn a shell variable into an environment variable. First the variable
must be set. To set a variable, the equals sign (=) is used. There can be no spaces around the equals
sign. Then the variable can be accessed using the dollar sign before the name.
$ AGE=40
$ echo $AGE
40
$ bash
$ echo $AGE
$ exit
$ echo $AGE
40
$export AGE
$ echo $AGE
40
$ bash
$ echo $AGE
40
The env command displays all of the environment variables on the system, along with their current
values.
Page 61
c
2010
n + 1, Inc All Rights Reserved
4.4 Quoting
When the shell parses input, certain characters have special meaning, and are interpreted instead
of being read literally. These special characters are called metacharacters. If you need to use these
characters, you need to require the shell to not use them for their special meaning, but to treat them
literally. In order for this to occur, the metacharacters must be quoted.
If only a single character needs to be quoted, the character can be proceeded with a backslash. The
backslash is a metacharacter with a special meaning that the next character is quoted. To use an
actual backslash, proceed it with an additional backslash (really, this works).
If there are many metacharacters in a line, backslashing them all can be tedious. In this case,
enclosing them within double quotes will treat the metacharacters literally, with one exception.
Variables still will be evaluated within double quotes, so the dollar sign is still a metacharacter.
However, within single quotes, all metacharaters are treated literally, thus dollar signs will be
treated as dollar signs, not as the start of a variable name.
One final type of quoting exists, this is the nesting of commands. If a piece of text is surrounded
by backticks, it will be treated as a command and the result of the command inserted into the text.
There is a second syntax for this, instead of the backticks, the command can be surrounded by
parenthesis and proceeded by a dollar sign. Examples of both ways are below.
$ echo "The date is date +%x"
$ echo "The date is $(date +%)"
Page 62
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
4.5 aliases
In Bash, command shortcuts can be created. These are called aliases. To create an alias, the alias
command is used. Examples are below:
$ alias rm="rm -i"
$ alias ll="ls -latr"
With those aliases, every time the user types rm, rm -i will be run instead. This allows the user to
create shorter versions of commonly run commands.
To remove an alias, the unalias command is used.
$ unalias rm
Page 63
c
2010
n + 1, Inc All Rights Reserved
Page 64
c
2010
n + 1, Inc All Rights Reserved
Chapter 5
File Permissions
Objectives
Explain changing the owner or group associated with a file
Describe the file permissions of a file or directory
Be able to change permissions on a file or directory
Understand default permissions based on masking
65
Description
username
password
x - Password in /etc/shadow
UID
User ID number
GID
GECOS
home dir
shell
Every user is a member of at least one, but quite possibly, many, groups. Information on groups is
stored in the file /etc/groups. The table below shows the /etc/group fields.
Field
Description
group name
password
x - Password in /etc/gshadow
GID
Group ID number
user list
Originally, passwords were stored as encrypted strings in the /etc/passwd and /etc/group files. All
users need read access to these files and this became a security issue. Passwords are no longer stored
in these files (although the field still exists). Instead, they are stored in files called /etc/shadow and
/etc/gshadow. Only root has read access to these files. In addition to the encrypted passwords,
these files also contain information related to aging of passwords.
Page 66
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 67
c
2010
n + 1, Inc All Rights Reserved
Page 68
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 69
c
2010
n + 1, Inc All Rights Reserved
Page 70
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
5.2.1 chmod
The chmod command is used to change file permissions. Only the owner of a file (and the root
user) can change the permissions on a file. There are two methods for changing the permissions, a
symbolic representation and a numerical representation. The symbolical can add (+), subtract (-),
or set (=) permissions for the three groups, the user/owner (u), the group(g), and other users (o), or
it can be changed for all (a).
The examples below show how to combine these symbols.
Add write permission for owner
$ ls -l test.txt
-r--r--r-- 1 robc robc 0 May 10 10:41 test.txt
$ chmod u+w test.txt
$ ls -l test.txt
-rw-r--r-- 1 robc robc 0 May 10 10:41 test.txt
Add execute permission for everyone
$ chmod a+x test.txt
$ ls -l test.txt
-rwxr-xr-x 1 robc robc 0 May 10 10:41 test.txt
Subtract write permission from group and others
$ ls -l test2.txt
-rw-rw-rw- 1 robc robc 0 May 10 10:41 test2.txt
$ chmod go-w test2.txt
$ ls -l test.txt
-rw-r--r-- 1 robc robc 0 May 10 10:41 test2.txt
Set specific permissions on file
$ chmod u=rwx,g=rx,o= test.txt
$ ls -l test.txt
-rwxr-x--- 1 robc robc 0 May 10 10:41 test.txt
It is also possible to use chmod with the numerical representation learned in the previous section.
The final example from above is shown numerically below.
$ chmod 750 test.txt
Once the numerical representation is learned it is generally easier to use. However, when using
chmod with the recursive option (-R), it is generally better to use the symbolic version and add or
subtract the permissions that need to change. Generally, directories need the execute permission
and files dont, so recursively changing directories and files at the same time can lead to problems,
when the numerical method is used.
Page 71
c
2010
n + 1, Inc All Rights Reserved
5.3 umask
By default, files are created with a 666 permission (read and write for everone) while directories are
created with 777 permission (read, write, and execute for all).
$ mkdir testdir
$ touch testfile
$ ls -l
total 4
drwxr-xr-x 2 robc robc 4096 2009-07-11 11:21 testdir
-rw-r--r-- 1 robc robc
0 2009-07-11 11:22 testfile
The directory testdir has 755 permissions. The file testfile has 644 permissions. Why dont they match
the defaults above? This is due to the umask. The umask is subtacted from the defaul permissions
when a file or directory is created in order to set the permissions. The umask command shows the
current umask value. The command can also set the value.
$ umask
0022
$ umask 0002
$ umask
0002
$ mkdir testdir2
$ touch testfile2
$ ls -l
total 8
drwxr-xr-x 2 robc
drwxrwxr-x 2 robc
-rw-r--r-- 1 robc
-rw-rw-r-- 1 robc
The new direction now has 775 permission. The new file has 664 permission. The change in umask
from 0022 to 0002 allows write permission for groups.
Page 72
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 73
c
2010
n + 1, Inc All Rights Reserved
Page 74
c
2010
n + 1, Inc All Rights Reserved
Chapter 6
Text Processing
Objectives
Explain the use of the grep command
Describe the different text processing tools
Understand piping together the tools to create a complex filter
75
(:0)
(:0.0)
(:0.0)
(:0.0)
(:0.0)
There are several options available for grep. The table belows lists only the most common.
Option
Description
-i
Ignore case
-v
-c
-A NUMBER
-B NUMBER
-C NUMBER
Page 76
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Tab
\n
Newline
\r
Carriage return
Beginning of line
End of line
Page 77
c
2010
n + 1, Inc All Rights Reserved
Description
[:alpha:]
[:digit:]
[:alnum:]
[:lower:]
[:upper:]
[:space:]
[:cntrl:]
Match any 4 letter line beginning with a lowercase letter and ending with a n
$ grep [a-z]..n$ /usr/share/dict/words
Match any lines in /etc/passwd containing a uppercase letter
$ grep [[:upper:]] /etc/passwd
Same as above
$ grep [A-Z] /etc/passwd
Match any lines in words file that begin with a digit
$ grep [[:digit:]] /usr/share/dict/words
What would this match?
$ grep [:upper:] /etc/passwd
Page 78
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
6.1.3 Quantifiers
Quantifiers greatly expand the power of regular expressions. They match certain amounts of
repeated patterns of the character preceeding the quantifier.
The table below shows the quantifiers and the number of repeats they match.
Quantifier
Description
Match 0 or 1 times
n,
n,m
Match n to m times
Table 6.3: Regular expression quantifiers
The regular expression pattern ca*t would match all of the following:
ct
cat
caat
caaat
caaaaaaaaaaat
With advanced regular expressions, it is often necessary to use the -E option for extended regular
expressions.
Match all 15 letter words beginning with a vowel
$ grep -E [aeiou].{14}$ /usr/share/dict/words
Match all 12 letter words betting with a f, g, or h and ending in a r, s, or t
$ grep -E [fgh].{10}[rst]$ /usr/share/dict/words
Match all lines containing 2 or more uppercase letters in a row
$ grep -E [[:upper:]]{2,} /usr/share/dict/words
Page 79
c
2010
n + 1, Inc All Rights Reserved
6.1.4 Parenthesis
When parenthesis surround part of a regular expression, it means one of three different things.
First, it makes a new atom out of that part of the expression. An atom can be acted upon by a
quantifier following the parenthesis. Instead of acting on the last character, it acts upon the entire
pattern within the parenthesis.
abc{3} matches abccc
(abc){3} matches abcabcabac
Secondly, the parenthesis can be used to create an option of regular expressions. The options are
separated with a pipe.
(abc|xyz) matches abc and xyz
Finally, the parenthesis can be used to create a group for referencing later. In some programs,
regular expressions can be used in a search and replace, and any patterns that match a part of the
expression within parenthesis is stored in a varible for use within the replace portion.
Page 80
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
6.2 sed
The sed command is a non-intereactive stream editor that uses commands similar to ed. The syntax
for sed takes a command and a file on which to act. The command is applied to each line of input
with results written to STDOUT. For example, to change also occurences of teh to the within a
file, the following sed command would be used:
$ cat memo.txt
To: All Staff
From: Heady teh Head Honcho
Date: June 1, 2006
Re: New Memo Format Effective June 1
In order to make interoffice communications easier, please adhere to teh following guidelines for wr
*
*
*
*
*
*
*
Clearly state teh purpose of teh memo in teh subject line and in teh first paragraph.
Keep language professional, simple and polite.
Use short sentences.
Use bullets if a lot of information is conveyed.
Proofread before sending.
Address teh memo to teh person(s) who will take action on teh subject, and CC those who need t
Attach additional information: dont place it in teh body of teh memo if possible.
In order to make interoffice communications easier, please adhere to the following guidelines for wr
*
*
*
*
*
*
*
Page 81
Clearly state the purpose of the memo in the subject line and in the first paragraph.
Keep language professional, simple and polite.
Use short sentences.
Use bullets if a lot of information is conveyed.
Proofread before sending.
Address the memo to the person(s) who will take action on the subject, and CC those who need t
Attach additional information: dont place it in the body of the memo if possible.
c
2010
n + 1, Inc All Rights Reserved
In order to make interoffice communications easier, please adhere to teh following guidelines
Page 82
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
6.3 tr
The tr command is used to translate, squeeze and delete characters. As a default, tr looks for
characters in set1 and replaces them with characters in set2.
tr options set1 set2
With the -d (delete) or -s (squeeze) options, tr needs only set1, which will tell it what to delete or
squeeze. Squeeze removes repeated sets of characters, such as multiple white space characters.
$ cat tr.txt
this file is in all lower case.
$ cat tr.txt | tr a-z A-Z
THIS FILE IS IN ALL LOWER CASE.
$ cat tr.txt | tr -d s
thi file i in all lower cae.
Page 83
c
2010
n + 1, Inc All Rights Reserved
6.4 sort
The sort command sorts, merges or compares all the lines from files or STDIN. By default, sort writes
the results to STDOUT. When given more than one file as input, the default operation is to sort each
file and then merge them into one. Some useful options include the following:
Option
Description
-n
Sort numerically
-r
-t separator
-k NUMBER
-o filename
Here are some examples of sort. The final example stores the sorted data in a file instead of
displaying it on the screen.
$ cat data.txt
Carl:31
Ann:21
Donna:3
Bob:20
$ sort data.txt
Ann:21
Bob:20
Carl:31
Donna:3
$ sort -t: -k2 data.txt
Bob:20
Ann:21
Donna:3
Carl:31
$ sort -t: -k2 -n data.txt
Donna:3
Bob:20
Ann:21
Carl:31
$ sort -t: -k2 -odata.sort data.txt
Page 84
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
6.5 uniq
By default, the uniq command runs through a file or standard input, finds all duplicated lines and
removes the duplicates. In order for the uniq command to work properly, it must be fed sorted data.
Some useful options include:
Option
Description
-i
Ignore case
-d
-u
-c
If uniq is given a second filename on its command line, it will write the output to that file. Because
uniq requires sorted files, it is very common to run sort first and pipe the output to uniq, as in the
example below:
$ sort data.txt | uniq >nodups.txt
Page 85
c
2010
n + 1, Inc All Rights Reserved
6.6 cut
The cut command cuts sections of text from files, or STDIN, and neatly pastes them together to
STDOUT. The cut command is most useful with files or input the contain information arranged
using tabs (default) or some other delimiting character. Some useful options include:
Option
Description
-d separator
Use as separator
-f range
Fields to cut
Table 6.6: Options for the cut command
When specifying a range, start from 1 at the beginning of the line. Specify multiple ranges by
separating them with a comma.
The /etc/passwd file contains several records related to user accounts. Here is an example using the
cut command to list only user names and UIDs from /etc/passwd.
$ cut -d: -f1,3 /etc/passwd
robc:501
user:502
The cut command is often used with other commands to create a complex text manipulation, as
shown in the examples below:
$ cut -d: -f7 /etc/passwd | sort | uniq -c | sort -rn
17 /bin/sh
11 /bin/false
2 /bin/bash
1 /bin/sync
Page 86
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 87
c
2010
n + 1, Inc All Rights Reserved
Page 88
c
2010
n + 1, Inc All Rights Reserved
Chapter 7
89
[user@localhost ]$ df -i
Filesystem
Inodes
IUsed
IFree IUse%
/dev/sda2
4100544 179253 3921291
5%
/dev/sda7
44597248
11 44597237
1%
/dev/sda5
5124480
2154 5122326
1%
/dev/sda3
5124480
25336 5099144
1%
/dev/sda1
26104
78
26026
1%
tmpfs
128209
1 128208
1%
Mounted on
/
/data
/var
/home
/boot
/dev/shm
The table below shows the most commonly used options for df.
Option
Description
-h
-i
-T
Page 90
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
-h
-s
-S
max-depth=N
Page 91
c
2010
n + 1, Inc All Rights Reserved
7.3 Compression
There are a number of compression commands available in linux. Unix used the compress command,
which is available in some linux distributions. However, compress was not efficient and has been
surpassed by the other algorithms. The syntax of the compress command has stayed and is used by
most of the other commonly used compression commands.
Like compress, neither gzip nor bzip2 archives directories. They are used to compress an archive that
has already been created. The zip command has the ability to both archive and compress.
Page 92
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Option
Description
-r
Recurse directories.
-v
Verbose mode.
-1 to -9
Page 93
c
2010
n + 1, Inc All Rights Reserved
]$ ls
]$ bzip2 token.txt
]$ ls
stuff]$ bunzip2 token.txt.bz2
]$ ls
The -1 to -9 options work differently in bzip2. They are used to set block size for the compression
algorithm and dont control speed or compression ratios. Therefore, they are rarely used. Below is
a table of the commonly used options.
Option
Description
-r
Recurse directories.
-v
Verbose mode.
Table 7.4: Options for the bzip2 command
Page 94
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
-r
Recurse directories.
-v
Verbose mode.
-0 to -9
Page 95
c
2010
n + 1, Inc All Rights Reserved
Description
-c
Create archive.
-x
Extract archive.
-t
-v
Verbose mode.
-f
Archive to file.
-z
gzip archive.
-j
bzip2 archive.
Table 7.6: Options for the tar command
Page 96
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
mkdir testtar
cd testtar
touch file1 file2 file3
tar -cvf /test1.tar *
$ cd ..
$ tar -cvf test2.tar testtar/
$ tar -tf test1.tar
$ tar -tf test2.tar
$
$
$
$
mkdir testtar2
mv test1.tar testtar2
mv test2.tar testtar2
cd testtar2
$
$
$
$
Page 97
c
2010
n + 1, Inc All Rights Reserved
Page 98
c
2010
n + 1, Inc All Rights Reserved
Chapter 8
99
8.1 Processes
A process is a running instance of a program. The terms process and program are often used
interchangeably but it is inaccurate. A program is an executable file. It is passive while a process
is active. Multiple instances of a single program can be run simultaneously, each as a different
process. Also, some programs may spawn several processes upon execution.
Every process has a set of attributes associated with it:
System Resources Threads, process ID, priority, file handles and environmental variables
Virtual Memory RAM and swap space
Security Attributes What resources the process can access
Processor State Physical memory addresses and contents of registers
Page 100
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
8.1.1 States
Just because a program has been launched does not mean that it is actively running. Processes can
be in several states.
running Currently being allocated CPU slices
stopped Still loaded in memory, but not running
sleeping Waiting for some event, such as user input
zombie Process not properly ended by parent process
It is important to understand the difference between sleeping processes and stopped processes.
When a process is stopped, it is no longer receiving any CPU cycles.
Page 101
c
2010
n + 1, Inc All Rights Reserved
Page 102
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
The top command provides a continuous display of system staus with the most active processes
listed and updated every 5 seconds. Three different classes of information is displayed: system
data, memory data, and process data.
[user@localhost ]$ top
top - 17:18:04 up 48 min, 3 users, load average: 0.05, 0.04, 0.04
Tasks: 115 total,
1 running, 114 sleeping,
0 stopped,
0 zombie
Cpu(s): 0.8%us, 0.3%sy, 0.0%ni, 98.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem:
3786412k total,
645428k used, 3140984k free,
19596k buffers
Swap: 8391592k total,
0k used, 8391592k free,
370264k cached
PID
5617
5916
5921
1
2
3
4
5
6
7
8
9
10
11
44
45
48
USER
root
user
user
root
root
root
root
root
root
root
root
root
root
root
root
root
root
PR
20
20
20
20
15
RT
15
RT
RT
15
RT
15
15
15
15
15
15
NI
0
0
0
0
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
TIME+
0:44.06
0:00.88
0:02.06
0:01.00
0:00.00
0:00.00
0:00.00
0:00.00
0:00.00
0:00.00
0:00.00
0:00.00
0:00.04
0:00.02
0:00.00
0:00.00
0:00.00
COMMAND
Xorg
gnome-screensav
metacity
init
kthreadd
migration/0
ksoftirqd/0
watchdog/0
migration/1
ksoftirqd/1
watchdog/1
events/0
events/1
khelper
kblockd/0
kblockd/1
kacpid
As long as top continues to run, the process information continues to update, To exit, type q.
Page 103
c
2010
n + 1, Inc All Rights Reserved
8.1.3 Signals
Signals are used to communicate events to a process. Signals are represented by a number and a
symbolic name that corresponds to the intended use of the signal. Some signals depend on the
archetecture and cannot be found on all platforms.
Associated with each signal is a default action, represented by its name. For example, SIGINT is an
interrupt process sent from the keyboard. When a user hits Ctrl-C, the SIGINT signal is sent to the
process running in the foreground.
Many programs contain signal handlers to catch and deal with signals that are sent to the process.
With a few exceptions, the process can handle the signal as it sees fit. Thus, while SIGINT tells
a process to quit, it might choose to continue or use it to start a shutdown procedure, instead of
immediately dying.
Processes cannot install signal handlers for the SIGSTOP and SIGKILL signals. To provide the
desired behavior, these two signals are caught and enforced by the kernal.
The following table contains the most common signals:
Signal
Value
Action
Description
SIGHUP
Terminate
Hangup on terminal
SIGINT
Terminate
SIGQUIT
Core Dump
SIGFPE
Core Dump
SIGKILL
Terminate
Kill signal
SIGTERM
15
Terminate
Termination signal
SIGCONT
18
Continue
Continue if stopped
SIGSTOP
19
Stop
Stop process
Page 104
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 105
c
2010
n + 1, Inc All Rights Reserved
Page 106
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 107
xclock
xclock
jobs
xclock
bg 1
jobs
xclock &
kill %1
jobs
xclock
c
2010
n + 1, Inc All Rights Reserved
Page 108
c
2010
n + 1, Inc All Rights Reserved
Chapter 9
Package Management
Objectives
Describe the use of rpm commands for package management
Explain the different package options with RPM
Be able to use yum to manage packages
109
9.1 RPM
Installing from source presents many challenges for the administrator:
Build dependencies must be resolved manually
Dependencies are not tracked after installation
Files placed on the file system during installation are not tracked
Removing a package involves deleting each file individually
Versioning tasks, such as upgrading and rolling back, can be difficult
Modern package management systems attempt to solve these problems. The most widely used
package management system is RPM (RPM Package Manager). It is used by many distributions.
RPM keeps a database of all the packages installed on a system and all of the files placed on your
system by those packages. The rpm command is used to query the package database, install, and
delete packages.
Page 110
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
-i
-U
-F
-v
Verbose mode
-e
Uninstall package
- -force
Force upgrade
- -nodeps
Ignore dependencies
Table 9.1: Options for the rpm command
Page 111
c
2010
n + 1, Inc All Rights Reserved
Page 112
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Description
-qa
-qi packagename
-ql packagename
-qR
Every time a package is installed, upgraded, or deleted, RPM logs the changes in its database. The
RPM verify command allows an administrator to verify that their system configuration matches
the database. It verifies that every file installed by a package continues to exist on the system. It
also checks the attributes of each file to make sure the files are the intended ones with the proper
permissions.
The common command line options for RPM verify are listed in the following table:
Option
Description
-V packagename
-Va
-Vf file
Verify all the files provided by the package that also provided
the named file
Table 9.3: Options for the rpm verify command
Page 113
c
2010
n + 1, Inc All Rights Reserved
9.2 Yum
The yum command is used for installing RPM packages from repositories. It will determine dependencies and install those packages in addition to the package being installed. It is possible to
configure yum to work with multiple repositories and yum will use the most up-to-date versions
when different repositories contain the same packages.
The table below shows commonly used yum commands:
Option
Description
install
Install package
update
remove
Remove package
provides
search
The behavior of yum is determined by its configuration file, at /etc/yum.conf. A default yum.conf
file is shown below:
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
# Note: yum-RHN-plugin doesnt honor this.
metadata_expire=1h
installonly_limit = 5
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
Page 114
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Individual repositories are configured in files stored in /etc/yum.repos.d/, one file for each repository.
An example repository configuration looks like:
[adobe-linux-i386]
name=Adobe Systems Incorporated
baseurl=http://linuxdownload.adobe.com/linux/i386/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
Page 115
c
2010
n + 1, Inc All Rights Reserved
Page 116
c
2010
n + 1, Inc All Rights Reserved
Chapter 10
Secure Shell
Objectives
Use SSH to access remote machines
Set up public/private keys
Use scp to transfer files securely
117
Page 118
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
10.1.1 Configuration
SSH works under a standard client/server model. The SSH client connects to a server running the
sshd process. Once the client and server establish a connection and setup up an encrypted channel,
the user can then authenticate.
On both sides, there are a few files that can be configured. By default, most of these never need to
be changed. On the server, the following files handle configuration:
/etc/ssh/sshd_config
/etc/ssh/ssh_host_key
/etc/ssh/ssh_host_key.pub /etc/ssh/sshrc
/.ssh/config
/.ssh/id_rsa
/.ssh/id_rsa.pub
There is another important file located in the users .ssh directory. It is the known hosts file. This
file contains the public key of the hosts that have been connected to. If you try to connect to a
host whose key doesnt match, ssh will warn you and not allow the connection. You then have
to manually remove the key from this file in order to connect. SSH also notifies you whenever
you are connecting to a system that you havent connected to before, one without an entry in the
known hosts file.
Page 119
c
2010
n + 1, Inc All Rights Reserved
Page 120
[
[
OK
OK
]
]
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 121
100% 8049
7.9KB/s
00:00
c
2010
n + 1, Inc All Rights Reserved
0.6KB/s
00:00
ssh mail.nplus1.net
cd .ssh
cat robc\@otho-id_dsa.pub >> authorized_keys
chmod 600 authorized_keys
In order to work, the .ssh directory must have file permissions of 700 and the authorized keys file
must have permissions of 600. SSH will not use them if anyone other than the owner has read
permission to the directory or file.
Page 122
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 123
c
2010
n + 1, Inc All Rights Reserved
Page 124
c
2010
n + 1, Inc All Rights Reserved
Chapter 11
Mounting Filesystems
Objectives
Understand mounting filesystems
Be able to add entries to /etc/fstab
Learn to mount and unmount NFS and SMB shares
125
Page 126
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 127
c
2010
n + 1, Inc All Rights Reserved
Page 128
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
11.2 NFS
The Network File System is the native file sharing method for UNIX systems. An NFS server
exports directories. This makes them available for sharing across the network. The client
machine then mounts the NFS exports. Users then use the shares as if they were local. From
the users perspective there is no difference between a remote NFS filesystem and a local filesystem.
The standard mount command is used to mount NFS shares. The type of filesystem is nfs and the
device points to a server and location on that server. For example, if the server thorin was mounting
a website, the mount command would look like:
$ mount -t nfs thorin:/export/website /mnt/web
If a share is continuously mounted, its description can be placed in /etc/fstab so that it mounts on
boot.
To determine what exports are available from an NFS server, use the showmount command as
follows:
showmount -e server_name
Page 129
c
2010
n + 1, Inc All Rights Reserved
11.3 Samba
SMB is the native file sharing protocol for Microsoft Windows. It is also called CIFS. It allows
servers to share directories, printers, users and other information. On the server side, samba allows
the Linux server to be a Windows file server on the network. On the client side, there are two tools
to access remote SMB shares.
First, there is the smbclient command. This provides an ftp-like interface to the SMB share.
smbclient //server/share -U user
Notice that the slashes are backwards from the normal Windows syntax. The user must provide a
password to access the share and then uses ftp style commands to access files.
The second method is to mount the share using the mount command. This requires the username
option as shown below.
mount -t smb -o username=user //server/share dir
Page 130
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
$ ls -la /mnt/server
$ umount /mnt/server
Part 2. Add a line to /etc/fstab for the NFS share mounted in Part 1. Mount it again without using
the full mount command. Make sure it mounts properly. Then unmount it.
Part 3. Repeat Parts 1 and 2 only for a SMB share the the instructor gives you the name of.
Page 131
c
2010
n + 1, Inc All Rights Reserved
Page 132
c
2010
n + 1, Inc All Rights Reserved
Chapter 12
Shell Scripting
Objectives
Understand the special variables used in shell scriping
Use the conditional constructs if and case
Use the looping constructs for and while
133
Page 134
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
$ echo $?
0
$ ls no.dir
2
The return value of commands is used by a variety of flow control elements, covered in the next
section. One of the primary commands used by these elements is the test command. The test
command has two syntaxes:
test expression
[ expression ]
In the latter syntax, which is the most common within shell scripts, the space after the starting
brace and before the closing brace are manditory. There are a large number of options for the test
command, the most common are shown in the table below.
Option
Condition tested
-e filename
File exists
-d filename
-f filename
-x filename
x=y
x -eq y
x -ne y
x -gt y
x -lt y
Page 135
c
2010
n + 1, Inc All Rights Reserved
Page 136
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 137
c
2010
n + 1, Inc All Rights Reserved
Page 138
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
The variable dereferenced with $* is a list that expands to all of the command line parameters. It is
equivalent to $1 $2 $3 $4 etc.
#!/bin/bash
#file echo3
echo $*
echo $1 $2 $3
echo $#
shift
echo $1 $2 $3
echo $#
$
a
a
4
b
3
./echo3 a b c d
b c d
b c
c d
Page 139
c
2010
n + 1, Inc All Rights Reserved
12.2 if-then-ilif-else-fi
The most basic of the flow control constructs is the if-then construct. If a command returns a value
of 0, then a block of code is executed. The syntax of the command is shown below, with a simple
example.
#!/bin/bash
if [ -d backup ]
then
echo "Moving file.txt to backup directory."
mv file.txt backup
fi
If backup is a directory, then the echo and the mv commands are executed, otherwise they are not.
The indenting is for ease of reading, it has no other meaning.
Often, if the command fails, a separate block of commands need to be run, with the else part of the
construct, a block of code to execute if the command fails can be defined.
#!/bin/bash
if [ -d backup ]
then
echo "Moving file.txt to backup directory."
mv file.txt backup
else
echo "backup is not a directory."
fi
If the first if fails, it is sometimes needed to test another command. The elif construct can be used,
once or multiple times, to test these other commands.
#!/bin/bash
if [ -d backup ]
then
echo "Moving file.txt to backup directory."
mv file.txt backup
elif [ -f backup ]
then
echo "backup is a file, dont want to overwrite it."
elif [ -x backup ]
then
echo "backup is executable, view its contents"
cat backup
else
echo "backup is not a directory."
fi
Page 140
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 141
c
2010
n + 1, Inc All Rights Reserved
Page 142
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Page 143
echo
echo
echo
echo
"Hi there" ;;
"Hello to you too" ;;
"bye" ;;
"I dont have a response to that" ;;
c
2010
n + 1, Inc All Rights Reserved
Page 144
c
2010
n + 1, Inc All Rights Reserved
Appendices
145
LINUX FOUNDATIONS
<http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but
changing it is not allowed.
Preamble
The purpose of this License is to make a manual, textbook, or other functional and useful document
free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute
it, with or without modifying it, either commercially or noncommercially. Secondarily, this License
preserves for the author and publisher a way to get credit for their work, while not being considered
responsible for modifications made by others.
This License is a kind of copyleft, which means that derivative works of the document must
themselves be free in the same sense. It complements the GNU General Public License, which is a
copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software
needs free documentation: a free program should come with manuals providing the same freedoms
that the software does. But this License is not limited to software manuals; it can be used for
any textual work, regardless of subject matter or whether it is published as a printed book. We
recommend this License principally for works whose purpose is instruction or reference.
c
2010
n + 1, Inc All Rights Reserved
APPENDIX
subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not
explain any mathematics.) The relationship could be a matter of historical connection with the
subject or with related matters, or of legal, commercial, philosophical, ethical or political position
regarding them.
The Invariant Sections are certain Secondary Sections whose titles are designated, as being those
of Invariant Sections, in the notice that says that the Document is released under this License. If
a section does not fit the above definition of Secondary then it is not allowed to be designated as
Invariant. The Document may contain zero Invariant Sections. If the Document does not identify
any Invariant Sections then there are none.
The Cover Texts are certain short passages of text that are listed, as Front-Cover Texts or BackCover Texts, in the notice that says that the Document is released under this License. A Front-Cover
Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A Transparent copy of the Document means a machine-readable copy, represented in a format
whose specification is available to the general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text
formatters or for automatic translation to a variety of formats suitable for input to text formatters.
A copy made in an otherwise Transparent file format whose markup, or absence of markup, has
been arranged to thwart or discourage subsequent modification by readers is not Transparent. An
image format is not Transparent if used for any substantial amount of text. A copy that is not
Transparent is called Opaque.
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo
input format, LaTeX input format, SGML or XML using a publicly available DTD, and standardconforming simple HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats
that can be read and edited only by proprietary word processors, SGML or XML for which the DTD
and/or processing tools are not generally available, and the machine-generated HTML, PostScript
or PDF produced by some word processors for output purposes only.
The Title Page means, for a printed book, the title page itself, plus such following pages as are
needed to hold, legibly, the material this License requires to appear in the title page. For works
in formats which do not have any title page as such, Title Page means the text near the most
prominent appearance of the works title, preceding the beginning of the body of the text.
The publisher means any person or entity that distributes copies of the Document to the public.
A section Entitled XYZ means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language.
(Here XYZ stands for a specific section name mentioned below, such as Acknowledgements,
Dedications, Endorsements, or History.) To Preserve the Title of such a section when
you modify the Document means that it remains a section Entitled XYZ according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License
applies to the Document. These Warranty Disclaimers are considered to be included by reference in
this License, but only as regards disclaiming warranties: any other implication that these Warranty
Page 148
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
Disclaimers may have is void and has no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License
applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading
or further copying of the copies you make or distribute. However, you may accept compensation
in exchange for copies. If you distribute a large enough number of copies you must also follow the
conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display
copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the
Document, numbering more than 100, and the Documents license notice requires Cover Texts, you
must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover
Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly
and legibly identify you as the publisher of these copies. The front cover must present the full title
with all words of the title equally prominent and visible. You may add other material on the covers
in addition. Copying with changes limited to the covers, as long as they preserve the title of the
Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones
listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must
either include a machine-readable Transparent copy along with each Opaque copy, or state in or
with each Opaque copy a computer-network location from which the general network-using public
has access to download using public-standard network protocols a complete Transparent copy of
the Document, free of added material. If you use the latter option, you must take reasonably prudent
steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent
copy will remain thus accessible at the stated location until at least one year after the last time you
distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version
of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions of sections
2 and 3 above, provided that you release the Modified Version under precisely this License, with
Page 149
c
2010
n + 1, Inc All Rights Reserved
APPENDIX
the Modified Version filling the role of the Document, thus licensing distribution and modification
of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in
the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document,
and from those of previous versions (which should, if there were any, be listed in the History
section of the Document). You may use the same title as a previous version if the original
publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of
the modifications in the Modified Version, together with at least five of the principal authors
of the Document (all of its principal authors, if it has fewer than five), unless they release you
from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other copyright
notices.
F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the
Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts
given in the Documents license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled History, Preserve its Title, and add to it an item stating at
least the title, year, new authors, and publisher of the Modified Version as given on the Title
Page. If there is no section Entitled History in the Document, create one stating the title,
year, authors, and publisher of the Document as given on its Title Page, then add an item
describing the Modified Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to a Transparent
copy of the Document, and likewise the network locations given in the Document for previous
versions it was based on. These may be placed in the History section. You may omit a
network location for a work that was published at least four years before the Document itself,
or if the original publisher of the version it refers to gives permission.
K. For any section Entitled Acknowledgements or Dedications, Preserve the Title of the
section, and preserve in the section all the substance and tone of each of the contributor
acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles.
Section numbers or the equivalent are not considered part of the section titles.
M. Delete any section Entitled Endorsements. Such a section may not be included in the
Modified Version.
Page 150
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
N. Do not retitle any existing section to be Entitled Endorsements or to conflict in title with
any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary
Sections and contain no material copied from the Document, you may at your option designate
some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections
in the Modified Versions license notice. These titles must be distinct from any other section titles.
You may add a section Entitled Endorsements, provided it contains nothing but endorsements of
your Modified Version by various partiesfor example, statements of peer review or that the text
has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words
as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage
of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made
by) any one entity. If the Document already includes a cover text for the same cover, previously
added by you or by arrangement made by the same entity you are acting on behalf of, you may not
add another; but you may replace the old one, on explicit permission from the previous publisher
that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their
names for publicity for or to assert or imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the terms
defined in section 4 above for modified versions, provided that you include in the combination all
of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant
Sections of your combined work in its license notice, and that you preserve all their Warranty
Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant
Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same
name but different contents, make the title of each such section unique by adding at the end of it, in
parentheses, the name of the original author or publisher of that section if known, or else a unique
number. Make the same adjustment to the section titles in the list of Invariant Sections in the license
notice of the combined work.
In the combination, you must combine any sections Entitled History in the various original
documents, forming one section Entitled History; likewise combine any sections Entitled Acknowledgements, and any sections Entitled Dedications. You must delete all sections Entitled
Endorsements.
6. COLLECTIONS OF DOCUMENTS
Page 151
c
2010
n + 1, Inc All Rights Reserved
APPENDIX
You may make a collection consisting of the Document and other documents released under this
License, and replace the individual copies of this License in the various documents with a single
copy that is included in the collection, provided that you follow the rules of this License for verbatim
copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this
License, provided you insert a copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that document.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include translations of some or all Invariant
Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers,
provided that you also include the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between the translation and the original
version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled Acknowledgements, Dedications, or History, the
requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly provided
under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
Page 152
c
2010
n + 1, Inc All Rights Reserved
LINUX FOUNDATIONS
However, if you cease all violation of this License, then your license from a particular copyright
holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder fails to notify you of the
violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright
holder notifies you of the violation by some reasonable means, this is the first time you have received
notice of violation of this License (for any work) from that copyright holder, and you cure the
violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have
received copies or rights from you under this License. If your rights have been terminated and not
permanently reinstated, receipt of a copy of some or all of the same material does not give you any
rights to use it.
11. RELICENSING
Massive Multiauthor Collaboration Site (or MMC Site) means any World Wide Web server
that publishes copyrightable works and also provides prominent facilities for anybody to edit
those works. A public wiki that anybody can edit is an example of such a server. A Massive
Multiauthor Collaboration (or MMC) contained in the site means any set of copyrightable
works thus published on the MMC site.
CC-BY-SA means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San
Francisco, California, as well as future copyleft versions of that license published by that same
organization.
Incorporate means to publish or republish a Document, in whole or in part, as part of another
Document.
Page 153
c
2010
n + 1, Inc All Rights Reserved
APPENDIX
An MMC is eligible for relicensing if it is licensed under this License, and if all works that were
first published under this License somewhere other than this MMC, and subsequently incorporated
in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus
incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the
same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the with . . . Texts.
line with this:
with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being
LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge
those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend releasing these
examples in parallel under your choice of free software license, such as the GNU General Public
License, to permit their use in free software.
Page 154
c
2010
n + 1, Inc All Rights Reserved