Linux 101
Linux 101
Linux 101
I2C etc
____________________________________________________________________________________________________________
Page 45
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
&$ File Permissions and Attributes
"han!in! #ermissions and owners
From the previous figure we see that permissions can be acted upon with hmod. There are 3 categories of
ownership for each file and directory:
u: a valid user with an entry in /etc/passwd
!: a valid group with an entry in /etc/group
o: other
Example:
-rw-rw-r-- 1 jade sales 24880 Oct 25 17:28 libcgic.a
Changing Permissions with hmod:
chmod g8r,o1r )ibcgic.a
chmod gP, )ibcgic.a
Changing user and group with hown and h!r# :
cho,n root )ibcgic.a
chgrp apache )ibcgic.a
____________________________________________________________________________________________________________
Page 46
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
NOTICE
A useful option for hmod, hown and h!r# is G/ which recursively changes
ownership and permissions through all files and directories indicated.
Symboli and otal notation
Permissions can be read=r, write=w and execute=x. The octal values of these permissions are listed in the
next table.
Octal and symbolic permissions.
Symoli otal binary
read 4 ' 100'
write 2 ' 010'
execute 1 ' 001'
Permissions apply to the user, the group and to others. An item has a set of 3 grouped permissions for each
of these categories.
1ow to read a >GG or "rwxr"xr"x permission
user group other
rwx
4+2+1=6
r_x
4+1=;
r_x
4+1=;
The standard #ermission
UNX system create files and directories with standard permissions as follows:
Standard permission for:
Files 666 -rw-rw-rw-
Directories 777 -rwxrwxrwx
1mask
Every user has a defined umask that alters the standard permissions. The umask has an octal value and is
subtracted(*) from the octal standard permissions to give the files permission (this permission doesn't have a
name and could be called the file's effecti%e permission).
(*) While subtraction works in most cases, it should be noted that technically the standard permissions and
the umask are combined as follows:
Final Permissions = Standard Permissions (logical AND) (NOT)Umask
On systems where users belong to separate groups, the umask can have a value of 002.
____________________________________________________________________________________________________________
Page 47
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
For systems which place all users in the users group, the umask is likely to be 022.
S1ID #ermissions
An executable can be assigned a special permission which will always make it run as the owner of this file.
This permission is called SUD meaning 'set user D'. t has a symbolic value s or a numerical value &000.
Administrative tools may have the SUD bit set in order to allow non-root users to change system files.
For example the #asswd command can be run by any user and will interactively change his or her current
password. This password will be saved to @et@#asswd or @et@shadow. However both these files belong to
user root with typical permissions of 644 and 600 respectively.
This problem has been solved by setting the SUD bit on #asswd hence forcing it to run as user root with the
correct permissions to modify @et@#asswd or @et@shadow.
The SUD on #asswd
)s 1) W(,hich pass,d)
-(-9--)--) 1 (''t (''t 1+99. C41 $ .003 /49(/=21/:599Dd
NOTCE
The SUD bit is shown in symbolic form in the command above. t is possible to get more information about
a file using stat as well as seeing the octal representation of the permissions as follows:
stat usrbinpass,d
F27e# E/49(/=21/:599DdF
S2Ae# 1+99. B7'0<9# -0 IO B7'0<# -09$ (e3475( *27e
Dev20e# 30%;/773d I1'de# 3%$$+0 L21<9# 1
A00e99# G-%11/-(-9--)--)H !2d# G 0/ (''tH I2d# G 0/ (''tH
WARNNG! WARNNG! WARNNG!
The SUD permission is often associated with security issues. Here is an example that illustrates this.
1. A user would like to read user root' s mail. For this he changes the environmental variable as follows:
export C/IL8*arspoo)mai)root
2. The user then uses the command mail, hoping to see something!
mai)
/v5(/9:''7/8527/(''t# &e(82992'1 de12ed
So far it doesn't work. This would be too easy!
But if root can be convinced to set the SUD bit on mail the previous commands would allow any user to
read anybody's mail (including root).
____________________________________________________________________________________________________________
Page 48
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
The next examples are dangerous. Why?
chmod =E55 bincat
chmod uPs bingrep
SGID #ermissions
The SGD is a permission similar to SUD that is set for group members. The symbolic value is s and the
octal value of 5000.
Setting SGD on a directory changes the group ownership used for files subsequently created in that directory
to the directories group ownership. No need to use ne,grp to change the effective group of the process
prior to file creation (see exercise p.55) .
Examples:
chmod 2E55 homedata
chmod gPs bin,c
The stiky bit
The sticky bit permission with value 1000 has the following effect:
- Applied to a directory it prevents users from deleting files unless they are the owner (ideal for
directories shared by a group)
- Applied to a file this used to cause the file or executable to be loaded into memory and caused later
access or execution to be faster. The symbolic value for an executable file is t while for a non
executable file this is T. As file system caching is more generic and faster, file sticky bits tend not be
supported any more.
Examples:
chmod (III datastore.txt
chmod oPt binbash
File Attributes
Alongside the standard permissions there is another system that can be used to change the way a file can be
used. File Attributes do not show up in the 'ls' command. The 'lsattr' command must be used instead. The
'hattr' command is used to set and drop these attributes.
____________________________________________________________________________________________________________
Page 49
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
The following attributes are available. Please note the case.
'A' When a file with the 'A' attribute set is accessed, its atime (access time) record is not modified. This
avoids a certain amount of disk /O, typically for temporary files. Do be aware that some tools, such as
tmpwatch, rely on the atime record to determine if the file has been used recently. f the atime record is not
being updated the file's status might be misinterpreted.
'a' A file with the 'a' attribute set can only be open in append mode for writing. Only the superuser or a
process possessing the CAP_LNUX_MMUTABLE capability can set or clear this attribute. This is probably
most effectively used on system log files, to prevent intruders removing evidence of their passage. Do be
aware that in order for the intruder to have any chance of editing these log files, they need to have root
access. With root access they could remove the 'a' attribute, make the edits and then re-establish the 'a'
attribute.
'c' A file with the 'c' attribute set is automatically compressed on the disk by the kernel. A read from this file
returns uncompressed data. A write to this file compresses data before storing them on the disk. NB Sadly,
while the attribute is set on the file and is displayed by the lsattr command, it is not yet honoured by the ext2
or ext3 filesystem kernel drivers.
'D' When a directory with the 'D' attribute set is modified, the changes are written synchronously on the disk;
this is equivalent to the 'dirsync' mount option applied to a subset of the files. When this attribute is in
operation against a directory, the following operations are synchronous within that directory: create, link,
unlink, symlink, mkdir, rmdir, mknod and rename.
'd' A file with the 'd' attribute set is not candidate for backup when the dum# (8) program is run.
'i' A file with the 'i' (immutable) attribute cannot be modified: it cannot be deleted or renamed, no link can be
created to this file and no data can be written to the file. Only the superuser or a process possessing the
CAP_LNUX_MMUTABLE capability can set or clear this attribute.
'j' A file with the 'j' attribute has all of its data written to the ext3 journal before being written to the file itself, if
the filesystem is mounted with the "data=ordered" or "data=writeback" options. When the filesystem is
mounted with the "data=journal" option all file data is already journalled and this attribute has no effect. Only
the superuser or a process possessing the CAP_SYS_RESOURCE capability can set or clear this attribute.
's' When a file with the 's' attribute set is deleted, its blocks are zeroed and written back to the disk. NB As
with the 'c' attribute, this attribute is honoured by everything except the kernel filesystem driver.
'S' When a file with the 'S' attribute set is modified, the changes are written synchronously on the disk; this is
equivalent to the 'sync' mount option applied to a subset of the files. t is most often used for the 'cooked files'
used by database programs to hold their data. When used in this way the addition of two different caching
systems together is avoided. The caching system of the database, which is optimised for that systems use of
data, is allowed to write direct to disk.
'T' The 'T' attribute is only usable when using the 2.6.x kernel. The 'T' attribute is designed to indicate the top
of directory hierarchies, this is designed for use by the Orlov block allocator. The newer file allocation policies
____________________________________________________________________________________________________________
Page 50
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
of the ext2 and ext3 filesystems place subdirectories closer together allowing faster use of a directory tree if
that directory tree was created with a 2.6 kernel.
't' A file with the 't' attribute will not have a partial block fragment at the end of the file merged with other files
(for those filesystems which support tail-merging). This is necessary for applications such as LLO which read
the filesystems directly, and which don't understand tail-merged files. Note: As of this writing, the ext2 or ext3
filesystems do not (yet, except in very experimental patches) support tail-merging.
'u' When a file with the 'u' attribute set is deleted, its contents are saved. This allows the user to ask for its
undeletion. This is another attribute that is supported by everything except the kernel itself.
Example:
J )sattr test!i)e
1111111111111 test!i)e
J chattr Pi test!i)e
J )sattr test!i)e
1111i11111111 test!i)e
J rm 1! test!i)e
rm? cannot remo*e Xtest!i)eY? @peration not permitted
J chattr 1i test!i)e
J rm 1! test!i)e
J )s test!i)e
)s? test!i)e? #o such !i)e or directory
____________________________________________________________________________________________________________
Page 51
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
;$ 3xerises and Summary
/e-iew =uestions (answers p.150)
Yes or No
1. The @usr directory must always be on the root device since it contains
essential tools needed at boot time _____
2. f a user's home directory is anywhere else than in the @home directory
then some operations may not work _____
3. Making a filesystem on a partition always deletes all the data on that partition _____
Glossary
Term Description
base directories subdirectories that are directly under the root directory
data block block used to store data on a filesystem. Data blocks are referenced by inodes
essential root (/)
subdirectories
term used in this manual to identify directories that must be present at boot time once
the root filesystem has been mounted
ext2 the second extended filesytem type was adopted as the generic Linux filesystem
ext3 the third extended filesystem supports the same features as ext2 with an added
journalling system
file permissions attributes stored inside a file's inode giving simple read,write and execute permissions
to the file owner (u), the group (g) and any other (o) user as well as more advanced
permissions such as SUD, SGD and the 'sticky bit'
filesystem hierarchy
standard (FHS)
"This standard consists of a set of requirements and guidelines for file and directory
placement under UNX-like operating systems. The guidelines are intended to support
interoperability of applications, system administration tools, development tools, and
scripts as well as greater uniformity of documentation for these systems" see
http://www.pathname.com/fhs/
inode block used to store information about files, directories and symbolic links. nformation
includes the location of the file's data block, file permissions, time stamps and file type
(e.g directory, file or symlink)
Orlov block allocator Scheme that increases the performance of an EXT2/EXT3 filesystem. t is only
available for 2.6 kernels. t was ported from BSD and improved by Alexander Viro,
Andrew Morton, and Ted Ts'o. The original author is Grigory Orlov. This scheme can
be switched on and of using the hattr command under Linux
superblock is read when the filesystem is mounted, contains information such as the block-size
used for the current filesystem (default 1024), the number of free inodes, the mount
count and maximum mount count (used to determine if a full filesystem check should
be performed)
____________________________________________________________________________________________________________
Page 52
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
Files
File Description
/etc/mtab file used by mount to keep track of currently mounted devices
/proc/mounts file used by the kernel to keep track of currently mounted devices
"ommands
Command Description (apropos)
chattr changes file attributes on a ext2/3 filesystem
chgrp chgrp - change the group ownership of a file
chmod chmod change file access permission
chown chown(1) change the user and group ownership of a file
df df - report filesystem disk space usage
du du - estimate file space usage
e2fsck e2fsck - check and repair a Linux second extended file system
fsck check and repair any file system
lsattr lists the file attributes on a ext2/3 filesystem
mke2fs mke2fs create an ext2/3 filesystem
mkfs mkfs build a Linux file system
mount mount(1) All files accessible in a Unix system are arranged in one big tree, the file
hierarchy, rooted at /. These files can be spread out over several devices. The mount
command serves to attach the file system found on some device to the big file tree.
Conversely, the umount(8) command will detach it again
umask tool used to set the file-creation mask mode see hel# umask
Filesystem
1. Create 2 new partitions (larger than 50M) on the @de-@hda device using fdisk.
HNT: To create a new partition type n. The partition type defaults to <9 (Linux)
To write the new partition table type w.
The partition table needs to be read: REBOOT the computer !
2. Format the first partition using the ext5 filesystem type and the second with reiserfs.
HNT: The mkfs tool is a front for mkfs$ext5 or mkfs$reiserfs, etc. The syntax is
m0!s St 4!stype5 4de*ice5
3. Make directories in @mnt and mount the new partitions
m0dir mntext2
m0dir mntreiser!s
4. Check the status of your system:
Use mount to verify which devices are mounted. The permissions set in fstab are visible too.
____________________________________________________________________________________________________________
Page 53
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
Use df to check the total number of blocks used. The Gk option will convert the number of blocks in
kilobytes (the default block size for ext5)
Run fsk on one of the newly created filesystems. The fsk utility is a front for fsk$ext5, fsk$ext9,
fsk$reiserfs, etc. The syntax is:
!sc0 4de*ice5
5. Going further: Changing from ext5 to ext9 :
Update the device mounted on @mnt@ext5 to ext9 with tune2fs. This will add a journal to the existing
filsystem. Make sure to make the relevant change for the filesystem type in @et@fstab
tune2!s ST de*hdaN
At this stage the system has added a Kournal to the @de-@hda10 partition, making it an ext9 formated
partition. This process is non-destructive and reversible. f you mount an ext9 as an ext5 filesystem, the
$Kournal file will be erased. You can add it again with tune5fs .
File #ermissions
1. Login as a user (non root). Create a file using touh and verify that it has the effective permission
664.
2. Change the umask to 027. f you create a new file what is it's effective permission? _________
Where is the value of umask set? Depening the systems this can be @et@#rofile or @et@bashr
3. Add 2 users to your system.
useradd user(
useradd user2
Add passords with pass,d user( and pass,d user2
4. Create a group called sales.
groupadd sa)es
5. Add the users to the group sales
gpass,d 1a user( sa)es
gpass,d 1a user2 sa)es
6. Create a directory @news owned by the group sales and read-writable for this group.
m0dir 1m EE0 ne,s - cho,n .sa)es ne,s
7. Set the GD to the @news directory.
chmod gPs ne,s
What are the symbolic permissions (eg. -rwxr_xr_x) on @news? [use 79 -7d /1eD9 ] ______
____________________________________________________________________________________________________________
Page 54
LinuxIT Tehnial Trainin! "entre
The Linux Filesystem
_________________________________________________
Verify that a group member doesn't need to type "ne,grp sa)es in order to create files with the right
permissions. Can members of the group sales modify any files in this directory?
8. Add the sticky"bit permission on the @news directory. Verify that only user-owners can modify the files
in the that directory. What are the permissions like on @news? ______________
10. As root set SUD root xeyes. Login as a non root user. Check that this binary runs with U root.
chmod uPs X,hich xeyesX
Log in as another user and run xeyes. Then do:
ps aux M grep xeyes
(the binary should be running as root)
____________________________________________________________________________________________________________
Page 55
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
$%e Command &ine
Prere*uisites
None
Goals
ntroduce the bash shell and basic concepts such as interactively starting an executable
Distinguish variables defined as local or global (exported)
Manipulate data streams using pipes and other redirection operators
Understand meta-characters used for "file globbing"
"ontents
T(3 "0,,A+D LI+3$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$;%
1. The interactive shell.....................................................................................................................57
2. Variables......................................................................................................................................58
3. nput, Output, Redirection............................................................................................................59
4. Metacharacters and Quotes........................................................................................................62
5. The Command History.................................................................................................................63
6. Other Commands........................................................................................................................64
7. Exercise and Summary................................................................................................................67
________________________________________________________________________________________________________
Page 56
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
0-er-iew
A basic way to interact with a computer system is to use the command line. The shell interprets
the instructions typed in at the keyboard. The shell prompt (ending with $ or # for user root)
indicates that it is ready for user input.
The shell is also a programming environment which can be used to perform automated tasks.
Shell programs are called scripts.
Most Common shells
The Bourne shell /bin/sh
The Bourne again
shell
/bin/bash
The Korn shell /bin/ksh
The C shell /bin/csh
Tom's C shell /bin/tcsh
Since the bash shell is one of the most widely used shells in the Linux world the LP
concentrates mainly on this shell.
1$ The interati-e shell
Shell commands are often of the form
0'8851d /':t2'196 J5(348e1t9K>
Printin! text to the sreen
The the bash shell uses the eho command to print text to the screen.
echo this is a short line
Full@/elati-e #ath
The shell interprets the first word of any string given on the command line as a command. f the string
is a full or relati-e #ath to an executable then the executable is started. f the first word has no /
characters, then the shell will scan directories defined in the PATH variable and attempt to run the first
command matching the string.
For example if the PATH variable only contains the directories @bin and @usr@bin then the string xeyes
won't be found since it is stored in @usr@711/%@bin@xeyes so the full path needs to be run
/usr/X11R6/in/!eyes
An alternative to typing the full path to an executable is to use a relati-e path. For example, if the user is
in the directory where the xeyes program is stored then one can type
/!eyes
________________________________________________________________________________________________________
Page 57
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
5$ 4ariables
Shell variables are similar to variables used in any computing language. Variable names are limited to
alphanumeric characters. For example CREDT=300 simply assigns the value 300 to the variable named
CREDT.
1. initialise a variable: Variable-Name=value (no spaces !!)
2. reference a variable: $Variable-Name
"R#$%&'())
echo *"R#$%&
The value of a variable can be removed with the unset command.
+'port, *et and +n!-
There are two types of variable: local and exported.
Local variables will be accessible only to the current shell. On the other hand, exported variables are
accessible by both the shell and any child process started from that shell.
The commands set and en- are used to list defined variables
$%e set and en! commands
set Lists all variables
en- Lists all exported variables
A global variable is global in the sense that any child process can reference it.
&OC.& +/0OR$+D
2xample# Make the CREDT variable a global variable. Test whether it's listed with set or en-.
e!port "R#$%&
env + ,rep "R#$%&
________________________________________________________________________________________________________
Page 58
VAR!al
VAR ""
parent
child
parent
child
VAR !al
e#port VAR!al
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
Start a new shell (child process) and verify that CREDT is accessible. Can one start any shell and be
sure that CREDT is still declared ?
List of common predefined %ariables
0R+D+(I1+D 2.RI.3&+* ,3A+I+G
DSPLAY Used by X to identify where to run a client application
HSTFLE Path to the users .bash_history file
HOME The path to the user's home
LOGNAME The name used by the user to log in
PATH List of directories searched by the shell for programs to be
executed when a command is entered without a path.
PWD The current working directory
SHELL The shell used (bash in most Linux distributions)
TERM The current terminal emulation
*pecial !ariables
The next few variables are related to process management.
$! represents the PD value of the last child process
$$ represents the PD of the running shell
$? is 0 if the last command was executed successfully and 1 otherwise
9$ In#utJ 0ut#utJ /ediretion
UNX processes normally open three standard file descriptors which enable it to process input and
output. These standard descriptors can be redefined for any given process. n most cases the stdin
descriptor is the keyboard, and the two output descriptors, stdout and stderr, is the screen.
4 process and itHs ? descriptors
'umerical %alues for stdin( stderr and stdout
stdin 0
stdout 1
stderr 2
________________________________________________________________________________________________________
Page 59
STDOUT
>
>>
|
STDERR
2>
STDIN
<
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
stdout rediretion
program 4 file
The data flows from left to right.
fdisk l > partions-t!t
This will run the fdisk utility and output the result to the partitionstxt file. No output is visible. Also notice
that the shell will read this line from the right. As a result, the
partitionstxt file will be created first if it doesn't exist and overwritten if the 'L' operator is used.
The 'LL' operator will append standard output to a file.
*$DO5$ Redirection
stdin rediretion
program 6 file
n this case data flows from right to left. The 'M' operator is only used for stdin and cannot be used for
stdout.
f the file instuctions contains on each line the letters p, m, and : then the next example would cause
fdisk to print the partition table of /de%/hda, print the utility's help screen and finally quit:
fdisk /dev/hda < instructions
*$DI1 Redirection
________________________________________________________________________________________________________
Page 60
process
$I%& '
D&VIC&
>
>>
1>
process
$I%& '
D&VIC&
<
0<
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
stderr rediretion
program 24 errorfile
stdin, stdout and stderr are represented by 0, 1 and 2 respectively. This allows one to select the stderr
stream:
find / .> /dev/null
*$D+RR Redirection
#i#ed ommands
program7 N program2
Pipes are represented by the "| symbol. The data stream goes from the left to the right. The next figure
illustrates how the stdout for one process is redirected to the stdin for another process.
0iped Commands
cat /var/lo,/messa,es + less
NB Multiple output redirects are parsed from right to left, so the following commands are not equivalent.
Do-command 2>&1 >logfile
Do-command >logfile 2>&1
The tee "ommand
command N tee /IL2'4M2
________________________________________________________________________________________________________
Page 61
process
$I%& '
D&VIC&
2>
process
|
process
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
This command is used after a pipe and takes a filename as an argument. The standard output from the
previous command is then sent to the file given as an argument but tee also lets the stream through to
stdout. The stdout has been duplicated in this way.
&$ ,etaharaters and =uotes
Metacharacters are characters that have special meaning for the shell. They are mainly used for file
globbing, that is to match several files or directory names using a minimum of letters.
The input (<), output (>) and pipe (|) characters are also special characters as well as the dollar ($) sign
used for variables. We will not list them here but note that these characters are seldom used to name
regular files.
8ildcards
The O wildcard can replace any number of characters.
)s usrbinbR lists all programs starting with a 'b'
The P wildcard replaces any one character.
ls /usr/in//0 lists all programs having a 'b' as the second letter
C H I is used to define a range of value.
ls a1)234 lists all files starting with an 'a' and have a digit in second position. Also
ls 156a40 lists all files that don't start with an 'a' or an 'A'
C Qstring6(string2RS although not just a file naming wildcard, it can be used to match the names of existing
files.
ls inde!-7htm8html9
#otes and escape codes
The special meaning of metacharacters can be cancelled by escape characters, which are also
metacharacters.
The backslash (\) is called the esa#e harater and cancels the meaning of all metacharacters forcing
the shell to interpret them literally.
The single quotes (' ') cancel the meaning of all metacharacters except the backslash.
The double quotes (" ") are the weakest quotes but cancel most of the special meaning of the enclosed
characters except the pipe (|), the backslash (TB and a variable ($var).
________________________________________________________________________________________________________
Page 62
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
$%e back tick
Back quotes UU will execute a command enclosed. The next example defines the variable TME using the
date command.
&%:#';&oday<s date is =date >?a@?d@?=
echo *&%:#
&oday<s date is Aun@1B@Cul
Another way of executing commands (similar to the back ticks) is to use VAB. This will execute the
enclosed command and treat it as a variable.
&%:#'*DdateE
;$ The "ommand (istory
To view the list of previously typed commands you can use the bash built-in command history.
history
( )s
2 grep 500 etcpass,d
This has listed all the cached commands as well as the commands save in W@$bashDhistory. When a
user exits the shell cached commands are saved to W@$bashDhistory.
You can recall commands by using the Up-arrow and Down-arrow on your keyboard. There are also
emacs key bindings that enable you to execute and even edit these lines.
2macs Iey $indings for 2diting the )ommand 1istory
Ctrl+P Previous line (same as Up-arrow)
Ctrl+n Next line (same as Down-arrow)
Ctrl+b Go back one character on the line (same as Left-Arrow)
Ctrl+f Go forward one character on the line (Same as Right-Arrow)
Ctrl+a Go to the beginning of the line (Same as <Home>)
Ctrl+e Go to the end of the line (Same as <End>)
The bang X key can be used to rerun a command.
Example
!x executes the latest command in the history list starting with an 'x'
!2 runs command number 2 from the history output
!-2 runs the command before last
________________________________________________________________________________________________________
Page 63
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
!! runs the last command
^string1^string2 run previous command and replace string1 by string2
%$ 0ther "ommands
.liases
You can create aliases for commands needing many arguments. The format to create an alias is
57259 8:('3=F0'8851d /':t2'196J5(348e1t9KF
By typing alias alone at the command line you will get a list of currently defined aliases.
Command completion
By pressing TA>J the shell will complete the commands you have started typing in.
66 is a redirection for +O(
For example
cat 44 stop
will accept standard input until the keyword 'stop' is entered.
Compond commands
command1; command2; command3 The three commands are run in sequence regardless of
the success of the previous command
command1 && command2 && command3 Each command will execute only if the previous exit
code is 0 (success)
command1 || comand2 || command3 The next command will execute only if the previous exit
code is not 0 (failure)
$%e 99e'ec9 command
This command is not a binary but rather is part of the shell. t is used to start other commands. Ordinarily
if a command is executed, a sub-process is started. f the exec command is used to initiate the new
program, it reoccupies the process used to start it. t replaces the current shell (in a script or the
interactive shell).
When the new command terminates, control is not passed back to the calling shell, but returns to the
process that called the shell used to make the exec call.
________________________________________________________________________________________________________
Page 64
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
echo **
F1F
* ash
* echo **
FBB
* echo hello
hello
* echo **
FBB
* e!ec echo hello
hello
* echo **
F1F
The above shows control falling back to the second shell (process 455) after a straight forward echo and
the first shell (process 414) using an exec.
,an#a!es and the whatis database
The manpages are organised in sections
NAME the name of the item followed by a short one line description.
SYNOPSYS the syntax for the command
DESCRPTON a longer description
OPTONS a review of all possible options and their function
FLES files that are related to the current item (configuration files etc)
SEE ALSO other manpages related to the current topic
These are the main sections one can expect to find in a manpage.
The whatis database stores the NAME section of all the manpages on the system. This is done through
a daily ron. The whatis database has the following two entries:
158eG<eH L '1e 721e de90(2:t2'1
The syntax for whatis is:
D;5t29 M9t(213N
The output is the full NAME section of the manpages where string matched named7key8
One can also use the man command to query the whatis database. The syntax is
851 -< M9t(213N
This command is similar to a#ro#os. Unlike whatis this will query both the "name and the "one line
description entries of the database. f the string matches a word in any of these fields the above query
will return the full NAME section.
________________________________________________________________________________________________________
Page 65
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
Example: (the matching string has been highlighted)
Ghatis lilo
727' (H) 1 insta)) boot )oader
727'.con! 6)i)o7 (5) 1 con!iguration !i)e !or )i)o
man 2k lilo
grubby (H) 1 command )ine too) !or con!iguring grub, 727', and
e727'
727' (H) 1 insta)) boot )oader
727'.con! 6)i)o7 (5) 1 con!iguration !i)e !or 727'
The FHS recommends manpages to be kept in @usr@share@man. However additional locations can be
searched using the MANPATH environment variable set in @et@man$onfi!. Each directory is further
divided into subdirectories corresponding to manpage sections.
Manpage Sections
Section 1 nformation on executables
Section 2 System calls, e.g mkdir(2)
Section 3 Library calls, e.g stdio(3)
Section 4 Devices (files in /dev)
Section 5 Configuration files and formats
Section 6 Games
Section 7 Macro packages
Section 8 Administration commands
Section 9 Kernel routines
To access a specific section ' one has to enter:
851 N 0'8851d
Examples:
man mkdir
man . mkdir
man cronta
man B cronta
6$ 3xerise and Summary
/e-iew =uestions (answers p.150)
________________________________________________________________________________________________________
Page 66
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
Yes or No
1. f the PATH variable isn't properly set then programs can be
started only if users type in the executable's full or relative path _____
2. The STDOUT from a process can be piped into a file _____
3. Once a data stream has gone through a pipe that stream is
generally no longer visible on STDOUT _____
4. All the commands entered at the shell are stored in a mysql database _____
Glossary
Term Description
compound commands several commands given in a single line at the shell using delimiters.
Depending on the delimiter the shell will execute the commands differently
(p.64)
metacharacters character that is not interpreted literally by the shell but has added meaning
command substitution use the output of a command as a variable. This is done by enclosing the
command in back ticks `` or round brackets $()
For example )s homeW(,hoami) will list the current user's home
directory
file globbing term used when handling multiple file names using wild cards. The name
comes from the !lob sub-program in old UNX shells used to expand wild
cards given on the command line
redirection and pipes operations that manipulate data streams and the file descriptors of a process.
A redirection involves a process and a file, whereas a pipe will involve only
processes
stderr, stdin, stdout names of the file descriptors available for any process to stream error
messages, read input streams and write output (non-error) streams
wild cards the following R, Z , "[\" or "6 7" metacharacters used to match more than
one character when working on the command line
"ommands
Command Description (or apropos)
alias set an alias for a single or a sequence of commands (see man builtins or hel# alias)
echo print text to STDOUT
________________________________________________________________________________________________________
Page 67
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
env list variables that have been exported (see man builtins or hel# en-)
exec Shell built-in used to execute new programs but instead of starting a new sub-process it
replaces the calling process
export export the value of a variable to the environment of subsequently executed commands
(see man builtins or hel# ex#ort)
history display the command history list with line numbers (see man builtins or hel# history)
tee teeA1B read from standard input and write to (both) standard output and files
set list all variables in the environment of the current process (see also man builtins and
hel# set)
3xerises
WARNNG: You will need the uuenode and uudeode commands in the exercises. These
commands are provided by the sharutils package.
*tdin-stdot-stderr
Type the next commands and represent the sequence of execution (if possible) using diagrams similar to
the ones used in this chapter.
ls /etc H df > /tmp/out-1
Dls /etc H dfE > /tmp/out-.
find /etc 2type f .> /dev/null + sort
tr 1a2I4 162J4 < /etc/passGd + sort > /tmp/passGd-tmp
cat /tmp/passGd-tmp + tr 162J4 1a2I4
Command &ine
1. List all files in /usr/X11R6/bin that don't start with an x
)s usrK((BIbin6]x7R
5. The command xterm has the following options:
-bg <color> set background
-fg <color> set foreground
-e <command> execute 'command' in terminal
Set a new alias such that the su command opens a new color xterm and prompts for a root
password.
a)ias su83xterm 1bg orange 1!g bro,n 1e su 1 O3
Where would you store this alias on the system? ___________
9. You can encode files using uuenode. The encoded file is redirected to stdout.
For example: uuencode /bin/bash super"shell B uufile encodes @bin@bash and will produce a file called
su#er.shell when running uudeode against the uufile
- Mail the uuencoded /bin/bash to a local user (for this you can either use uuenode and a pipe N J
or save the uuencoded output to a file uufile and use STDN redirection M).
________________________________________________________________________________________________________
Page 68
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
- Split the uuencoded file into 5 files:
uuencode binbash super1she)) 5 uu!i)e
sp)it Sb (50000 uu!i)e base1name.
This will create files called base1name.aa, base1name.ab, etc
To get a uuencoded file with all the original data (unsplit) do
cat base1name.R 5 uu!i)e.ne,
Finally uudecode the file and check it still works.
uudecode uu!i)e.ne,
This should create a binary file called su#er.shell
9$ Which tool finds the full path to a binary by scanning the PATH variable? _____
2ariables
1. Do the following
Assign the value 'virus' to the variable ALERT.
/LABT8*irus
Verify that it is defined using the set command:
set Mgrep /LABT
s ALERT listed when using en- instead of set?
Next type 'bash'. Can you access the ALERT variable?
bash
echo W/LABT
NOTE the value of ALERT: ______ ( is it blank?)
Type exit (or ^D) to return to your original session.
Use the ex#ort command to make ALERT a global variable.
export /LABT
Verify that it is a global (env) variable
en* M grep /LABT
(v) Start a new bash shell and make sure that ALERT is defined in the new shell:
bash
echo W/LABT
n this new shell, redefine the variable ALERT
________________________________________________________________________________________________________
Page 69
LinuxIT Tehnial Trainin! "entre
The "ommand Line
_______________________________________________
export /LABT8green
Exit that shell. What is the value of ALERT in the original shell? ________
5. At the command prompt type the following lines:
CBA&IT0(8;00-CBA&IT028=00
!or '/B in CBA&IT0( CBA&IT02-do echo W'/B-done
Notice that the variable VAR is referenced with $VAR.
AiB Rerun this command.
AiiB Rerun this command replacing CREDT01 by $CREDT01
9. Using appropriate quotes change your PS1 variable to include the full path to your working directory.
(Hint: the value of PS1 is [\u@ \W]\$ , you only need to replace the \W by a \w)
P+(8Y6^u_^h ^, 7^W Y
What does PS2 look like? ________
________________________________________________________________________________________________________
Page 70
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
(ile Management
Prere*uisites
The Command Line (see p.56)
Understand the EXT2 file system (see p.42)
Goals
Effectively move around the filesystem to create, delete and find files or directories
Distinguish between hard and symbolic links
"ontents
FIL3 ,A+AG3,3+T$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$61
1. Moving around the filesystem.............................................................................................................72
2. Finding Files and Directories..............................................................................................................72
3. Handling directories............................................................................................................................74
4. Using cp and mv.................................................................................................................................74
5. Hard Links and Symbolic Links..........................................................................................................75
7. Touching and dd-ing...........................................................................................................................76
8. Exercises and Summary.....................................................................................................................78
________________________________________________________________________________________
Page 71
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
1$ ,o-in! around the filesystem
Absolute and relati-e #aths
A directory or a file can be accessed by giving its full pathname, starting at the root (/) or its relative path,
starting from the current directory.
4bsolute path: independent of the user's current directory
starts with /
0elati%e path: depends on where the user is
doesn't start with /
As in any structured filesystem there are a number of utilities that can help you navigate through the system.
The next two commands are built-in commands.
#wd: Gives your actual position as an absolute path.
d: The 'change directory' command
5$ Findin! Files and Diretories
We will describe the find, whih, whereis and loate utilities.
find
Syntax:
*21d MDIREC"ORON MCRI"ERIAN /-e)e0 MCOMMANDN JK PQ6
The .I02)&O09 argument tells find where to start searching and )0I&20I4 can be the name of a file or
directory we are looking for.
2xamples#
!ind usrK((BIbin 1name `xR`.
!ind 1user 502
Matching lines are listed to standard out. This output can be acted upon. For example delete the file, or
change the permission. The find tool has the build-in option Gexe which allows you to do that. For example,
remove all files belonging to user 502:
!ind 1type ! 1user 502 Sexec rm S! [\ ^-
xar!s
This tool is often thought of as a companion tool to find. n fact xar!s will process each line of standard
output as an argument for another tool. We could use xar!s to delete all files belonging to a user with:
!ind 1type ! 1user 502 M xargs rm S!
________________________________________________________________________________________
Page 72
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
Certain commands such as rm cannot deal with too long arguments. t is sometimes necessary to
delete all files in a directory with
)s Mxargs rm 1!
Common criteria switches for find
-type specify the type of file
-name name of the file
-user user owner
-atime, ctime, mtime access, creation and modified times (multiples of 24 hrs)
-amin, cmin, mmin access, creation and modified times (multiples of 1 min)
-newer /IL2 files newer than /IL2
loate
Syntax:
7'05te MS"RININ
When using loate all files and directories that match the expression are listed.
)ocate K((B
The search is much faster. n fact loate queries the @-ar@lib@sloate@sloate$db database. This database is
kept up to date via a daily cron job which runs u#datedb.
When running u#datedb from the command line the @et@u#datedb$onf file is read to determine pruned
files systems (e.g NFS) and directories (e.g /tmp)
whih
Syntax:
D;20; 9t(213
This tool will return the full path to the file called strin! by scanning the directories defined in the user's
PATH variable only. As a result whih is only used to find commands.
whereis
Syntax
whereis strin!
This tool will return the full path to source or binaries as well as documentation files matching strin! by
scanning the PATH variable as well as a number of well known locations
Gettin! the most from ls
Most common options for ls
- show inode
-h print human readable sizes
-n list UDs and GDs
-p append descriptor (/=@) to list
-R recursively display content of directories
-S sort by file size
-t sort by modification time (similar to -c)
-u show last access time
________________________________________________________________________________________
Page 73
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
9$ (andlin! diretories
Making a director) wit% mkdir:
When making a directory you can set the permission mode with the .m option. Another useful option is .#
which creates all subdirectories automatically as needed.
Example:
m0dir Sp docsprograms*ersions
Remo!ing directories:
To remove a directory use either rmdir or rm .r. f you are root you may have to specify .f to force the
deletion of all files.
+otie: rm Sr! dir(R removes all files and subdirectories leaving dir1 empty
rm Sr! dir( removes all files and subdirectories including dir1
&$ 1sin! # and m-
#
Syntax:
0: /':t2'196 file1 file2
0: /':t2'196 files directory
t is important to notice that # file6 file2 makes a new copy of file6 and leaves file6 unchanged.
/ig# file6 with inode 2G; is copied to file2( duplicating the data to a new data area and creating a new inode
J2?K for file2
I D
250
I D
6238
You can also copy several files to a directory, using a list or wildcards. The following table lists the most used
options.
Most common options for cp
-d do not follow symbolic link (when used with -R)
-f force
- interactive, prompt before overwrite
-p preserve file attributes
-R recursively copy directories
+ote: cp Sr dirR dir2 will copy all files and subdirectories omitting mydir
________________________________________________________________________________________
Page 74
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
cp Sr mydir dir2 will copy all files and subdirectories including mydir
m-
Syntax:
8v /':t2'196 oldname newname
8v /':t2'196 9'4(0e de9t215t2'1
8v /':t2'196 9'4(0e d2(e0t'(
The m- command can both mo%e and rename files and directories. f oldname is a file and newname is a
directory then the file oldname is moved to that directory.
f the source and destination are on the same filesystem, then the file isn't copied but the inode information is
updated to specify the new location. Most common options are .f force overwrite and .i query interactively.
;$ (ard Links and Symboli Links
Symboli links
A soft link to a file or a directory creates a new inode that points to the same data area:
)n 1s )i)o.con! )i)o.sym
This is the listing for these files. Notice that the reference count is 1 for both files.
1r,1111111 1 root root 22; #o* < 0<?0I )i)o.con!
)r,xr,xr,x 1 root root < #o* < 0<?0I )i)o.sym 15 )i)o.con!
/ig2# 4 soft link to a file
I D
lilo.conf
I
lilo.sym
Soft links can be created across filesystems.
(ard Links
________________________________________________________________________________________
Page 75
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
A hard link is an additional name for the same inode and as such the reference count of the file increases by
one for every new hard link.
)n )i)o.con! )i)o.)in0
n the listing notice that the reference count is 5 and that both files have the same size. n fact they are
identical.
1r,1111111 . root root 22; #o* < 0<?0I )i)o.con!
1r,1111111 . root root 22; #o* < 0<?0I )i)o.)in0
Hard links can only be created within the same filesystem.
6$ Touhin! and dd.in!
touh
Another way of creating or modifying a file is to use touh.
Syntax: touch {options} file7s8
f file doesn't exist it is created. You can also change the access time of a file using the .a option, .m
changes the modification time and .r is used to apply the time attributes of another file.
Example:
touch !i)e(.txt !i)e2.txt creates new files
touch my!i)e 1r etc)i)o.con! myfile gets the time attributes of lilo.conf
To create a file called errors use the L option:
touch 11 1errors
dd
This command copies a file with a changeable /O block size. t can also be used to perform conversions
(similar to tr). Main options are ifY (input file) ofY (output file) on-Y (conversion)
The conversion switch can be: lcase ucase ascii
Example:
dd i!8mntcdromimagesboot.img o!8de*!d0
Notice that unlike # the dd tool will copy portions of a device and preserve the underlying filesystem. On the
other hand # only deals with the data and will transfer it from one filesystem to another:
SOURCE TARGET
________________________________________________________________________________________
Page 76
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
cp:
dd: input file = device output file = device
dd: input file = file output file = device
dd: input file = device output file = file
Filesystem A
Filesystem >
________________________________________________________________________________________
Page 77
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
<$ 3xerises and Summary
/e-iew=uestions (answers p.150)
Yes or No
1. The d G command will take you back to a previous directory? _____
2. Typing d W (in the bash shell) is the shortest command that will take
you to your home directory ? _____
3. One can make two new directories /dir1/dir2 using mkdir without any options _____
4. The command u#datedb will update the loate database _____
5. The syntax to create a symbolic link called FLE-LNK pointing to the file FLE is
)n 1s %ILA1LI#L %ILA _____
6. The commands d @et and d $@et are always equivalent _____
Files
File Description
/etc/updatedb.conf configuration file for the u#datedb tool
/var/lib/slocate/slocate.d
b
the locate (or slocate 'secure locate') database
"ommands
Command Description (apropos)
cd change current directory see he)p cd
cp #A1B copy files and directories
dd copy and convert files. Often used to copy the content of a disk device to another device or file
find findA1B search for files in a directory hierarchy
ln lnA1B make links between files
locate command used to search files and directories in the locate database
ls lsA1B list directory contents
mkdir mkdirA1B make directories
mv m-A1B move (rename) files
pwd #wdA1B print name of current/working directory
rm rmA1B remove files or directories
touch create new empty file or change file timestamps
updatedb command used to update the locate database
whereis whereisA1B locate the binary, source, and manual page files for a command
which whihA1B shows the full path of (shell) commands
________________________________________________________________________________________
Page 78
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
3xerises
File Navigation
1. Make a new directory in @tm# called @et.
m0dir tmpetc
2. n @tm#@et@ create a file called newfile (use touch, cat or vi).
3. Go to the root directory (cd /).
4. Test which of the following commands will show the content of newfile ?
cat etcne,!i)e
cat etcne,!i)e
cat tmpetcne,!i)e
cat tmpetcne,!i)e
5. Remove the @tm#@et directory with rmdir. Do step 1 again then remove @tm#@et with rm
Making space on the filesystem
n order to create more space on the device containing the directory @usr@share@do we need to find a spare
device with enough space and copy the contents of @usr@share@do to that device. Then we create space by
deleting the @usr@share@do directory and creating a symbolic link from @usr@share@do to the new location.
6. Make a directory called @s#are on which we will mount a spare devices (one of the partitions created in
the previous exercises should be suitable)
m0dir spare
mount 4device5 spare
7. Test with df .h @s#are and du .hs @usr@share@do that the device is large enough to contain all of the
existing data.
8. Next, copy the contents of @usr@share@do to @s#are@
cp 1a usrsharedoc spare
9. Make sure the data has all been copied across then edit @et@fstab to make that device available at boot
time.
10. Delete @usr@share@do and create a symbolic link pointing from @usr@share@do to @s#are@do
)n 1s sparedoc usrsharedoc
11. (optional) Do the same with @home. Any extra problems?
Finding Files on the System
12. Copy the file /etc/liloconf to /etc/liloconfbak
(i) Use find to find this new file
(ii) Use loate to find /etc/liloconfbak
(iii) Update the locate database and retry (ii)
________________________________________________________________________________________
Page 79
LinuxIT Tehnial Trainin! "entre
File ,ana!ement
_________________________________________________
Backup strategy (first step)
Find all files in your home directory that have been modified in the past 24 hours.
!ind home Smtime S( Mtee )ist( M,c S1)ines (-1 means less than one day)
We will introduce archiving tools in LP 102, but the output of the find command can be piped directly into
#io.
________________________________________________________________________________________
Page 80
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
0rocess Management
Prere*uisites
The Command Line (p.56)
Goals
Find the process D (or PD) of a running process using different tools
Use kill and killall effectively with the appropriate signal
Manage jobs from the command line in the foreground or the background
"ontents
P/0"3SS ,A+AG3,3+T$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$<1
1. Viewing running processes.................................................................................................................82
2. Modifying Processes..........................................................................................................................83
3. Processes and the shell.....................................................................................................................85
4. Exercises and Summary.....................................................................................................................87
________________________________________________________________________________________
Page 81
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
1$ 4iewin! runnin! #roesses
Processes have a unique Process D the PID. This number can be used to modify a process' priority or to
stop it.
A process is any running executable. f process_2 has been spawned by process_1, it is called a child
process. The spawning process_1 is called the parent process.
The #roess family tree
The #stree command gives a good illustration of parent and child process hierarchy.
/igure 6# !art of the pstree output
bash(1046)---xinit(1085)-+-X(1086)
`-xfwm(1094)-+-xfce(1100)---xterm(1111)---bash(1113)-+-pstree(1180)
| |-soffice.bin(1139)---soffice.bin(1152)-+
-soffice.bin(1153)
| | |-soffice.bin(1154)
| | |-soffice.bin(1155)
| | |-soffice.bin(1156)
| | `-soffice.bin(1157)
| `-xclock(1138)
|-xfgnome(1109)
|-xfpager(1108)
|-xfsound(1107)
`-xscreensaver(1098)
n the above figure all the process' PDs are shown; these are clearly incremental. The most common used
options are .# to display PDs and .h to highlight a users processes only.
Findin! runnin! #roesses
A more direct way to determine which processes are running is to use #s. Most users have a set combination
of options which work for most situations.
Here are three such options:
#s ux all processes run by the user
#s T processes run under the current terminal by the user
#s aux all processes on the system
________________________________________________________________________________________
Page 82
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
t is recommended you read the #s man#a!e and choose your own best options!
ps accommodates 3'IL"style and $-."style arguments
usage: ps -[Unix98 options]
ps [BSD-style options]
ps --[GNU-style long options]
ps help for a command summary
-ummary of options
.a show all processes for the current user linked to a tty (except the session leader)
.e or .A show all processes
.f gives the PPD (Parent Process D) and the STME (Start Time)
.l is similar to .f and displays a long list
a show all processes linked to a tty, including other users
x show all processes without a controlling tty as well
"ontinuously u#datin! #roess information
The to# utility will update information on processes at an adjustable rate.
While to# is running you can type h for a list of commands. The space bar will update information instantly.
You can also use to# to change a process' priority as we shall see in the next section.
5$ ,odifyin! Proesses
Sto##in! #roesses
The kill command can be used to send signals to processes. There are 63 signals available. The default
signal terminates a process and is called SGTERM with value 15.
kill
-yntax
kill SGNAL process_PD
Every process can choose whether or not to catch a signal except for the SGKLL which is dealt with by the
kernel. Most daemons redifine the SGHUP to mean "re-read configuration file.
,ost "ommon Si!nals
1 or SGHUP hangup or disconnect the process
2 or SGNT same as Ctrl+C interrupt
3 or SGQUT quit
9 or SGKLL kill the process through a kernel call
15 or SGTERM terminate a process 'nicely'. This is the DEFAULT signal.
One can also stop processes without knowing the process' PD using killall.
________________________________________________________________________________________
Page 83
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
killall
-yntax
0i))a)) +I"#/L process9#/CA
/ig6# Interprocess signaling
Proess #riority and nie numbers
Nice numbers (#I) alter the CPU priority and are used to balance the CPU load in a multiuser environment.
Each process is started with a default nice number of 0. Nice numbers range from 1: [lowest] to .50 [highest].
Only root can decrease the nice number of a process. Since all processes start with a default nice number of
zero as a consequence negative nice numbers can only be set by root!
nie numbers and "P1 #riorities
19 N PR
users
0 (default)
root
-20 Pool of processes 0
________________________________________________________________________________________
Page 84
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
To modify a process' priority that is already running use renie. To set a process' priority use nie.
-yntax
nice S4#I5 4process5
renice 4P1#I5 1p 4PI&5
Notice that renie works with PDs and handles lists of processes at a time. A useful option to renie is the
.u option which affects all processes run by a user.
Set nice number 1 for processes 234 and 765:
renice P( 1p 2;= EI5
Set nice number -5 for xlok:
nice 115 xc)oc0
9$ Proesses and the shell
bak!round and for!round #roesses
After you have started a process from the shell you automatically leave the shell interpreter. You will notice
that no commands will respond. The reason for this is that it is possible to run programs in the foreground f!
or in the background b! of a shell.
When a program is running in the foreground it is possible to recover the shell prompt but only by interrupting
the program for while. The interruption signal is "trl Z.
Sto##in! and startin! Kobs
A process started from a shell is also called a Mob Once the job receives the [Z signal it is stopped and the
shell prompt is recovered. To restart the program in the background simple type: b!.
Example
[mike localhost /bin]$xclock
xlok runnin! in for!roundJ shell #rom#t lost
[1]+ Stopped xclock xlok reei-ed [Z si!nal
[mike localhost /bin]$bg shell #rom#t reo-eredJ issue the b! ommand
[1]+ xclock & xlok is runnin! in the bak!round
[mike localhost /bin]$
Notice the [1]+ symbol above. The integer is the process' Mob number( which it can be referred to as.
The '+' sign indicates the last modified process. A '-' sign would indicate the second last modified process.
________________________________________________________________________________________
Page 85
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
One can start a process in the background by appending a ) to the command.
xc)oc0O
6(7 I2(;
Listin! Kobs
The Kobs utility lists all running processes started from the current shell. The Mob number, the job's state
(running/stopped), as well as the two last modified processes, will be listed.
Output for Mobs
[1]- Stopped xclock
[2] Running xman &
[3]+ Stopped xload
The Kob number
One can conveniently stop and start a selection of jobs using the Mob number. This is achieved with the f!
command.
)alling Mob 2 to the foreground and killing Mob 6
fg 2 or
fg %2 or
fg %?xma
kill 9 %1
A-oidin! (1P with nohu#
Finally there is a program called nohu# which acts as a parent process independently from the user's
session. When a user logs off, the system sends a HUP to all processes owned by that process group. For
example, to avoid this HUP signal a script called bi!ban! which attempts to calculate the age of the Universe
should be started like this:
nohup bigbang O
________________________________________________________________________________________
Page 86
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
&$ 3xerises and Summary
/e-iew =uestions (answers p.150)
Yes or No
1. Running kill against a process will always attempt to kill the given process _____
2. The commands '0i)) W(pido! xeyes ' and '0i))a)) xeyes ' are equivalent _____
3. A program started with a pending '&' will run in the background _____
4. A process's nice number is the same as its CPU priority _____
Glossary
Term Description
background
process
a process started on the shell with
Wcommand O
Unlike a foreground process the shell doesn't need to wait for the process to terminate before
running another command
foreground
process
a process started on the shell with
Wcommand
Once the process is started the shell has to wait for it to terminate before it can run another
command
orphaned
process
a process whose parent process has terminated. An orphaned process is then 'adopted' by
init
PD a number associated with a process
zombie
process
a process that has exited but is still considered by the parent process as present until the next
,ait() system call. The ,ait() system call performed by the parent process should refresh
the status of the child process as terminated if the process has exited. A zombie process
usually doesn't last for long. However due to bugs some zombie processes can last longer
taking up system resources even though the process itself has physically exited!
"ommands
Command Description (apropos)
bg resume a suspended job in the background
Ctrl+Z keyboard combination used to suspend the current foreground process
fg send a job in the foreground (making it the current process)
jobs list of processes started from the current shell
kill send a specified signal to a process using PDs
killall send a specified signal to a process using process names
nice starts a process with a modified scheduling priority
________________________________________________________________________________________
Page 87
LinuxIT Tehnial Trainin! "entre
Proess ,ana!ement
_________________________________________________
nohup nohu#A1B run a command immune to hangups, with output to a non-tty
ps #sA1B gives a snapshot of the current processes. f you want a repetitive update of this
status, use to#
pstree prints current processes in a hierarchical tree rooted (by default) at init
renice modified scheduling priority of a running process
top to#A1B display top CPU processes
3xerises
1$ Check the current nice value of your running x-terminal. Change this value using to# or renie.
5$ What is the equivalent signal of a [Z sent to a process? (List all signals with kill Gl)
9$ Which signal is redefined for most daemons and forces the configuration file to be reread?
&$ What is the default signal sent to a process, using kill or killall?
;$ Which signal is directly handled by the kernel and cannot be redefined?
%$ Make sure you log into a virtual terminal (tty1 to tty6) before doing this. We want to run a script that will
continue to run once we logout using the nohu# parent process.
n the @tm# directory create a file called print"out with the following content:
count80
,hi)e (true) do
echo this is iteration number Wcount
)et countP8(
done
We first do the following (without using nohu#) :
cd tmp
.print1out O
exit
You may not see the command line when typing exit but this should log you out. When you log back
in check that print"out is no longer running
ps ux M grep print1out
Next start the command with
nohup tmpprint1out O
exit
Log back in and test these commands
ps ux Mgrep print1out
tai) 1! anohup.out
Ctr)PC
0i))a)) print1out
ps uxMgrep print1out
tai) 1! anohup.out
________________________________________________________________________________________
Page 88
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
$e't 0rocessing
Prere*uisites
The Command Line (p.56)
Goals
Effectively manipulate files and data streams to alter the content as required ( e.g sort or format)
mprove command line skills by memorising and understanding simple text tools
"ontents
T37T P/0"3SSI+G$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$<:
1. cat the Swiss Army Knife....................................................................................................................90
2. Simple tools........................................................................................................................................91
3. Manipulating text................................................................................................................................93
4. Exercises and Summary.....................................................................................................................96
________________________________________________________________________________________
Page 89
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
1$ at the Swiss Army \nife
at the editor
The at utility can be used as a rudimentary text editor.
cat 5 short1message
,e are curious
to meet
penguins in Prague
Crtl+D
Notice the use of Ctrl+D. This command is used for ending interactive input.
at the reader
More commonly at is used only to flush text to stdout. Most common options are
.n number each line of output
.b number only non-blank output lines
.A show carriage return
Example
cat etcreso)*.con!
> search mydomain.org
nameser*er (2E.0.0.(
ta reads bak.to.front
This command is the same as at except that the text is read from the last line to the first.
tac short1message
> penguins in Prague
to meet
,e are curious
________________________________________________________________________________________
Page 90
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
5$ Sim#le tools
usin! head or tail
The utilities head and tail are often used to analyse logfiles. By default they output 10 lines of text. Here are
the main usages.
List 20 first lines of @-ar@lo!@messa!es:
head 1n 20 *ar)ogmessages
head 120 *ar)ogmessages
List 20 last lines of @et@aliases:
tai) 120 etca)iases
The tail utility has an added option that allows one to list the end of a text starting at a given line.
List text starting at line 25 in @-ar@lo!@messa!es:
tai) P25 etc)ogmessages
Exercise: f a text has 90 lines, how would you use tail and head to list lines 50 to 65? s there only one way
to do this ?
Finally tail can continuously read a file using the .f option. This is most useful when you are expecting a file to
be modified in real time.
ountin! linesJ words and bytes
The w utility counts the number of bytes, words, and lines in files. Several options allow you to control w's
output.
Options for w
.l count number of lines
.w count number of words
. or .m count number of bytes or characters
Remarks:
With no argument w will count what is typed in stdin.
________________________________________________________________________________________
Page 91
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
numberin! lines
The nl utility has the same output as at .b.
Number all lines including blanks
n) 1ba etc)i)o.con!
Number only lines with text
n) 1bt etc)i)o.con!
re#lain! tabs with s#aes
The ex#and command is used to replace TABs with spaces. One can also use unex#and for the reverse
operations.
-iewin! binary files
There are a number of tools available for this. The most common ones are od (octal dump) and hexdum#.
s#littin! files
The s#lit tool can split a file into smaller files using criteria such as size or number of lines. For example we
can spilt /etc/passwd into smaller files containing 5 lines each
sp)it 1) 5 etcpass,d
This will create files called xaa, xab, xac, xad ... each file contains at least 5 lines. t is possible to give a more
meaningful prefix name for the files (other than 'x5) such as 'pass"G' on the command line
sp)it 1) 5 etcpass,d pass,d15
This has created files identical to the ones above (aa, xab, xac, xad ...) but the names are now passwd"Gaa,
passwd"Gab, passwd"Gac, passwd"Gad ...
________________________________________________________________________________________
Page 92
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
3rasin! onseuti-e du#liate lines
The uni* tool will send to STDOUT only one version of consecutive identical lines. Consider the following
example:
uni> 5 tmp$#IG$A
)ine (
)ine 2
)ine 2
)ine ;
)ine ;
)ine ;
)ine (
b&
The file /tmp/3'IN32 has the following content:
cat tmp$#IG$A
721e 1
721e .
721e 3
721e 1
NOTCE
From the example above we see that when using uni* non consecutive identical lines are still printed to
STDOUT. What is the content of /tmp/3'IN32 if we first send the STDN through sort (see p.94) as
follows:
sort M uni> 5 tmp$#IG$A
9$ ,ani#ulatin! text
The following tools modify text layouts.
hoosin! fields and haraters with ut
The ut utilility can extract a range of characters or fields from each line of a text.
The G option is used to manipulate characters.
Syntax:
04t L0 J(513e1,(513e.K
Example
cut Sc51(0,(51 etcpass,ord
________________________________________________________________________________________
Page 93
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
The example above outputs characters 5 to 10 and 15 to end of line for each line in /etc/password.
One can specify the field delimiter (a space, a commas etc ...) of a file as well as the fields to output. These
options are set with the Gd and Gf flags respectively.
Syntax:
04t -d Jde7282te(K -* J*2e7d9K
Example
cut 1d? 1! (,E 11output1de)imiter8c c etcpass,d
This outputs fields 1
st
and 7
th
of /etc/passwd delimited with a space. The default output"delimiter is the same
as the original input delimiter. The ..out#ut.delimiter option allows you to change this.
Koinin! and #astin! text
The easiest utility is #asteJ which concatenates two files next to each other.
Syntax:
:59te te)t1 te)t.
With Koin you can further specify which fields you are considering.
Syntax:
R'21 -R1 J*2e7d_148K -R.J*2e7d_148K te)t1 te)t. or
R'21 -1 J*2e7d_148K -.J*2e7d_148K te)t1 te)t.
Text is sent to stdout only if the specified fields match. Comparison is done one line at a time and as soon as
no match is made the process is stopped even if more matches exist at the end of the file.
sortin! out#ut
By default, sort will arrange a text in alphabetical order. To perform a numerical sort use the .n option.
formattin! out#ut with fmt and #r
You can modify the number of characters per line of output using fmt. By default fmt will concatenate lines
and output 75 character lines.
fmt options
.w number of characters per line
.s split long lines but do not refill
.u place one space between each word and two spaces at the end of a sentence
________________________________________________________________________________________
Page 94
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
Long files can be paginated to fit a given size of paper with the #r utility. One can control the page length
(default is 66 lines) and page width (default 72 characters) as well as the number of columns.
When outputting text to multiple columns each column will be evenly truncated across the defined page
width. This means that characters are dropped unless the original text is edited to avoid this.
translatin! haraters
The tr utility translates one set of characters into another.
Example changing uppercase letters into lowercase
tr Y/1DY Ya1bY 4 !i)e.txt
Replacing delimiters in @et@#asswd:
tr Y?Y Y Y 4 etcpass,d
Notice: tr has only two ar!uments! The file is not an argument.
________________________________________________________________________________________
Page 95
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
&$ 3xerises and Summary
/e-iew =uestions (answers p.150)
Yes or No
1. The commands 'cat %ILA ' and 'cat 4 %ILA ' will both display the contents of %ILA 99999
2. The command ')ast %ILA ' will display the 10 last lines of FLE _____
3. When altering lines from a file using ut those changes are made on the STDOUT only _____
4. When running uni* against a file consecutive identical lines are deleted in the file _____
"ommands
Command Description (apropos)
at atA1B concatenate files and print on the standard output
ut utA1B remove sections from each line of files
ex#and ex#andA1B convert tabs to spaces
fmt fmtA1B simple optimal text formatter
head headA1B output the first part of files
Koin KoinA1B join lines of two files on a common field
nl nlA1B number lines of files
od odA1B dump files in octal and other formats
#aste #asteA1B merge lines of files
sort sortA1B sort lines of text files
s#lit s#litA1B split a file into pieces
ta taA1B concatenate and print files in reverse
tail tailA1B output the last part of files
tr trA1B translate or delete characters
unex#and unex#andA1B convert spaces to tabs
uni* uni*A1B remove duplicate lines from a sorted file
w wA1B print the number of bytes, words, and lines in files
3xerises
1$ Use at to enter text into a file called message.
cat 55 message
)ine (
b&
Do the same but use the keyword STOP instead of the predefined eof control (^D).
________________________________________________________________________________________
Page 96
LinuxIT Tehnial Trainin! "entre
Text Proessin!
_________________________________________________
cat 55 message 44 +T@P
)ine 2
+T@P
Next, append text to message using eho.
echo )ine ; 55 message
5$ Create a file called index with two fields 02/202')2 and &I&L2 separated by a space.
e.g 00( $sing9Linux
Create a second file pricing with two fields 02/202')2 and !0I)2 separated by a space
e.g 00( <.<<
Use Koin to display the reference, title and prices fields.
9$ Using tr replace all colons by semi-colons in /etc/passwd.
Do the same using ut.
&$ Use head and tail to list lines 70 to 85 of /%ar/log/messages
;$ Use the ut utility together with !re# and ifonfi! to printout only the P address of the first
network interface eth0.
%$ n @tm# make a directory called files
m0dir tmp!i)es
Create 50 files in that directory:
J]binbash
count80
,hi)e 6 Wcount 1)t 50 7- do
touch tmp!i)esWcount.txt
)et countP8(
done
We want to change all the txt extensions to dat extentions. For this we need to type the following on the
command line:
!or %ILA+ in W()s R.txt)
do
%ILA#/CA8W(echo W%ILA+M cut 1d. 1!()
m* W%ILA+ W%ILA#/CA.dat
done
________________________________________________________________________________________
Page 97
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
*oftware Installation
Prere*uisites
The Command Line (p.56)
Goals
Understand the use of a Makefile when compiling large projects from source
Manipulate source archives effectively and run the appropriate build commands
Fix problems related to shared (or dynamic) libraries
Use the RPM package manager to query, add, remove, update or verify software
"ontents
S0FT2A/3 I+STALLATI0+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$:<
1. ntroduction.........................................................................................................................................99
2. Static and Shared Libraries ............................................................................................................100
3. Source Distribution nstallation.........................................................................................................104
4. The RedHat Package Manager RPM ..............................................................................................107
5. Debian Package Management.........................................................................................................112
6. The Alien Tool..................................................................................................................................116
7. Exercises and Summary...................................................................................................................117
________________________________________________________________________________________
Page 98
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
1$ Introdution
We begin with a short code example. Although we don't need an advanced understanding of the C language,
these examples can help trouble shoot common situations.
&he mainc file:
Jinc)ude4std)ib.h5
int main()[
.e))o()-
\
&he 1elloc file#
Jinc)ude4stdio.h5
*oid .e))o()[
print!(2.i ] ^n3)-
\
Notice that the main.c is incomplete in the sense that the Hello() function is undefined. n the same way
.e))o.c doesn't have a "main declaration. So these files are interdependent. One can however compile
obKet files (.o) which are like non-executable binary files which can be used to 'build' an application.
)ompiling the obMect files#
gcc Sc main.c
gcc Sc .e))o.c
This will generate two files main.o and .e))o.o which can now be used to build the application a##.
)ompiling app #
gcc So app main.o .e))o.o
The L' option simply specifies a name for the compiled code. f no name is specified the compiled output is
called a$out by default.
All these steps can be automated using a ,akefile. Here is a minimal Makefile which would compile the a##
executable.
________________________________________________________________________________________
Page 99
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Makefile
+.ALL 8 binsh
CC 8 usrbingcc
app? main.o .e))o.o
W(CC) So app main.o .e))o.o
main.o? main.c
W(CC) Sc main.c
.e))o.o? .e))o.c
W(CC) Sc .e))o.c
5$ Stati and Shared Libraries
Functions that will often be used are archived as libraries. During compilation these libraries can be linked to
the code which uses the library function calls. The library can either be statically or dynamically linked to the
code.
The 300 compiler can link libraries in a variety a ways (many options). However by default it will link files that
are given on the commandline that don't have a >0 extention (only the >0 files are treated as code).
Listing 6# Linking by default
gcc main.c .e))o.o
This will produce an 5>'4t executable with the Hello.o object statically linked to it.
llustration of a statically linked application (a.out):
C Stati libraries
Static libraries are archived >' files. These archives are created with the 5( tool and have a >5 extention.
Listing2# adding an obMect file to an archi%e#
ar rcs )ib!oo.a !i)e(.o !i)e2.o
________________________________________________________________________________________
Page 100
(ello)o
a)out
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
C Dynami@Shared Libraries
A shared library is a library that will be loaded by the program when it is executed. One also says that the
library is dynamically loaded.
Listing ?# )reating a shared library#
gcc Sc S!PIC .e))o.c creates the object file
gcc Sshared SF(,soname,)ib!oo.so.( So )ib!oo.so.(.0 .e))o.o
The S!PIC flag enables the Position ndependent Code generation.
Listing+# )ompiling with a shared library#
gcc main.c )ib!oo.so.(.0
This will produce an a$out executable. However if you try to run this it will complain with the error message
listed below.
llustration of a dynamically linked application (a.out):
The process of attaching a dynamic library at run-time is called linking and is handled by the ld.so library.
How does the linker know where to find libfoo.so?
-hared library not found error#
.a.out? error ,hi)e )oading shared )ibraries? 72=*''>9'>1>0? cannot open
shared obTect !i)e? #o such !i)e or directory
This error illustrates the case where the linker could not find the dynamic library libfoo.so.1.0. n the next
section we will see what can be done to fix this problem.
________________________________________________________________________________________
Page 101
lib*oo)so
a)out
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
C Shared Library namin! and dynami loadin!
We will use the above example to understand how Linux libraries are maintained.
/igure 6# &he -hared Library 'ames
To find out which shared libraries an executable needs at execution time the 7dd tool is used.
2xample#
)dd a.out
> )ib!oo.so.(.0 85 1't *'41d
)ibc.so.I 85 )ib)ibc.so.I (0x=002H000)
)ib)d1)inux.so.2 85 )ib)d1)inux.so.2 (0x=0000000)
Notice that lifoo-so-1-) is not found. This is because the 5>'4t needs to dynamically load this library
and the dynamic linker 7d>9' is not aware of this new library.
n fact the linker uses a database called the ldcache containing entries of the form:
soname =>/path/to/library
The content of the ld-cache can be viewed with the following command:
)dconfig -p
+ libaudiofile.so.0 (libc6) => /usr/lib/libaudiofile.so.0
libaudiofile.so (libc6) => /usr/lib/libaudiofile.so
libaudio.so.2 (libc6) => /usr/X11R6/lib/libaudio.so.2
libattr.so (libc6) => /usr/lib/libattr.so ..........
The ld-cache is generated at boot time by the same ldonfi! tool. By default ldonfi! will scan the
directories @lib and @usr@lib to build the ld-cache.
________________________________________________________________________________________
Page 102
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
f libraries are installed in different locations (e.g @usr@loal@lib, @o#t@lib or @usr@711/%@lib) these directories
need to be listed in @et@ld$so$onf allowing ldonfi! to take these directories into consideration when
building the cache.
2hat ha##ens when an a##liation is startedP
The application will ask the linker for the dynamic libraries it needs using a soname, the linker will then query
the ld-cache and associate this name with the full path to the actual library. Once the full path is known the
linker can link the library to the application.
2hat ha##ens if the ld.ahe doesn]t ontain the full #ath to the libraryP
n general the application will fail to start and will print an error message saying " cannot open shared
obTect !i)e? #o such !i)e or directory ". But one can also define a global variable called
LD_LBRARY_PATH and assign to this variable the name of the directory containing the library.
Knowing this we can now fix the problem with our application above using one of the tw0 methods below:
1. f the binary needs to be temporary tested define the LD_LBRARY_PATH variable as follows:
export L&9LIDB/BQ9P/T.8W(p,d)
2. f you are root and would like the library to be available for all then copy the 72=*''>9'>1>0 file to
/49(/7'057/72=/ and run 7d0'1*23 to update the ld cache.
The GNU specification advises libraries to be stored in /49(/7'057/72=. These guidelines are
followed by developers and most tarballed code will install libraries in that directory and the binaries
in /49(/7'057/=21. nstalling and removing this code from the system would be done by make
install and make uninstall.
The FHS (Filesystem Hierarchy Standard) recommends libraries be kept in /49(/72=/ and
associated binaries in /49(/=21/. This convention standard is adhered to by Linux distributions.
n effect mature and stable code is stored in /49(/ rather than /49(/7'057/ and the two
standards do not lead to any contradictions. nstalling and removing this code code would be done
using the rpm command.
NOTICE
With certain distributions the /usr/local/lib/ directory is not scanned by 7d0'1*23. t is simply a
matter of adding this directory to /et0/7d>9'>0'1* and ... reboot?
________________________________________________________________________________________
Page 103
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
9$ Soure Distribution Installation
Open source projects are often distributed as tarballs (i.e compressed tarred archives). Many development
environments (glade, kdevelop.) generate the files that help facilitate compiling and installation of a project.
1nom#ressed Arhi-es
Uncompressed archives have a $tar extension. For example if a project has been developed in a directory
called my.#roKet.-$1@ then the following command would archive this directory with all its files and
subdirectories:
tar c my1proTect1*.( 5 my1proTect1*.(>t5(
or
tar c! my1proTect1*.(>t5( my1proTect1*.(
Since most projects are very large and are available for download from the nternet they are rarely
uncompressed.
"om#ression
The three compression tools commonly used are om#ress (old), !^i# and b^i#5. Unlike the windows ^i#
these compressions can only be applied to files. But since an archive is a file that contains all the data
needed to recover directories, these compressions are suitable for archives. A compressed archive is then
called a tarball.
compression tool de-compression tool cat decompression file extension
om#ress unom#ress ^at .Z
!^i# !un^i# ^at .gz
b^i#5 bun^i#5 b^at .bz2
2xamples
compress 1* %ILA(
FILE1: -- replaced with FILE1.Z Compression: !.2"#
g:ip 1* %ILA2
FILE2: $%.# -- replaced with FILE2.&'
b:ip2 1* %ILA;
FILE%: 2.%2(:1) %.%" *its+*yte) $,.!1# sa-ed) (!$$! in) 2(!%2! o.t.
________________________________________________________________________________________
Page 104
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
1O$IC+
1$ When compressing a file, the original file name is appended a .Z,.!^ or .b^5
5$ Compression tools listed above only work on files and not on directories
9$ Only one file at a time can be compressed (no wild cards!)
The ^at and b^at tools can be used to decompress files, however the decompressed file will be sent to
STDOUT so it is necessary to use a file redirection:
:cat %ILA(.N 5 %ILA(
Arhi-es and "om#ression
compression tool tar switch archive extension
om#ress Z .tar.Z or .tgZ
!^i# z .tar.gz or .tgz
b^i#5 j .tar.bz2
The table above introduces the tar options Z,z and j which call the appropriate compression tools when
needed.
The next two examples are equivalent:
tar c! my1proTect1*.(>t5( my1proTect1*.(
b:ip2 my1proTect1*.(>t5(
tar cT! my1proTect1*.(>t5(>=A. my1proTect1*.(
2orkin! with tarballs
We know how to create archives. All we need is an overview of the main tar switches.
tar operations Create Extract Test
minimal switches c or cf xf tf
optional switches v,Z,z,j v,Z,z,j v,Z,z,j
________________________________________________________________________________________
Page 105
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Examples (extractions)
tar x*T! myproTect1*.(.tar.b:2
tar x:! some1other1proTect1*.2.0.tar.g:
Examples (tests)
tar tT! myproTect1*.(.tar.b:2
tar t:! some1other1proTect1*.2.0.tar.g:
Alternative Examples (using ^at and b^at)
b:cat myproTect1*.(.tar.b:2 M tar x! 1
:cat some1other1proTect1*.2.0.tar.g: M tar t! 1
Common (iles
Once a project has been extracted you can expect to find the following files:
configure: This is a script which determines what architecture is being used. t also checks that the required
compiler, libraries an headers are present. This information is then stored in files called Ca0e!i)e
The safest way to run the script is to use '.con!igure'.
You can also decide where the project will be installed using the S1pre!ix option. The default installation
directory for most projects is @usr@loal. f you want to install the compiled project in your home directory you
should type:
.con!igure Spre!ix8W.@CA
Makefile: This acts like a configuration file for the make utility. The main information provided is:
- The name of the compiler and compiling options
- The path to the shared libraries and header files
- Mapping between code files (.c) and object files (.o)
________________________________________________________________________________________
Page 106
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Compiling t%e pro:ect
f the files above are present then there is a good chance that you will successfully 'port' the program to your
computer. Here are the routine steps:
.con!igure
ma0e
ma0e insta))
t is strongly recommended to run $@onfi!ure and make as a non root user.
ma0e insta)) must be run as root only if the installation directories are write protected (/usr/ or /usr/local).
There are many options to the $@onfi!ure script. To customise your installation you could type
.con!igure S1he)p
&$ The /ed(at Paka!e ,ana!er /P,
Most Linux distributions manage software using some form of package management to perform tasks such
as installations, updates and queries. The most popular package types are Debian and RPM. We only cover
RPM in this manual.
&he /unctions of a !ackage Manager
________________________________________________________________________________________
Page 107
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Paka!e namin!
There is no strict convention but most rpm package names are formed as follows:
name"%ersion"releasearchitecturerpm
The architecture name can either indicate which computer architecture the enclosed binaries are made for
(e.g i386, ppc, ia64, noarch) or it can indicate that the package contains the source code (src).
,aKor and minor modes
Some short name options are similar but perform different actions depending on their position on the
command line. A distinction is made between the first option and other options.
The first option given to r#m is in major mode. For example in rpm 1i* /.rpm the option 'i' is a major
option and will cause package 4 to be installed.
Similarly an option that is not in first position is in minor mode. For example in rpm 1>pi /.rpm the option
'i' is a minor mode and will get information from the package 4 such as the author and the licence type.
These are the major mode options for r#m.
Short Lon! Desri#tion
.i install nstalls the package
.1 update Updates or installs a package
.F --freshen Updates only installed package
.4 --verify file size, MD5, permissions, type ...
.* --query Queries installed/uninstalled packages, and files
.e erase Uninstall package
These are the minor mode options for r#m.
Short Desri#tion
a applies to all installed packages
together with * lists onfiguration files
d together with * lists documentation files
f together with * queries which package installed a given file
h adds hashes while processing
i together with * lists information about a package
l together with * lists all files and directories in a package
# together with * specifies that the query is performed on the package file
- verbose
=uery modes
&hree :uery types# uninstalled packages( installed packages and files
Query Type Option
Package file .*#
nstalled package .*
File .*f
An extra option will allow you to get information on all installed files Gl, documentation Gd configuration files G
, etc ...
________________________________________________________________________________________
Page 108
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
We consider for example the package routed.0$16$i9<%$r#m. We can query this package and list its contents
before installation with the l option as follows:
rpm S>p) routed10.(E.i;HI.rpm
Once this package is install we can query the installed package with:
rpm S>) routed10.(E or
rpm S>) routed
Finally if we want to find out which package installed the file @usr@sbin@routed the rpm database can be
queried with:
rpm S>! usrsbinrouted
S#eial 0#tions
..node#s install a package regardless of dependencies
..fore force an upgrade
..test doesn't actually install or upgrade, just prints to stdout
..re*uires PACKAGE together with * lists capabilities required by a package
..whatre*uires CAPABLTY together with * lists packages which require the capability
Paka!e Si!natures
You can check the signature of each package that is distributed as part of a project. For example to load the
keys of all the developers involved with the Fedora project do the following (just once):
rpm -import /usr/share/rhn/RPM-GPG-KEY-fedora
You can now download any package from an FTP site which mirrors the project's RPMs. For example we
downloaded ^lib.1$5$1$1.5$1$i9<%$r#m from ftp.mirror.ac.uk in the Fedora subdirectory. We next check the
authenticity of the file:
rpm --checksig /home/adrian/zlib-1.2.1.1-2.1.i386.rpm
/home/adrian/zlib-1.2.1.1-2.1.i386.rpm: (sha1) dsa sha1 md5 gpg OK
________________________________________________________________________________________
Page 109
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Paka!e Inte!rity
The next command checks the integrity of the package bash:
rpm V bash
This returns nothing. We next do the following as user root:
chown bin /bin/bash
chmod 775 /bin/bash
f we check the integrity of bash again this time we get:
rpm V bash
.M...U.. /bin/bash
The package manager has compared the current status of all files which are part of the bash package with
the known original state of these files stored in a database. The changes made to @bin@bash have been
identified.
t is possible to verify the integrity of all packages installed on the system by adding the 'a' (--all) option
after '4' (--verify)
The verify option performs a number of tests on each file; when a test is positive a number of characters
(listed below) are used to identify the errors:
Returned character Error description
$ the test was successful
P the test couldn't be performed
S file size has changed
, permission mode or file type has changed
; the file's MD5 sum has changed
D device major/minor number miss-match
L broken symbolic link
1 the user owner of the file has changed
G the group owner of the file has changed
T the mtime (modified time) has changed
________________________________________________________________________________________
Page 110
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Goin! Further' >uildin! /P, #aka!es Anot for &0I e'am prposeB
NOTICE:
This is additional information, this paragraph is not an LP 101 objective. When doing this section you may
encounter problems with the -rebuild option, this is due to the fact that the new versions of RPM use
r#mbuild instead of r#m when rebuilding packages.
The source code for many RPM packages is also available as an RPM package and will be used to build a
binary package. The naming convention is:
name1*ersion1re)ease.src.rpm
These packages contain at least two files, the tarball with the code and a spec file. The spec file contains
instructions to patch, compile and build the RPM package. f the code needs to be patched before
compilation then the patches are included in the source package.
There are three different ways to build a RPM package. We will assume that we have a package called
name1*ersion1re)ease.src.rpm.
/or these methods to work you first need to install the rpm-bild package
Method 6:
nstall the RPM source package with:
(:8 L2v; 158e-ve(92'1-(e7e59e>9(0>(:8
This will copy files to the following directories:
usrsrcredhat+PAC+
usrsrcredhat+@$BCA+
n the usrsrcredhat+PAC+ directory there is now a file called name$s#e (where 'name' is the name
of the package). To start building the compiled package, that is name.-ersion.release$i9<%$r#m, we type in
the following command:
(:8 L=5 158e>9:e0
This will start a series of scripts. The tarball in usrsrcredhat+@$BCA+ will be unpacked in
usrsrcredhatD$IL&.
f the compilation succeeds then the built binary package will be saved in usrsrcredhatBPC+.
There are different subdirectories corresponding to various CPU models/generations. f the compilation didn't
involve specific features from these chips then the package will be saved in the noarch directory.
Method 2:
This method triggers the same chain of events as the previous one but is started with the following single
command:
________________________________________________________________________________________
Page 111
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
(:8 L-(e=427d 158e-ve(92'1-(e7e59e>9(0>(:8
Method ?:
n some cases developers will distribute a tarball together with a spec file. f the tarball is called name1
*ersion1re)ease.tar.g: you can search for a .spec file with the following:
t5( tAv* 158e-ve(92'1-(e7e59e>t5(>3A S 3(e: >9:e0
f the tarball has a spec file then you can build an RPM package by typing:
(:8 L=t 158e-ve(92'1-(e7e59e>t5(>3A
;$ Debian Paka!e ,ana!ement
Systems using Debian based variants of Linux don't use the rpm package management system, but rather
the Debian Package Management system. The Debian system is more rigorous and configurable than the
rpm system, but for historical reasons is less widely used.
The approach used by the the Debian system is very similar to that used by the rpm system. The equivalent
command to 'rpm' in a Debian system is 'd#k!'.
Paka!e +amin!
Similarly to RPM-based system, Debian packages come in files whose names are formed as follows:
name<%ersion"release<architecturedeb
The release number indicates which Debian release of the version of the software the package contains,
while the architecture name specifies the computer architecture (i386, sparc, all).
d#k!
dpkg is a medium-level tool to install, build, remove and manage Debian packages. Other front-end
packages are more commonly used to contol d#k!J including the a#t tools and others such as dselet.
d#k! itself is controlled via command line parameters, which consist of an action and zero or more options.
The action parameter tells dpkg what to do and options control the behaviour of the action in some way.
d#k! maintains some usable information about available packages. The information is divided in three
classes: states, seletion states and fla!s.
Paka!e States
State Description
installed The package is unpacked and configured OK.
half.installed The installation of the package has been started, but not completed for some reason.
not.installed The package is not installed on your system.
un#aked The package is unpacked, but not configured.
half.onfi!ured The package is unpacked and configuration has been started, but not yet completed for
some reason.
________________________________________________________________________________________
Page 112
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
onfi!.files Only the configuration files of the package exist on the system.
Paka!e Fla!s
Flag Description
hold A package marked to be on hold is not handled by d#k!, unless forced to do that with
option fore.hold.
reinst.re*uired A package marked reinst.re*uired is broken and requires reinstallation. These
packages cannot be removed, unless forced with option ..fore.reinstre*.
Ations
The heart of dpkg operation is the command line parameters specifying the action which should be
performed. While there are a large number of these, the following table summarises the main actions you
are likely to require on any regular basis.
Action Description
.l Prints a list of the packages installed on the system, or matching a pattern if any is given.
The first three characters on each line show the state, selection state, and flags of the
package
.s Shows the status and information about particular installed package(s)
.I Show information about a package in a $deb file
.L List the files included in a package
.S Show the package which includes the file specified
.i nstall (or upgrade) and configure a package from a $deb file
..un#ak Unpack (only) a package in a $deb file
..onfi!ure Configure an unpacked package. With .a (or ..#endin!B configures all packages
requiring configuration
.r Remove a package (but leave its configuration files)
.P Purge remove a package along with its configuration files
..!et.seletions Get a list of package selections from a system (to stdout)
..set.seletions Set the list of package selections for a system (from stdin)
0#tions
All options can be specified both on the commandline and in the d#k! configuration file /etc/dpkg/dpkgcfg.
Each line in the configuration file is either an option (exactly the same as the commandline option but without
leading dashes) or a comment (if it starts with a _).
Option Description
.fore.t%ing Forces d#k! to perform an action which it would normally not take (for example, to
ignore dependency information - ..fore.de#ends, or to downgrade a package with
fore.down!rade)
..refuse.t%ing Refuse to do something which d#k! would normally automatically do
..i!nore.de#ends gnore dependency checking for a package
..no.at Show what d#k! would do, but don't do it (also: ..simulateB
________________________________________________________________________________________
Page 113
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
./ Recurse through directories (using with .i or ..un#ak)
Files
d#k! uses a number of files in its operation, including "etc"dpkg"dpkg.cfg which contains default
configuration settings.
Lists of available packages along with their statuses are held in the files
"!ar"lib"dpkg"a!ailable and @!ar"lib"dpkg"stats.
A $deb file, along with the files making up a packages programs, libraries and configuration, will also include
a number of control files which allow the execution of scripts before and after installation and removal, along
with lists of files and configuration files. These can be found in the "!ar"lib"dpkg"info directory once the
packages are installed.
1se of d#k!
To install a package from a .deb file, you could use dpkg as follows:
dpkg Si he))o92.(.(1=9i;HI.deb OR
dpkg --unpack he))o92.(.(1=9i;HI.deb
dpkg --configure he))o
To remove the hello package along with its configuration, you could use:
dpkg SP he))o
While:
dpkg Sr he))o
would remove only the package, leaving its configuration files installed.
The get a list of all the packages installed on the system, use the command:
dpkg S)
Note that when dealing with a package file, the filename is given, while when dealing with an installed
package, the package name only is given.
APT
________________________________________________________________________________________
Page 114
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
The d#k! tool is fine for installing individual packages with no dependencies, but when installing a number of
packages which may have dependencies, the APT tool is generally used instead.
APT is one of the strengths of dpkg, and provides an easy way of installing and updating a system. t is
controlled by two files:
File Description
@et@a#t@a#t$onf Contains general configuration options for APT, such as which release of Debian to
install, whether/which proxy settings to use, etc
@et@a#t@soures Lists sources of Debian files, which may be on CDs, or on the network
n general, to use APT you must first configure the sources it is to used. This can be done (if you are using
CDs) by using the command:
apt1setup
which asks the user to choose which mirror to download from, and tests it, or if you are using CDs, using:
apt1cdrom
which allows individual CDROMs to be scanned for packages.
Once APT knows where the Debian packages are located, two command line tools are used for package
management: a#t.ahe and a#t.!et.
a#t.ahe
a#t.ahe allows manipulation of the APT package cache (which is stored in files in "!ar"cac%e"apt). An
action normally follows apt-cache on the command line, and common options include:
Action Description
searh Search all the available package descriptions for the string given, and print a short
description of the matching package
show Shows a full description of the package specified
a#t.!et
While a#t.ahe is useful for finding out information about available packages, a#t.!et allows updating of
package information, retrieval, installation and removal of packages, and even upgrading of an entire Debian
distribution. apt-get expects an action to be provided on the command line, and the most common are listed
below:
Action Description
u#date Update the list of packages from the sources in /etc/apt/sources.list
install package nstall the package(s) specified, along with any dependencies
u#!rade Upgrade any packages which have newer versions available
________________________________________________________________________________________
Page 115
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
dist.u#!rade Upgrade entire distribution to the latest release (best to read the release notes first!)
remo-e Remove the package(s) specified
1se of APT
The two main uses of APT are for updating the system (for example if security-related updates have become
available). This is normally done using the two commands:
apt1get update
apt1get upgrade
The other main use of APT is to install required packages. This normally involves the following commands:
apt1get update Jupdate )ist o! pac0ages
apt1cache search !rob J!ind pac0ages re)ating to !robbing
apt1cache sho, !robnicate Jsho, in!ormation regarding a particu)ar
pac0age
apt1get insta)) !robnicate Jinsta)) !robnicate pac0age and its
dependencies
%$ The Alien Tool
The alien tool will change Debian packages into RedHat ones and vice versa. One can download it at:
http://kitenet.net/programs/
Convert a debian package to an rpm:
a)ien Sto1rpm pac0age.deb
Convert an rpm package to debian:
a)ien Sto1debian pac0age.rpm
________________________________________________________________________________________
Page 116
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
________________________________________________________________________________________
Page 117
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
6$ 3xerises and Summary
/e-iew =uestions (answers p.150)
Yes or No
1. When building a project from source one has to compile sections of the code in the
correct order using ! on the command line _____
2. The program make will only build a project if it is started in a directory containing
the appropriate Makefile _____
3. Pre-compiled binary packages and source code packages are two types of RPM
packages _____
4. Once shared libraries have been installed from source it is recommended to run ldonfi! _____
5. The ldonfi! tool is used to update the ld-cache _____
6. Program installed from source can be queried using a package manager _____
7. The APT tools can install packages and resolve all dependencies _____
Glossary
Term Description
build term used when compiling a project from source, usually started by typing make
compile translate programming instructions written in a high-level language into machine readable
code. The output of a compilation is called the object code
dynamic library
shared library
static library
a library that can be loaded at the same time as the execution of a program
a library intended to be used by more than one executable. Shared libraries are often
dynamic libraries and have a $so extension (shared object)
a library that is copied into the executable during the compilation. Static libraries have $a
extensions (archive)
high-level
language
a programming language readable by humans used to write source code
linker 1$ program used during the compilation process to assemble objects generated by the
compiler into an executable see ldA1B
5$ program that dynamically loads shared libraries needed by an executable at runtime
see ld$soA<B
object code the output of a compilation. Object code is either an executable or may be linked to
another object code to form an executable
source code programming instructions written in a high-level language that need to be compiled with a
compiler or interpreted with an interpreter
tarball a compressed tar archive
________________________________________________________________________________________
Page 118
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
Files
File Description
/etc/ld.so.conf configuration file for ldonfi!
Makefile file read by the make utility when building a project
/etc/rpmrc used by r#m and r#mbuild (see LP 201), this file contains information such as the
system's architecture or the path to macros and utilities used when handling packages.
This file is often located in the @usr@lib@r#m@ directory
/usr/lib/rpm/ directory containing all the macros needed when handling packages
/var/lib/rpm/ directory where databases for the package manager (RPM) are kept
"ommands
Command Description
alien alienA1B Convert or install an alien binary package. t converts between Red Hat rpm,
Debian deb, Stampede slp, Slackware tgz, and Solaris pkg file formats. f you want to use a
package from another Linux distribution than the one installed on your system you can use
alien to convert it to your preferred package format and install it
APT tools Tools used to perform advanced operations on Debian packages located on a CD or a
server
configure script often included with a project source code used to create makefiles. t attempts to
determine information such as the system's CPU type or installed components needed to
build the project(compiler, header files or libraries).
dpkg tool used to manipulate packages in the DEBAN format
LD_LBRARY_
PATH
environment variable containing the search path to shared libraries used by the linker
(ld.so)
ldconfig program that builds the 'ldcache' used by the linker to find shared libraries, with the .# flag it
will print the current content of the cache
ldd lddA1B prints the shared libraries required by each program or shared library specified
on the command line
make info make The `make' utility automatically determines which pieces of a large program
need to be recompiled, and issues commands to recompile them.
rpm tool used to manipulate packages in the RPM format
3xerises
n the following examples download a source RPM file (e.g. bash-2.05-8.src.rpm for RedHat 7.2) from
www.rpmfind.net.
1$ nstalling as a tarball.
- Extract the contents of the RPM package without compiling anything with:
rpm Si*h bash12.051H.src.rpm
- n the usrsrcredhat+@$BCA+ directory, unpack the tarball with:
tar x*:! bash12.051H.tar.g:
________________________________________________________________________________________
Page 119
LinuxIT Tehnial Trainin! "entre
Software Installation
_________________________________________________
- Optional (recommended!): The patches can be applied. Depending on which directory you are in
the syntax will vary.
From usrsrcredhat+@$BCA+?
patch Sp0 Sb 4 file.patch
From usrsrcredhat+@$BCA+bash12.051H
patch Sp( Sb 4 file-patch
- We will choose to install the files in a temporary root directory, for example @tm#@#roKet.test/. On a
production system the usual location should be usr)oca). We create this directory:
m0dir tmpproTect1test
- Finally follow the usual compilation steps.
.con!igure Spre!ix8tmpproTect1test
ma0e
ma0e insta))
You can now list the content on @tm#@#roKet.test.
5$ (Going further not required for LP101) We next rebuild the project into an RPM package.
rpm S1rebui)d packa,e.src.rpm
The compiled binary package should be in usrsrcredhatBPC+
- Check the package's contents with the G*#l option
- nstall the package(s), and run queries on the installed package
- Uninstall the package
9$ Configure @et@a#t@soures using a#t.setu#. Use the APT tools and d#k! to query/install/update available
packages.
________________________________________________________________________________________
Page 120
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
.d!anced $e't Maniplation
Prere*uisites
The Command Line (p.56)
Text Processing (p.90)
Goals
Distinguish expressions used for file globbing (metacharacters) and regular expressions
Use the !re# tools effectively
Understand simple sed commands
"ontents
AD4A+"3D T37T ,A+IP1LATI0+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$150
1. Regular Expressions..................................................................................................................121
2. The grep family..........................................................................................................................121
3. Working with grep......................................................................................................................122
4. egrep and fgrep.........................................................................................................................122
5. The Stream Editor - sed.............................................................................................................123
6. Exercises and Summary............................................................................................................125
_____________________________________________________________________________________
Page 121
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
0-er-iew
Finding a word or multiple words in a text is achieved using !re#, f!re# or e!re#. The keywords used
during a search are a combination of letters called regular expressions Regular expressions are
recognised by many other applications such as sed, and -i.
1$ /e!ular 3x#ressions
Traditional /e!ular 3x#ressions Are!exB
A regular expression is a sequence of characters (or atoms) used to match a pattern. Characters are
either constants (treated literally) or metacharacters.
&able6# Main metacharacters
"haraters Searh ,ath
TMKEY Words beginning with 'KEY'
WORDTL Words ending with 'WORD'
[ Beginning of a line
V End of a line
H Range I Range of ASC characters enclosed
H[c I Not the character 'c'
T[ nterpret character '[' literally
"ca*t Strings containing 'c' followed by no 'a' or any
number of the letter 'a' followed by a 't'
". Match any single character
3xtended re!ex: The main eregex's are: +,?,() and |
&able2# List of main eregex
"haraters Searh ,ath
`A1NA2NA3` Strings containing 'A1' or 'A2' or 'A3'
"caat" Strings containing a 'ca' followed by any number
of the letter 'a' followed by a 't'
"caPt" Strings containing 'c' followed by no 'a' or exactly
one 'a' followed by a 't'
"caOt" Strings containing 'c' followed by no 'a' or any
number of the letter 'a' followed by a 't'
5$ The !re# family
basi !re#
The !re# utility supports regular expressions regex such as those listed in &able6.
e!re#
The e!re# tool supports extended regular expressions eregex such as those listed in &able2.
_____________________________________________________________________________________
Page 122
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
f!re#
Fgrep stands for fast grep and f!re# interprets strings literally (no regex or eregex support)
9$ 2orkin! with !re#
-yntax for grep#
3(e: &A""ERN FILE
!re# Main Options
. count the number of lines matching PATTERN
.f obtain PATTERN from a file
.i ignore case sensitivity
.n indicate the input file's line number
.- output all line except those containing PATTERN
.w match exact PATTERN
For example list all non blank lines in /etc/lilo.conf:
grep S* 2bW3 etc)i)o.con!
&$ e!re# and f!re#
The f!re# utility does not recognise the special meaning of the regular expressions. For example
!grep dcatRe %ILA
will only match words containing 'cat*'. The main improvement came from f!re#'s ability to search from a
list of keywords entered line by line in a file, say LST. The syntax would be
!grep S! LI+T %ILA
The e!re# utility will handle any modern regular expressions. t can also search for several keywords if
they are entered at the commandline, separated by pipes. For example;
egrep 2)inuxMbimage3 etc)i)o.con!
_____________________________________________________________________________________
Page 123
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
;$ The Stream 3ditor . sed
At this point the stream editor makes its appearance! t is an old type of tool and originally the only one
available under UNX to manipulate text.
The sed utility is most often used to search and replace patterns in text. t supports most regular
expressions.
;.7 3eginning sed
-yntax for sed
9ed /':t2'196 T0'8851dU /IN&!"FILE6
The input file is optional since sed also works on file redirections and pipes.
Here are a few examples assuming we are working on a file called MODF.
.elete all commented lines#
sed dbJ d e C@&I%
Notice that the search pattern is between the double slashs //.
-ubstitute /de%/hda6 by /de%/sdb?#
sed ds/^de*^hda(/^de*^sdb;/ge C@&I%
The s in the command stands for 'substitute'. The ! stands for "globally and forces the substitution to
take place throughout each line.
If the line contains the keyword I29 then substitute O#H with OPH globally#
sed d LAQ s?-ge C@&I%
;.2 More .d!anced sed
You can issue se-eral ommands each starting with Ge at the command line. For example, (1) delete all
blanks then (2) substitute 'OLD' by 'NEW' in the file MODF
sed Se dbW de 1e ds@L&#AFge C@&I%
_____________________________________________________________________________________
Page 124
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
These commands can also be written to a file, say COMMANDS. Then each line is interpreted as a new
command to execute (no quotes are needed).
4n example )OMM4'.- file
( so)dne,
0ey,ord so)dne,g
2;,25 d
The syntax to use this )OMM4'.- file is:
9ed -* COMMANDS MODIF
This is much more compact than a very long commandline !
-ummary of options for sed
)ommandline flags
.e Execute the following command
.f Read commands from a file
.n Do not printout unedited lines
sed commands
d Delete an entire line
r Read a file and append to output
s Substitute
w Write output to a file
_____________________________________________________________________________________
Page 125
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
%$ 3xerises and Summary
/e-iew =uestions (answers p.151)
Yes or No
1. The extended regular expression 'nuc)eZar' will match nuc)ear and nuc)ar
____
2. The regular expression 'ba:aRr' will match ba:aar and ba:ar but not ba:or ____
3. The extended regular expression 'nuc)ePar' will only match nuc)ear
____
4. The regular expression 'ba:aR' will match ba:aar, ba:ar and ba:or
____
"ommands
Command Description or apropos
egrep print lines containing matching patterns using extended regular expressions
fgrep print lines containing matching patterns using literal stings
grep print lines containing matching patterns using regular expressions
sed sedA1B stream editor is used to perform basic text transformations on an input stream
(a file or input from a pipeline)
3xerises
1. Create a new file called FLE containing the lines:
Using grep,
fgrep and
egrep
to grep for 99% of the cats
% these are two
% commented lines
- Use !re# to output only uncommented lines.
- Find all lines containing 'grep' exactly. (Not 'egrep' nor 'fgrep'.Use .w to match the word)
- Find lines containing words starting with an 'a'
2. Regular expressions. Append the following lines to the previous file:
ct
cat
caats
caaatss
ca+t
ca*t
ca?t
_____________________________________________________________________________________
Page 126
LinuxIT Tehnial Trainin! "entre
Ad-aned Text ,ani#ulation
______________________________________________
crate
carts
- nvestigate the outcome of the following using !re#, e!re# and f!re#:
grep YcaPtY %ILA
grep YcaZtY %ILA
grep Yca.tY %ILA
grep YcaaRtY %ILA
grep YcaRr.Y %ILA
3. Use sed to do the following changes in FLE
(use a COMMAND file, then do everything on the commandline)
- in the first line substitute 'grep,' with 'soap'
- delete '!grep' in the second line
- substitute 'egrep' with ' ,ater'
- in the fourth line replace 'grep !or' with ',ash'
Save the result to a file using the w option
_____________________________________________________________________________________
Page 127
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
5sing !i
Prere*uisites none
Goals
Understand the three operating modes of -i
ntroduce most common editing commands
Recognise the use of regular expressions and sed-like commands
"ontents
1SI+G 4I$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$156
1. vi Modes....................................................................................................................................128
2. Text tems..................................................................................................................................128
3. nserting Text.............................................................................................................................129
4. Cut and Paste............................................................................................................................129
5. Copy Paste................................................................................................................................130
6. Search and Replace .................................................................................................................130
7. Undo and Redo..........................................................................................................................130
8. Running a Shell Command........................................................................................................131
9. Save and Quit............................................................................................................................131
10. Exercises and Summary..........................................................................................................132
_____________________________________________________________________________________
Page 128
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
n most Linux distributions -i is the text editor of choice. t is considered an essential admin tool such as
!re# or at and is found therefore in the @bin directory.
1$ -i ,odes
n order to perform complex operations such as copy/paste -i can operate in different modes.
C "ommand mode
This is the editing and navigation mode. Commands are often just a letter. For example use K to jump to
the next line.
As a rule of thumb if you want to perform an operation several times you can precede the command by a
number. For example 10K will jump 10 lines.
n some situations the arrow keys on the keyboard are not mapped properly, it is still possible to navigate
using the commands h K k l with the following effect:
C Last Line Aor olumnB ,ode
You enter this mode from the command mode by typing a colon$ The column will appear at the bottom
left corner of the screen. n this mode you can perform a simple search operation, save, quit or run a
shell command.
C Insert ,ode
The easiest way to enter this mode while in command mode is to use i or a. This mode is the most
intuitive and is mainly used to interactively enter text into a document.
The Esc key will exit the insert mode and return to command mode
5$ Text Items
tems such as words and paragraphs are defined in command mode to allow editing commands to be
applied to text documents without using a mouse.
2ordJ sentenes and #ara!ra#hs
e resp. b Move to the end/begining of the current word
A resp. B Move to the begining/end of the current sentence
Q resp.B Move to the begining/end of the current paragraph
w Similar to e but includes the space after the word
>e!innin! and 3nd
[ Beginning of line
V End of line
1G Beginning of file
G End of file
_____________________________________________________________________________________
Page 129
h j k l
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
All these text items can be used to navigate through the text one word (w) or paragraph (R)at a time, go
to the beginning of a line ([) the end of the file (G) etc. One can also use these text items to execute
commands such as deleting and copying.
9$ Insertin! Text
When in command mode typing i will allow you to enter text in the document interactively. As with all
other features in -i there are many other ways of doing this. The table below lists all possible inserting
modes.
nsert commands
a Append text with cursor on the last letter of the line
A Append text with cursor after last letter at the end of the line
i nsert text at the current position
o nsert text on a new line below
O nsert text on a new line above
s Delete the current letter and insert
S Delete current line and insert
A very useful option when modifying a document is to delete a section of text you wish to replace just
before entering insert mode. This is done by the change command. As the other commands in this
section will put you into NSERT mode but you can specify which portion of the text needs to be deleted
before. For example:
c$
will delete all the text from the current cursor position to the end of the line.
Another command used to replace a single character (nothing else!) is r. First choose which character
needs to be replaced and put the cursor on this character. Next press r followed by a new character. The
new character will replace the old one. This command will leave the editor in COMMAND and not
NSERT mode!
&$ "ut and Paste
f you want to delete a single character while in command mode you would use x and dd would delete
the current line. One can then paste the deleted item with the command #.
/emark: Nearly all -i commands can be repeated by specifying a number in front of the command. You
can also apply the command to a text item (such as word., sentence, paragraph ...) by placing the entity
after the command.
Examples:
Delete a word:
d,
Delete text from here to the end of the current line
dW
Delete text from here to the end of the current paragraph
d\
_____________________________________________________________________________________
Page 130
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
One can simultaneously delete an item and switch to insert mode with the command. As usual you can
use this command together with a text item such as w or Q.
;$ "o#y Paste
The copy action in -i is the command y (for yank, the letter was already taken for change), and the
paste action is still #.
f an entire line is yanked the pasted text will be inserted on the next line below the cursor.
The text selection is made with the familiar text items w, l, R, V etc ... There are a few exceptions such as
the last example.
Examples:
Copy the text from here to the end of the current line
yW
Copy the entire current line
yy
Copy 3 lines
;yy
The latest deleted item is always buffered and can be pasted with the # command. This is equivalent
to
a cut-and-paste operation.
%$ Searh and /e#lae
Since searching involves pattern matching we find ourselves once again dealing with regular expressions
(regex). As many UNX text manipulation tools such as !re# or sed, -i recognises regular expressions
too.
To perform a search one must be in COMMAND mode. The @ (forward slash) command searches
forward and the P command searches backwards.
One can also perform search and replace operations. The syntax is similar to sed.
Example:
Downward search for words beginning with 'comp' in all the text
^4comp
Upward search for lines starting with the letter z
Zb:
Search in the whole text for the keyword 'VAR' and replace it by 'var'
?V s'/B*ar
6$ 1ndo and /edo
_____________________________________________________________________________________
Page 131
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
At this stage is is worth mentioning that one can always undo changes! This must be done in COMMAND
mode with the u command (works as long as one hasn't yet saved the file). The redo command is [/.
<$ /unnin! a Shell "ommand
While in LASTLNE mode everything following an exclamation mark X is interpreted as a shell command.
For example while editing lilo.conf or grub.conf you may need to find out the name of the root device.
This can be done with:
:!df /
:$ Sa-e and =uit
The command for saving is 'w. By default the complete document is saved. n some case -i will refuse
to save changes made to a document because of insufficient rights. n such cases ione can attempt to
force a write with 'wX
One can also specify an alternative name for the file. Portions of the text can be saved to another file
while other files can be read and pasted in the current document. Here are the examples which illustrate
this.
Examples:
Save the current document as 'newfile'
?, ne,!i)e
Save lines 15 to 24 in a file called 'extract'
?, (5,2= extract
Read from file 'extract'. The text will be pasted at the cursor
?r extract
2arnin!: n the column mode context we have the following
$ is the current line
V is the end of the document
The following are different ways available to quit -i:
'w* save and quit
'*X quit but do not save changes
'x exit and save when changes exist
'*uit same as '*
'exit or 'e same as 'x
ZZ same as 'x
_____________________________________________________________________________________
Page 132
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
10$ 3xerises and Summary
/e-iew =uestions (answers p.151)
Yes or No
1. The command 'l' (lower case L) will place the cursor one position to the left _____
2. The command 3dd will delete three lines _____
3. The command 3wd will delete three words _____
4. The command :qw will write and exit _____
"ommands
vi action Description
^,$ beginning and end of line
1G,G beginning and end of document
b,e beginning and end of word
(,) beginning and end of sentence
{,} beginning and end of paragraph
w,W word and word including hyphens and punctuations
h,j,k,l left, up, down, right navigation commands
:! call a shell command
:quit,:q quit
:quit!,:q! force quit, discard changes
:wq write and quit
:exit,:x,:e,ZZ exit (saves changes if needed)
/,? search forwards or backwards
a,A,i,o,O,s,S start insert mode
c start insert mode while changing an item
r replace a single character in command mode
d,dd delete an item or delete entire line
x delete a single character
y,yy yank item or entire line
p paste content of buffer
u,^R undo, redo
_____________________________________________________________________________________
Page 133
LinuxIT Tehnial Trainin! "entre
1sin! -i
______________________________________________
3xerises
4s root cp "!ar"log"messages to "tmp 3sing !iHs search and replace utility make each line begin with
print < and end with <=
&ype QuR to undo all the changes
)opy "etc"lilo.conf to "tmp( edit this file and try to copy/paste ))/p and cut/paste with dd/p
In%estigate the outcome of -'( >>( -?it( -w?( and -?@ 7which ones sa%e and which one don5tS8
In%estigate the outcome for the %arious inserting modes# .( a( O( o( * and s
Optional# If you ha%e time the !im-en%anced package installs a program called !imttor which takes
you through most common !i options
_____________________________________________________________________________________
Page 134
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
$%e / +n!ironment
Prere*uisites None
Goals
Understand the different components of the "Xwindows" environment
Recognise the function of each configuration file (no editing is expected)
Run applications on any display
Understand the function of a display manager including XDMCP
"ontents
T(3 7 3+4I/0+,3+T$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$19&
1. ntroduction................................................................................................................................135
2. Configuring X11R6....................................................................................................................136
3. Controlling X clients...................................................................................................................138
4. Starting X...................................................................................................................................139
5. The Display Manager.................................................................................................................140
6. Troubleshooting X Clients..........................................................................................................144
7. Choosing a Window Manager....................................................................................................144
9. Exercises and Summary............................................................................................................145
_____________________________________________________________________________________
Page 135
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
1$ Introdution
The X Windows system was developed as the display component of Project Athena at the
Massachusetts nstitute of Technology. t is the graphical environment for UNX. The X Window system
for Linux is based on the freely distributable port of X Window version 11 release 6 (Commonly referred
to as X11R6).
This freely distributable port is commonly known as xfree<% for the 80386/80486 and Pentium processor
families. Since its initial port, Xfree86 has been ported to other computing platforms, including System
V/386 and 386BSD.
X11R6 Components and Configuration Sections
,ection $iles ,ection -onitor
,ection InputDe!ice ,ection InputDe!ice ,ection De!ice
,ection .ointer /old0 ,ection 12eyboard1 /old0
The above diagram shows the components of the X11R6 server. The "Section names refer to
configuration sections in the 7F<%"onfi! configuration file (covered in the next section).
The two clients depicted on top of the server are so-called x"applications (e.g xclock or xterm). The
window manager is also a client. Window managers add "windowing facilities around the other x-
application clients, allowing functionalities such as window dragging, focus, iconification, etc.
NOTICE:
The X11R6 server is independent from the clients that run on top. Clients are configured using specific
configuration files or global files usually called 7defaults or 7resoures. The X server configuration
file will only configure components such as the font server and font directories, mouse, keyboard,
monitor resolution and color depth.
_____________________________________________________________________________________
Page 136
X11R6
mouse
xfs
video ke!o"#d
mo$i%o#
wm
client A client B
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
5$ "onfi!urin! 711/%
Two of the configuration utilities provided with the Xfree86 software are the 7F<%Setu# and xf<%onfi!
scripts. Other vendors have specific utilities such as:
7onfi!urator, redhat.onfi!.xfree<% (RedHat)
7Fdrake (Mandrake)
sax (Suse)
Once the server has been configured one can change the horizontal and vertical settings for the monitor
with x-idtune.
All the above mentioned configuration utilities will create and edit the 7F<%"onfi! configuration file. This
file is read at start up by the X Server and determines its behaviour. This file is typically found in the
/etc/X11 directory, and this is its' full path: @et@711@7F<%"onfi!.
There are 11 configuration sections in the config file, they are listed below:
ServerFlags
Module
nputDevice
Device
VideoAdapter
Monitor
Modes
Screen
ServerLayout
DR
Vendor
NOTICE:
The obsolete section names Ieyboard and !ointer are still recognised for compatability reasons, the
new section name is now Input.e%ice
One of the first sections is the Section "Files. The %ontPath keyword tells whether to get fonts from a
local directory or from a font server. The BgbPath keyword is used to indicate the full path to rgb text file
used to map color names to RGB notation:
+ection 2%i)es3
%ontPath 2pathto!ontsdir3
%ontPath 2transhostname?port3
BgbPath cpathtorgbc
And+ection
Where trans is the transport type unix, hostname is the fully qualified domain name of the font server,
and port is the port to connect to, usually port 7100.
Example:
%ontPath 2unix?E(003 J Loca) %ont +er*er
%ontPath 2unixmy!ontser*er.mydomain.com?E(003
Below is a sample 7F<%"onfi! file :
_____________________________________________________________________________________
Page 137
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
+ection c%i)esc
BgbPath cusrK((BI)ibK((rgbc
%ontPath
cusrK((BI)ibK((!ontsmisc?unsca)ed,usrK((BI)ibK((!ontsE5dpi?unsc
a)ed,usrK((BI)ibK((!onts(00dpi?unsca)ed,usrK((BI)ibK((!ontsmisc
c
And+ection
+ection cInput&e*icec
Identi!ier cLeyboard0c
&ri*er c0eyboardc
And+ection
+ection cInput&e*icec
Identi!ier cCouse0c
&ri*er cmousec
@ption cProtoco)c cICP+2c
@ption c&e*icec cde*psauxc
@ption cN/xisCappingc c= 5c
And+ection
+ection cConitorc
Identi!ier cPrimary Conitorc
'endor#ame c$n0no,nc
Code)#ame c$n0no,nc
.ori:+ync ;(.51;E.<
'ertBe!resh 551<0
Code)ine cH00xI00c =0.00 H00 H=0 <IH (05I I00 I0( I05 I2H Phsync
P*sync
And+ection
+ection c&e*icec
Identi!ier cPrimary Cardc
'endor#ame c$n0no,nc
Doard#ame c#onec
'ideoBam 20=H
And+ection
+ection c+creenc
&ri*er c/cce)c
&e*ice cPrimary Cardc
Conitor cPrimary Conitorc
&e!au)tCo)or&epth 2=
D)an0Time 0
+uspendTime 0
@!!Time 0
+ub+ection c&isp)ayc
&epth 2=
Codes cH00xI00c
And+ub+ection
+ub+ection c&isp)ayc
&epth ;2
Codes cH00xI00c
_____________________________________________________________________________________
Page 138
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
9$ "ontrollin! 7 lients
Settin! Fonts and "olours
X clients are configured using the $7resoures or $7defaults file. These file are kept in the users home
directory. t is not automatically created by default, as system-wide defaults are also available for each
program.
Below is an extract from a $7resoures:
xterm9co)orRbac0ground? D)ac0
xterm9co)orR!oreground? Fheat
xterm9co)orRcursorCo)or? @rchid
xterm9co)orRre*erse'ideo? !a)se
xterm9co)orRscro))Dar? true
xterm9co)orRsa*eLines? 5000
xterm9co)orRre*erseFrap? true
xterm9co)orR!ont? !ixed
xterm9co)or.geometry? H0x25P20P20
xterm9co)orR!u))Cursor? true
xterm9co)orRscro))Tty@utput? o!!
xterm9co)orRscro))Ley? on
term9co)orR'T(00.Trans)ations? Jo*erride^n^
4LeyPress5Prior ? scro))1bac0((,page)^n^
4LeyPress5#ext ? scro))1!or,((,page)
xterm9co)orRtit)eDar? !a)se
Each of these directives is a system default directive that describes how a client will be displayed. Each
line consists of the client name followed by an asterisk and the X Window parameter. Through a carefully
configured .Xresources file the user can define the way a client will look each time it is started.
The DISPLA8 4ariable
When an x-application (or X client) is started it needs to know which X server to run on. An X server is
referred to as a display. For example the first X server you start ( using startx for example) is called '0
the second would be called '1 and so on. The first X server (or display) running on the host 192.168.1.99
is called 1:5$1%<$1$::'0
Most native X clients such as xterm or xlok have a -display switch which can be used to set the
display. But the easiest method is to set the environment variable called DSPLAY!
The next two commands are equivalent:
xc)oc0 1disp)ay (<2.(IH.(.<<?0
&I+PL/Q8(<2.(IH.(.<<?0 xc)oc0
However the X server on the host 192.168.1.99 will not allow this x-application to run. The user that
started the X server on the remote host (192.168.1.99) needs to run the xhost command. This tool can
selectively add or remove hosts to an access control list.
Example: Allow remote x-applications from host 192.168.1.7 to run on local server
_____________________________________________________________________________________
Page 139
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
xhost P (<2.(IH.(.E
19.>1$+>1>7 =e213 5dded t' 500e99 0'1t('7 729t
+0TI"3
The xhost mechanism must be used in conjunction with xauth (not part of the LP objectives). For a
remote x-client from 192.168.1.7 to run on our local server we still need to run the following on the local
host:
xauth extract 1 W&I+PL/Q M ssh (<2.(IH.(.E xauth merge 1
(Assuming that the user names are the same and that the hostname contained in $DSPLAY can be
resolved)
&$ Startin! 7
An X session can be started using 2 methods:
Method 1: From the command line, after logging in onto a virtual terminal the user launches the X Server
using a script called startx
Method 2: A Display Manager is running prompting the user with a graphical login, this is available for a
specific runlevel (on RedHat type distributions this is runle-el ;B.
1$ From the "ommand Line
The startx script starts xinit. The xinit script has two main arguments (a) the X server and (b) the
xinitr script. The xinitr script will source (read) the files 7resourses (controlling the x-applications)
and the 7lients (choosing a window manager). So we can trace the startup sequence as follows:
startx ..L xinit ..L 7 .L xinitr .L 7lients
5$ 1sin! a Dis#lay ,ana!er
A display manager will automatically be started if the system is running in a given runlevel (e.g runlevel
5). We first describe the login process, the next section covers more advanced functionalities of a
Display Manager. The login process follows the following steps:.
xdm ..L xlo!in ..L 7session ..L (optionally) 7lients or W@$7lients
Different versions of display managers as well as different Linux distributions may use slightly different
steps. n general however, note that startx uses xinit whereas xdm uses 7session.
CUSTOMSNG
Each user can further customise their environment by using a $xinitr file. This file will be merged into
the system xinitr.
The switdesk tool allows users to define a custom $7lients file
_____________________________________________________________________________________
Page 140
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
;$ The Dis#lay ,ana!er
There are three main display managers, xdm (generic), gdm (GNOME) and kdm (KDE). According to the
LP objectives the configuration files are in the following directories:
@et@711@xdm@
@et@711@!dm@
@et@711@kdm@ (see LP objectives at the end of this manual p.162)
However, most often the configuration files for kdm are in @usr@share@onfi!@kdm (also see below).
\D,
This display manager is installed with the KDE desktop environment. t is based on the generic xdm
display manager and shares many common configuration files. These configuration files for are in
@usr@share@onfi!@kdm. The file that controls most functionalities is kdmr.
The path to the kdm binary is @usr@bin@kdm
KDM Configuration files:
kdmr 7aess (same as xdm) 7ser-ers (same as xdm) 7session (same as xdm) 7setu#
7startu#
GD,
This display manager is distributed with the GNOME desktop environment. The main configuration file is
!dm$onf
The path to the !dm binary is @usr@bin@!dm
GDM Configuration Files ( @et@711@!dm )'
Sessions@ !dm$onf
7D,
The xdm display manager is part of the Xfree86 application. The main configuration file is xdm.onfi!
The path to the xdm binary is @usr@bin@xdm
XDM Configuration Files:
7aess 7resoures 7session xdm.onfi! 7ser-ers _
We will look at the xdm configuration files in more detail later in this section.
Display Managers are used mainly in run level 5:
Set default runlevel in @et@inittab
id?5?initde!au)t?
_____________________________________________________________________________________
Page 141
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
Display managers allow local users to log onto the system using the graphical interface. They can also
be used to provide a graphical login interface over the network. For this they use a protocol called
7D,"P or X Display Manager Control Protocol. By default XDMCP is disabled (we will enable XDMCP
as an exercise).
X server and Display Manager
3elcome 44
Dis&l" ("$")e#
/#-application0
xlo)i$
login
password
X11R6
"onfi!uration Files
/etc/L66/xdm/Lrescources
Since the Display Manager is also an x-application, the fonts, the background colors and xlo!in
can be configured with the 7resourses file in @et@711@xdm@. When using !dm, the
@et@711@!dm@Init@Default script will source 7resoures.
/etc/L66/xdm/Lser%ers
This file simply maps the name of a display with an X server. For example display '0 is
understood
to be the local X server. Remember that X always runs on the first free @de-@tty$
/etc/L66/xdm/xdm"config
This is the main configuration file for xdm. t is also used to enable XDMCP (see exercises)
/etc/L66/xdm/Laccess
This file is used to enable XDMCP, allowing remote hosts to directly connect to the local server
( using .*uery) or query about other display
_____________________________________________________________________________________
Page 142
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
!e Xaccess file
J WKConsortium? Kaccess,* (.5 <(0H2I ((?52?5( r,s Axp W
J
J /ccess contro) !i)e !or K&CCP connections
J To contro) &irect and Droadcast access?
J
J pattern
J
J To contro) Indirect >ueries?
J
J pattern )ist o! hostnames andor macros ...
J
J To use the chooser?
J
J pattern C.@@+AB DB@/&C/+T
J
J or
J
J pattern C.@@+AB )ist o! hostnames andor macros ...
J
J To de!ine macros?
J
J Vname )ist o! hosts ...
J
J The !irst !orm te))s xdm ,hich disp)ays to respond to itse)!.
J The second !orm te))s xdm to !or,ard indirect >ueries !rom hosts matching
J the speci!ied pattern to the indicated )ist o! hosts.
J The third !orm te))s xdm to hand)e indirect >ueries using the chooser-
J the chooser is directed to send its o,n >ueries out *ia the broadcast
J address and disp)ay the resu)ts on the termina).
J The !ourth !orm is simi)ar to the third, except instead o! using the
J broadcast address, it sends &irectGuerys to each o! the hosts in the )ist
J
J In a)) cases, xdm uses the !irst entry ,hich matches the termina)-
J !or IndirectGuery messages on)y entries ,ith right hand sides can
J match, !or &irect and Droadcast Guery messages, on)y entries ,ithout
J right hand sides can match.
J
R Jany host can get a )ogin ,indo,
J
J To hard,ire a speci!ic termina) to a speci!ic host, you can
J )ea*e the termina) sending indirect >ueries to this host, and
J use an entry o! the !orm?
J
Jtermina)1a host1a
J The nicest ,ay to run the chooser is to Tust as0 it to broadcast
J re>uests to the net,or0 1 that ,ay ne, hosts sho, up automatica))y.
J +ometimes, ho,e*er, the chooser canYt !igure out ho, to broadcast,
J so this may not ,or0 in a)) en*ironments.
J
R C.@@+AB DB@/&C/+T Jany indirect host can get a chooser
J I! youYd pre!er to con!igure the set o! hosts each termina) sees,
J then Tust uncomment these )ines (and comment the C.@@+AB )ine abo*e)
J and edit the Vhost)ist )ine as appropriate
J
JVhost)ist host1a host1b
JR C.@@+AB Vhost)ist J
_____________________________________________________________________________________
Page 143
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
The Xservers file
J WKConsortium? Kser*.,s.cpp,* (.; <;0<2H (=?;0?;0 gi)dea Axp W
J
J
J WK%reeHI? xcprogramsxdmcon!igKser*.,s.cpp,* (.(.(.(.(2.2 (<<H(00= (5?2;?(= hohnde) Axp W
J
J Kser*ers !i)e, ,or0station prototype
J
J This !i)e shou)d contain an entry to start the ser*er on the
J )oca) disp)ay- i! you ha*e more than one disp)ay (not screen),
J you can add entries to the )ist (one per )ine). I! you a)so
J ha*e some K termina)s connected ,hich do not support K&CCP,
J you can add them here as ,e)). Aach K termina) )ine shou)d
J )oo0 )i0e?
J KTermina)#ame?0 !oreign
J
?0 )oca) usrK((BIbinK
Since the Display Manager is also an x"application the 7resoures file is similar to the $7resoures
file except that it controls how the login screen is displayed .
Sample Xrescources file
] WKConsortium? Kresources mainH (<<I(((( 0<?2=?=I s,ic0 W
x)oginRborderFidth? ;
x)oginRgreeting? CLIA#T.@+T
x)oginRnamePrompt? )ogin?^0=0
x)oginR!ai)? Login incorrect
Ji!de! C@L@B
x)oginRgreetCo)or? CadetD)ue
x)oginR!ai)Co)or? red
R%oreground? b)ac0
RDac0ground? J!!!!!0
Je)se
x)oginR%oreground? b)ac0
x)oginRDac0ground? ,hite
Jendi!
KConso)e.text.geometry? =H0x(;0
KConso)e.*erbose? true
KConso)eRiconic? true
KConso)eR!ont? !ixed
Sample xdm"config file
] WK%reeHI? xcprogramsxdmcon!igxdm1con!.cpp,* (.(.(.2.=.2 (<<<(0(2 (H?;;?2< hohnde) Axp W
]
&isp)ayCanager.ser*ers? etcK((xdmKser*ers
&isp)ayCanager.access%i)e? etcK((xdmKaccess
] /)) disp)ays shou)d use authori:ation, but ,e cannot be sure
] K termina)s ,i)) be con!igured that ,ay, so by de!au)t
] use authori:ation on)y !or )oca) disp)ays ?0, ?(, etc.
&isp)ayCanager.90.authori:e? true
&isp)ayCanager.9(.authori:e? true
]
&isp)ayCanagerRresources? etcK((xdmKresources
&isp)ayCanagerRsession? etcK((xdmKsession
&isp)ayCanagerRauthComp)ain? !a)se
] +AC$BITQ? do not )isten !or K&CCP or Chooser re>uests
] Comment out this )ine i! you ,ant to manage K termina)s ,ith xdm
&isp)ayCanager.re>uestPort? 0
_____________________________________________________________________________________
Page 144
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
%$ Troubleshootin! 7 "lients
Occasionally X Clients wont terminate properly leaving Eombie processes. A zombie process in one
whose parent processes has terminated, and cannot clear references to the child process. When a child
process' parent exits leaving the child process still running, this is usually visible by running ps which will
reveal the child process being owned by PD 1 (init). These processes should be killed because they may
be using CPU resources. Killing such a process requires the user to be the user who owns the process,
or root. t might be necessary to use the 9 option to actually kill these processes.
6$ "hoosin! a 2indow ,ana!er
The area that is commonly referred to as the desktop is also known in the X Window world as the
screen. t covers the entire area of your monitor display. The root window is the background of your
screen, typically used to display a colour or picture. The window manager provides an interface between
the user and the X server. t is virtually impossible to use X without a window manager, because it
provides the title bar and the familiar buttons with which you manipulate the display.
nformation on available window managers is available from the Window Managers website at
http://www.PliG.org/xwinman. Many of the Linux versions of these window managers are available at
ftp://metalab.unc.e du /pub/Linux/X11/window-managers .
n addition to the different window managers there are also various desktop environments, among which
the most common are KDE, GNOME and XFCE.
Below is a brief list of integrated window managers:
Enlightenment
fvwm
icewm
amiWM
mlvwm
dfm
olwm
olvwm
mwm
Window Maker
_____________________________________________________________________________________
Page 145
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
:$ 3xerises and Summary
/e-iew =uestions (answers p.151)
Yes or No
1. The configuration file for a window manager is 7F<%"onfi! ____
2. An x.lient can be configured to run on any X server accessible on a network ____
3. A display manager is a program that manages pixels when using a
windowing environment ____
4. A user running an X server can disable access control using xhost ____
5. The XDMCP protocol is used by display managers to display a graphical login
on remote computers ____
6. f a system is not running a display manager one usually starts a windowing
environment with the xinit tool ____
Glossary
Term Definition
DSPLAY Shell environmental variable used to notify x-applications which display (in this
case, which X server) to run on
XDMCP a protocol that provides a uniform mechanism for an autonomous
display to request login service from a remote host
run level a software configuration of the system which allows only a selected group of
processes to exist see initA<B
x-client or x-application n this manual the terms are used to describe applications such as xterm or
xlok that run on an X server
desktop environment a suite of applications (including a window manager) originally designed to use
the entire surface of the screen as a 'desktop'. ntegrated applications often
include features such as short cuts for copy pasting, drag and drop, etc.
Example desktops are 7F"3, G+0,3 and \D3
display manager an x-application which runs at a specific run level (often run level 5) displaying
a graphical login interface. Display managers also handle the XDMCP
protocol. Most common display managers are xdm (generic X11R6), !dm
(part of the GNOME desktop suite) and kdm (part of the KDE desktop suite)
window manager a special x-application which can move, resize or iconify windows. n some
cases window managers also provide a task bar as well as drop down menus
for quick launch. Examples are twm, fluxbox, iewm etc ...
session manager provides a way to save a window session once the user logs out
_____________________________________________________________________________________
Page 146
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
711 "onfi!uration File
File Description
XF86Config main configuration file for the X11R6 server
Dis#lay ,ana!er "onfi!uration Files
System File Description
gdm.conf main configuration file for !dm
kdmrc main configuration file for kdm
Xaccess one of the files used to allow/disallow XDMCP access
xdm-config main configuration file for xdm
Xrescources customisation file used by display managers
Xservers configures how many display managers to start on a system. The file associates a
display (default :0) to a server (usually X11R6)
Xsession script used by display managers to start a specific windowing environment
Xclients script used by Xsession as well as xdm to start a system wide windowing environment
1ser "ustomisations
File Description
~/.Xresources
~/.Xdefaults
files used to control the way x-applications start (e.g position, font size, colours, etc)
~/.xinitrc when using startx users can specify which window manager or desktop environment
to start
~/.Xclients when using a display manager users can specify which window manager or desktop
environment to start
"ommands
Command Description
gdm p.141 !dmA1B - GDM is a replacement for XDM, the X Display Manager. Unlike its
competitors (X3DM, KDM, WDM) GDM was written from scratch and does not contain
any original XDM / X Consortium code. GDM runs and manages the X servers for both
local and remote logins (using XDMCP)
kdm p.141 a display manager provided by the KDE desktop, it has many configuration files in
common with xdm
startx p.140 a script that calls xinit and starts the X Window System, that is an X server together with
a window manager or a desktop
xauth p.140 (not an LP objective) xauthA1B - The xauth program is used to edit and display the
authorization information used in connecting to the X server. Normally xauth is not used
to create the authority file entry in the first place; xdm does that see also #amDxauthA<B
_____________________________________________________________________________________
Page 147
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
for further reading
xdm p.141 the X Display Manager made available as part of the X server
xf86config
p.137
program that interactively creates a XF86Config file
XF86Setup
p.137
graphical program that interactively creates or modifies an XF86Config file
xhost p.139 xhostA1B - The xhost program is used to add and delete host names or user names to the
list allowed to make connections to the X server. n the case of hosts, this provides a
rudimentary form of privacy control and security. t is only sufficient for a workstation
(single user) environment,
xinit p.140 xinitA1B - The xinit program is used to start the X Window System server and a first client
program (usually a window manager) on systems that cannot start X directly from /etc/init
or in environments that use multiple window systems. When this first client exits, xinit will
kill the X server and then terminate
xinitrc p.140 script launched by xinit containing a list of clients to be started. Additional clients (such as
terminals, clocks, etc) should be started in the background. The first client however
(usually the window manager) should be started in the forground in order to prevent
xinitr from exiting see xinitA1B
xvidtune
p.137
x-idtuneA1B - Without any options it presents the user with various buttons and sliders
that can be used to interactively adjust existing video modes. t will also print the
settings in a format suitable for inclusion in an XF86Config file
3xerises
Before starting make sure you are running in runlevel 9.
init ;
1. Log into a virtual terminal (e.g Alt+F1)
2. As root save the existing configuration file @et@711@7F<%"onfi! and try out the various configuration
tools:
Redhat: Xconfigurator, redhat-config-xfree86 (8.0)
Mandrake : XFdrake
Suse: sax
XF86Setup
xf86config
X (this is the X11 server itself, use the .onfi!ure flag)
3. Start the X server by typing 7. This will start X11R6 alone with no window managers. Return to a
virtual terminal (e.g Ctrl+Alt+F2) and get the command line back. Then do the following:
export &I+PL/Q8)oca)host?0
xtermO
Go back into X by typing Ctrl+Alt+F7 (if you haven't changed the defaults in /etc/inittab...). You should
have an xterminal running. Next type in this terminal:
t,mO
What has happened? Can you kill twm without killing X? Go back to a
virtual terminal (e.g Ctrl+Alt+F2) and type:
K ?(
Log into another virtual terminal (e.g tty3) and type:
_____________________________________________________________________________________
Page 148
LinuxIT Tehnial Trainin! "entre
The 7 3n-ironment
______________________________________________
export &I+PL/Q8?(- xtermO
You now have two X servers running on screen 0 and 1. How do you switch from one to another?
4. Setting up XDMCP
For this to work make sure the line containing an 'O' is uncommented in @et@711@xdm@7aess.
f you are using xdm or kdm comment out the line in xdm.onfi! as follows
]&isp)ayCanager.re>uestPort? 0
This line is originally uncommented and allows only local login requests on screen 0 (more secure).
f you are using !dm then you will also need to edit !dm$onf and put
enab)e8true
This will turn off the default security settings for !dm.
f your P is 1.2.3.4 then users on your network can start an X session with:
K S>uery (.2.;.= ?(
or
K 1indirect (.2.;.= ?(
_____________________________________________________________________________________
Page 149
LinuxIT Tehnial Trainin! "entre
Answers to /e-iew =uestions
______________________________________________
.nswers to Re!ision #estions
Installation (p.8)
1.No the rawrite tool runs under DOS. The tool used to copy image files onto a block device is dd
2.Yes any device that can hold data (i.e not an extended partition) can be used as the root device
(ardware Su###ort (p.24)
1. No the root filesystem can be on any disk type
2. No the kernel module only handles the USB controller. The kernel will notify events to a USB user
agent which then uses user-maps to configure the particular device
,ana!in! De-ies (p.36)
1. No you need to re-run @sbin@lilo every time you change something in @et@lilo$onf
2. Yes GRUB only need to be installed once
3. No the 1024 cylinder limit affects the second stage bootloader
4. Yes one cannot set quotas on a directory
The Linux Filesystem (p.52)
1. No programs stored in @usr@ are not essential for booting up the system
2. No a user's home directory can be anywhere on the system
3. Yes
The "ommand Line (p.66)
1. Yes
2. No STDOUT can be redirected to a file
3. Yes
4. No commands are generally stored in a file called .bash_history in the user's home directory
File ,ana!ement (p.78)
1. Yes
2. No d with no argument will also go to the user's home directory
3. No you must use 'mkdir -p' to make directories which contain subdirectories
4. Yes
5. No the correct command is ')n 1s %ILA %ILA1LI#L '
6. No paths beginning with a forward slash are absolute paths
Proess ,ana!ement (p.87)
1. No kill will send a signal, some signals may simply pause a process, others force daemons to re-
read their configuration file. However the default signal (15 or SGTERM) will attempt to terminate a
process.
2. Yes
3. Yes
4. No
Text Proessin! (p.96)
1. Yes
2. No use tail
3. Yes this is the case with all the text tools
4. No all the text tools print the altered data to STDOUT and don't alter the original file
Software Installation (p.118)
1. No one uses make
2. Yes a makefile is unique for each project. The make tool will only read a makefile in the current
directory (i.e the directory the make command is started from)
3. Yes
4. Yes
5. Yes
_____________________________________________________________________________________
Page 150
LinuxIT Tehnial Trainin! "entre
Answers to /e-iew =uestions
______________________________________________
6. No
7. Yes
Ad-aned Text ,ani#ulation (p.126)
1. Yes the "e?" expression reads 'match 0 or 1 e'
2. Yes the "a*" expression reads ' match 0 or any a'
3. Yes the "e+" expressiom reads 'match at least 1 or any e'
4. Yes notice that the "a*" is at the end of the expression. This means that 'baz' followed by anything
will also be matched
1sin! -i (p.133)
1. No look at the position of hKkl on the keyboard. The l key is on the right and will cause the cursor to
move to the right
2. Yes
3. No 9w will move the cursor three words forward, then d is an incomplete command. Deleting three
words can be done with d9w
4. No the commands '*w will be read from left to right. So quit (*) must always be last
The 7 3n-ironment (p.146)
1. No the 7F<%"onfi! file only configures the X server. Window managers often use directories stored
in user's home directories
2. Yes this is true although firewalls can prevent x.a##liations to connect to remote X servers
3. No a display manager handles login access on a display (local X server or remote X server using
XDMCP)
4.Yes note that on most of the recent Linux distributions xhost must be used in conjunction with xauth
5. Yes
6. No one usually uses startx
_____________________________________________________________________________________
Page 151
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
&0I 7A7 Ob:ecti!es
http://www.lpi.org/en/obj_101.html
Thu Nov 4 04:45:58 2004
3xam 101' Detailed 0bKeti-es
This is a required exam for LP certification Level 1. t covers basic system administration skills that are common
across all distributions of Linux.
Each objective is assigned a weighting value. The weights range roughly from 1 to 10, and indicate the relative
importance of each objective. Objectives with higher weights will be covered in the exam with more questions.
To#i 101' (ardware ) Arhiteture
* 1$101$1 "onfi!ure Fundamental >I0S Settin!s
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Candidates should be able to configure fundamental system hardware by making the correct
settings in the system BOS. This objective includes a proper understanding of BOS configuration issues such as
the use of LBA on DE hard disks larger than 1024 cylinders, enabling or disabling integrated peripherals, as well as
configuring systems with (or without) external peripherals such as keyboards. t also includes the correct setting for
RQ, DMA and /O addresses for all BOS administrated ports and settings for error handling (p. 11).
Key files, terms, and utilities include:
@#ro@io#orts (p. 11)
@#ro@interru#ts (p. 11)
@#ro@dma (p. 11)
@#ro@#i (p. 11)
* 1$101$9 "onfi!ure ,odem and Sound ards
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Ensure devices meet compatibility requirements (particularly that the modem is NOT a win-modem),
verify that both the modem and sound card are using unique and correct RQ's, /O, and DMA addresses, if the
sound card is PnP install and run sndconfig (p.23)and isapnp (p.12), configure modem for outbound dial-up,
configure modem for outbound PPP | SLP | CSLP connection, set serial port for 115.2 Kbps (p.18)
* 1$101$& Setu# S"SI De-ies
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Candidates should be able to configure SCS devices using the SCS BOS as well as the
necessary Linux tools. They also should be able to differentiate between the various types of SCS. This objective
includes manipulating the SCS BOS to detect used and available SCS Ds and setting the correct D number for
different devices especially the boot device. t also includes managing the settings in the computer's BOS to
determine the desired boot sequence if both SCS and DE drives are used.
______________________________________________________________________________________________
Page 152
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
Key files, terms, and utilities include:
S"SI ID(p.14)
@#ro@ssi@(p.15)
ssiDinfo(p.15)
* 1$101$; Setu# different P" ex#ansion ards
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to configure various cards for the various expansion slots. They should
know the differences between SA and PC cards with respect to configuration issues. This objective includes the
correct settings of RQs, DMAs and /O Ports of the cards, especially to avoid conflicts between devices. t also
includes using isapnp if the card is an SA PnP device.
Key files, terms, and utilities include:
@#ro@dma
@#ro@interru#ts
@#ro@io#orts
@#ro@#i
#n#dum#A<B (p.12)
isa#n#A<B (p.12)
ls#iA<B (p.11)
* 1$101$% "onfi!ure "ommuniation De-ies
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Candidates should be able to install and configure different internal and external communication
devices like modems, SDN adapters (p.20), and DSL switches (p.20). This objective includes verification of
compatibility requirements (especially important if that modem is a winmodem [p.20]), necessary hardware settings
for internal devices (RQs, DMAs, /O ports), and loading and configuring suitable device drivers. t also includes
communication device and interface configuration requirements, such as the right serial port for 115.2 Kbps (p.18),
and the correct modem settings for outbound PPP connection(s) (p.18).
Key files, terms, and utilities include:
@#ro@dma
@#ro@interru#ts
@#ro@io#orts
setserialA<B
* 1$101$6 "onfi!ure 1S> de-ies
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Candidates should be able to activate USB support, use and configure different USB devices. This
objective includes the correct selection of the USB chipset and the corresponding module. t also includes the
knowledge of the basic architecture of the layer model of USB as well as the different modules used in the different
layers.
Key files, terms, and utilities include:
ls#iA<B
______________________________________________________________________________________________
Page 153
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
usb.uhi$o(p.13)
usb.ohi$o(p.13)
@et@usbm!r@(p.14
usbmodules
@et@hot#lu!(p.13)
To#i 105' Linux Installation ) Paka!e ,ana!ement
O 1$105$1 Desi!n hard disk layout
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' ;
Description: Candidates should be able to design a disk partitioning scheme for a Linux system. This objective
includes allocating filesystems or swap space to separate partitions or disks, and tailoring the design to the intended
use of the system. t also includes placing /boot on a partition that conforms with the BOS' requirements for booting.
Key files, terms, and utilities include:
/ (root) filesystem (p.5 and p.40)
/var filesystem (p.41)
/home filesystem (p.41)
swap space (p.6)
mount points (p.5)
partitions (p.5, p.28)
cylinder 1024 (p.32 and p.36)
O 1$105$5 Install a boot mana!er
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' 1
Description: Candidate should be able to select, install, and configure a boot manager. This objective includes
providing alternative boot locations and backup boot options (for example, using a boot floppy).
Key files, terms, and utilities include:
@et@lilo$onf (p.32)
@boot@!rub@!rub$onf (p.32)
lilo (p.32)
!rub.install (p.32)
,>/ (p.31)
su#erblok (p.42)
first sta!e boot loader (p.31)
______________________________________________________________________________________________
Page 154
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
O 1$105$9 ,ake and install #ro!rams from soure
Modified: 2003-March-17
Maintainer: Kara Pritchard
2ei!ht' ;
Description: Candidates should be able to build and install an executable program from source. This objective
includes being able to unpack a file of sources. Candidates should be able to make simple customizations to the
Makefile, for example changing paths or adding extra include directories.
Key files, terms, and utilities include:
gunzip
gzip (p.104)
bzip2 (p.104)
tar (p.105)
configure (p.106)
make (p.106)
O 1$105$& ,ana!e shared libraries
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to determine the shared libraries that executable programs depend on
and install them when necessary. Candidates should be able to state where system libraries are kept.
Key files, terms, and utilities include:
ldd (p.102)
ldconfig (p.103)
/etc/ld.so.conf (p.103)
LD_LBRARY_PATH (p.103)
O 1$105$; 1se Debian #aka!e mana!ement
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 8
Description: Candidates should be able to perform package management skills using the Debian package
manager. This objective includes being able to use command-line and interactive tools to install, upgrade, or
uninstall packages, as well as find packages containing specific files or software (such packages might or might not
be installed). This objective also includes being able to obtain package information like version, content,
dependencies, package integrity and installation status (whether or not the package is installed).
Key files, terms, and utilities include:
unpack (p.113, p.114, p.114)
configure (p.113, p.114)
/etc/dpkg/dpkg.cfg (p.113)
/var/lib/dpkg/* (p.114)
/etc/apt/apt.conf (p.115)
/etc/apt/sources.list (p.115)
dpkg (p.112, .114)
dselect (p.112)
______________________________________________________________________________________________
Page 155
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
dpkg-reconfigure
apt-get (p.115)
alien (p.116, p.119)
O 1$105$% 1se /ed (at Paka!e ,ana!er A/P,B
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 8
Description: Candidates should be able to perform package management under Linux distributions that use
RPMs for package distribution. This objective includes being able to install, re-install, upgrade, and remove
packages, as well as obtain status and version information on packages. This objective also includes obtaining
package information such as version, status, dependencies, integrity, and signatures. Candidates should be able to
determine what files a package provides, as well as find which package a specific file comes from.
Key files, terms, and utilities include:
/etc/rpmrc (p.119)
/usr/lib/rpm/* (p.119)
rpm (p.107, p.119)
grep
To#i 109' G+1 ) 1nix "ommands
O 1$109$1 2ork on the ommand line
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidates should be able to nteract with shells and commands using the command line. This
includes typing valid commands and command sequences, defining, referencing and exporting environment
variables, using command history and editing facilities, invoking commands in the path and outside the path, using
command substitution, applying commands recursively through a directory tree and using man to find out about
commands.
Key files, terms, and utilities include:
.
bash
echo (p.57)
env (p.58)
exec (p.64)
export (p.58)
man (p.66, p.65)
pwd (p.72)
set (p.58)
unset (p.58)
~/.bash_history (p.63)
~/.profile
O 1$109$5 Proess text streams usin! filters
Modified: 2003-March-17
______________________________________________________________________________________________
Page 156
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
Maintainer: Kara Pritchard
Weight: 6
Description: Candidates should should be able to apply filters to text streams. Tasks include sending text files
and output streams through text utility filters to modify the output, and using standard UNX commands found in the
GNU textutils package.
Key files, terms, and utilities include:
cat (p.90)
cut (p.93)
expand (p.92)
fmt (p.94)
head (p.91)
join (p.94)
nl (p.92)
od (p.92)
paste (p.94)
pr (p.95)
sed (p.124)
sort (p.94)
split (p.92)
tac (p.90)
tail (p.91)
tr (p.95)
unexpand (p.92)
uniq (p.93)
wc (p.91)
O 1$109$9 Perform basi file mana!ement
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to use the basic UNX commands to copy, move, and remove files and
directories. Tasks include advanced file management operations such as copying multiple files recursively, removing
directories recursively, and moving files that meet a wildcard pattern. This includes using simple and advanced
wildcard specifications to refer to files, as well as using find to locate and act on files based on type, size, or time.
Key files, terms, and utilities include:
cp (p.74)
find (p.72)
mkdir (p.74)
mv (p.75)
ls (p.73)
rm (p.74)
rmdir(p.74)
touch (p.76)
file globbing (p.67)
______________________________________________________________________________________________
Page 157
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
O 1$109$& 1se streamsJ #i#esJ and redirets
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidates should be able to redirect streams and connect them in order to efficiently process
textual data. Tasks include redirecting standard input, standard output, and standard error, piping the output of one
command to the input of another command, using the output of one command as arguments to another command
and sending output to both stdout and a file.
Key files, terms, and utilities include:
tee (p.61)
xargs (p.72)
< (p.60)
<< (p.64)
>(p.60)
>>(p.60)
| (p.61)
` ` (p.63)
O 1$109$; "reateJ monitorJ and kill #roesses
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidates should be able to manage processes. This includes knowing how to run jobs in the
foreground and background, bring a job from the background to the foreground and vice versa, start a process that
will run without being connected to a terminal and signal a program to continue running after logout. Tasks also
include monitoring active processes, selecting and sorting processes for display, sending signals to processes,
killing processes and identifying and killing X applications that did not terminate after the X session closed.
Key files, terms, and utilities include:
& (p.86)
bg (p.85)
fg (p.85)
jobs (p.86)
kill (p.83)
nohup (p.86)
ps (p.82)
top (p.83)
O 1$109$% ,odify #roess exeution #riorities
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should should be able to manage process execution priorities. Tasks include running a
program with higher or lower priority, determining the priority of a process and changing the priority of a running
process.
______________________________________________________________________________________________
Page 158
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
Key files, terms, and utilities include:
nice (p.84)
ps (p.82)
renice (p.85)
top (p.83)
O 1$109$6 Searh text files usin! re!ular ex#ressions
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to manipulate files and text data using regular expressions. This
objective includes creating simple regular expressions containing several notational elements. t also includes using
regular expression tools to perform searches through a filesystem or file content.
Key files, terms, and utilities include:
grep (p.122)
regexp ()
sed (p.124)
O 1$109$< Perform basi file editin! o#erations usin! -i
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 1
Description: Candidates should be able to edit text files using vi. This objective includes vi navigation, basic vi
nodes, inserting, editing, deleting, copying, and finding text.
Key files, terms, and utilities include:
vi (p.129)
/ (p.131), ? (p.131)
h,j,k,l (p.129)
G, H, L
i (p.130), c (p130), d, dd (p.130), p (p.130), o (p.130), a (p.130)
ZZ (p.132), :w! (p.132), :q! (p.132), :e! (p.132)
:! (p.132)
To#i 10&' De-iesJ Linux FilesystemsJ Filesystem (ierarhy Standard
O 1$10&$1 "reate #artitions and filesystems
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to configure disk partitions and then create filesystems on media such as
hard disks. This objective includes using various mkfs commands to set up partitions to various filesystems,
including ext2, ext3, reiserfs, vfat, and xfs.
Key files, terms, and utilities include:
______________________________________________________________________________________________
Page 159
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
fdisk (p.29)
mkfs (p.42)
O 1$10&$5 ,aintain the inte!rity of filesystems
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to verify the integrity of filesystems, monitor free space and inodes, and
repair simple filesystem problems. This objective includes the commands required to maintain a standard filesystem,
as well as the extra data associated with a journaling filesystem.
Key files, terms, and utilities include:
du (p.45)
df (p.45)
fsck (p.43)
e2fsck (p.43)
mke2fs (p.42)
debugfs (p.43)
dumpe2fs (p.43)
tune2fs (p.34)
O 1$10&$9 "ontrol mountin! and unmountin! filesystems
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to configure the mounting of a filesystem. This objective includes the
ability to manually mount and unmount filesystems, configure filesystem mounting on bootup, and configure user
mountable removeable filesystems such as tape drives, floppies, and CDs.
Key files, terms, and utilities include:
/etc/fstab (p.33)
mount (p.33)
umount (p.34)
O 1$10&$& ,ana!in! disk *uota
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidates should be able to manage disk quotas for users. This objective includes setting up a
disk quota for a filesystem, editing, checking, and generating user quota reports.
Key files, terms, and utilities include:
quota (p.35)
edquota (p.35)
repquota (p.35)
quotaon (p.35)
______________________________________________________________________________________________
Page 160
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
O 1$10&$; 1se file #ermissions to ontrol aess to files
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidates should be able to control file access through permissions. This objective includes
access permissions on regular and special files as well as directories. Also included are access modes such as suid,
sgid, and the sticky bit, the use of the group field to grant file access to workgroups, the immutable flag, and the
default file creation mode.
Key files, terms, and utilities include:
chmod (p.46)
umask (p.47)
chattr (p.49)
O 1$10&$% ,ana!e file ownershi#
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 1
Description: Candidates should be able to control user and group ownership of files. This objective includes the
ability to change the user and group owner of a file as well as the default group owner for new files.
Key files, terms, and utilities include:
chmod (p. 46)
chown (p.46)
chgrp (p.46)
O 1$10&$6 "reate and han!e hard and symboli links
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 1
Description: Candidates should be able to create and manage hard and symbolic links to a file. This objective
includes the ability to create and identify links, copy files through links, and use linked files to support system
administration tasks.
Key files, terms, and utilities include:
ln (p.75)
O 1$10&$< Find system files and #lae files in the orret loation
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidates should be thouroughly familiar with the Filesystem Hierarchy Standard, including typical
file locations and directory classifications. This objective includes the ability to find files and commands on a Linux
system.
Key files, terms, and utilities include:
find (p.72)
locate (p.73)
slocate (p.73)
updatedb (p.73)
______________________________________________________________________________________________
Page 161
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
whereis (p.73)
which (p.73)
/etc/updatedb.conf (p.73)
To#i 110' The 7 2indow System
O 1$110$1 Install ) "onfi!ure 7Free<%
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidate should be able to configure and install X and an X font server. This objective includes
verifying that the video card and monitor are supported by an X server, as well as customizing and tuning X for the
videocard and monitor. t also includes installing an X font server, installing fonts, and configuring X to use the font
server (may require a manual edit of /etc/X11/XF86Config in the "Files" section).
Key files, terms, and utilities include:
XF86Setup (p.137)
xf86config (p.137)
xvidtune (p.137)
/etc/X11/XF86Config (p.)
.Xresources (p.139)
O 1$110$5 Setu# a dis#lay mana!er
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 3
Description: Candidate should be able setup and customize a Display manager. This objective includes turning
the display manager on or off and changing the display manager greeting. This objective includes changing default
bitplanes for the display manager. t also includes configuring display managers for use by X-stations. This objective
covers the display managers XDM (X Display Manger), GDM (Gnome Display Manager) and KDM (KDE Display
Manager).
Key files, terms, and utilities include:
/etc/inittab
/etc/X11/xdm/* (p.141)
/etc/X11/kdm/* (p.141)
/etc/X11/gdm/* (p.141)
O 1$110$& Install ) "ustomi^e a 2indow ,ana!er 3n-ironment
Modified: 2003-March-17
Maintainer: Kara Pritchard
Weight: 5
Description: Candidate should be able to customize a system-wide desktop environment and/or window
manager, to demonstrate an understanding of customization procedures for window manager menus and/or desktop
panel menus. This objective includes selecting and configuring the desired x-terminal (xterm, rxvt, aterm etc.),
verifying and resolving library dependency issues for X applications, exporting X-display to a client workstation.
Key files, terms, and utilities include:
______________________________________________________________________________________________
Page 162
LinuxIT Tehnial Trainin! "entre
LPI 101 0bKeti-es
____________________________________________________________________
.xinitrc (p.140)
.Xdefaults (p.139)
xhost (p.139)
DSPLAY environment variable (p.139)
http://www.lpi.org/en/obj_101.html
Copyright 1999, 2000, 2001, 2002, 2003 Linux Professional nstitute. All rights reserved.
______________________________________________________________________________________________
Page 163
G+1 FDL Liense A!reement
________________________________________________________________________
Copyright (c) 200= LinuxIT.
Permission is granted to copy, distribute andor modi!y this document
under the terms o! the "#$ %ree &ocumentation License, 'ersion (.2
or any )ater *ersion pub)ished by the %ree +o!t,are %oundation-
,ith the In*ariant +ections being .istory, /c0no,)edgements, ,ith the
%ront1Co*er Texts being 2re)eased under the "%&L by LinuxIT3.
G+1 Free Doumentation Liense
Version 1.2, November 2002
Copyright (C) 2000,200(,2002 %ree +o!t,are %oundation, Inc.
5( %ran0)in +treet, %i!th %)oor, Doston, C/ 02((01(;0(, $+/
A*eryone is permitted to copy and distribute *erbatim copies
o! this )icense document, but changing it is not a))o,ed
0$ P/3A,>L3
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. t 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.
1$ APPLI"A>ILIT8 A+D D3FI+ITI0+S
This License applies to any manual or other work, in any medium, that contains a notice placed by the
copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-
wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The
"Document", below, refers to any such manual or work. Any member of the public is a licensee, and is
addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring
permission under copyright law.
A "Modified Version" of the Document means any work containing the Document or a portion of it, either
copied verbatim, or with modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively
with the relationship of the publishers or authors of the Document to the Document's overall subject (or to
related matters) and contains nothing that could fall directly within that overall 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 "nvariant Sections" are certain Secondary Sections whose titles are designated, as being those of
nvariant Sections, in the notice that says that the Document is released under this License. f a section does
not fit the above definition of Secondary then it is not allowed to be designated as nvariant. The Document
may contain zero nvariant Sections. f the Document does not identify any nvariant Sections then there are
none.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover
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.
____________________________________________________________________________________________________________
Page 164
G+1 FDL Liense A!reement
________________________________________________________________________
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 ASC without markup, Texinfo input
format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming 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 work's
title, preceding the beginning of the body of the text.
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 Disclaimers may have is
void and has no effect on the meaning of this License.
5$ 43/>ATI, "0P8I+G
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. f 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.
9$ "0P8I+G I+ =1A+TIT8
f you publish printed copies (or copies in media that commonly have printed covers) of the Document,
numbering more than 100, and the Document's 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.
f 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.
f 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. f
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.
____________________________________________________________________________________________________________
Page 165
G+1 FDL Liense A!reement
________________________________________________________________________
t 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.
&$ ,0DIFI"ATI0+S
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 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. n 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.
>$ 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.
"$ 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.
3$ Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
F$ nclude, 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 nvariant Sections and required Cover Texts given in
the Document's license notice.
($ nclude 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. f 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.
?$ 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.
\$ 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 nvariant 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.
,$ Delete any section Entitled "Endorsements". Such a section may not be included in the Modified
Version.
+$ Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any
nvariant Section.
0$ Preserve any Warranty Disclaimers.
f 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 nvariant Sections in the Modified Version's
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 parties--for 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.
f 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.
____________________________________________________________________________________________________________
Page 166
G+1 FDL Liense A!reement
________________________________________________________________________
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.
;$ "0,>I+I+G D0"1,3+TS
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 nvariant
Sections of all of the original documents, unmodified, and list them all as nvariant 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 nvariant Sections may
be replaced with a single copy. f there are multiple nvariant 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 nvariant Sections in the license notice of the combined work.
n 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."
%$ "0LL3"TI0+S 0F D0"1,3+TS
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.
6$ AGG/3GATI0+ 2IT( I+D3P3+D3+T 20/\S
A compilation of the Document or its derivatives with other separate and independent documents or works, in
or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the
compilation is not used to limit the legal rights of the compilation's users beyond what the individual works
permit. When the Document is included in an aggregate, this License does not apply to the other works in the
aggregate which are not themselves derivative works of the Document.
f the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the
Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document
is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
<$ T/A+SLATI0+
Translation is considered a kind of modification, so you may distribute translations of the Document under the
terms of section 4. Replacing nvariant Sections with translations requires special permission from their
copyright holders, but you may include translations of some or all nvariant Sections in addition to the original
versions of these nvariant 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. n case of a disagreement between
the translation and the original version of this License or a notice or disclaimer, the original version will
prevail.
f 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.
:$ T3/,I+ATI0+
You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this
License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However, parties who have received copies, or rights,
from you under this License will not have their licenses terminated so long as such parties remain in full
compliance.
10$ F1T1/3 /34ISI0+S 0F T(IS LI"3+S3
____________________________________________________________________________________________________________
Page 167
G+1 FDL Liense A!reement
________________________________________________________________________
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License
from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. f the Document specifies that a
particular numbered version of this License "or any later version" applies to it, you have the option of following
the terms and conditions either of that specified version or of any later version that has been published (not
as a draft) by the Free Software Foundation. f the Document does not specify a version number of this
License, you may choose any version ever published (not as a draft) by the Free Software Foundation.
____________________________________________________________________________________________________________
Page 168
LinuxIT Tehnial Trainin! "entre
Index
______________________________________________________
I1D+/
A
AD,% 25
alias 67
append 85
atime 85
>
bg 98
bootloaders
1527 cylinder limit :6
1527 cylinders :2
bootloader :1
;R<= :2
grub shell :2
grub-install :2
grub)con* :2
%I%> :1
'boot 'boot)b :1
'etc'lilo)con* :2
'sbin'lilo :2
"
cat ?5
cd @2
chattr 7?
chgrp 76
chmod 76
chown 76
chroot 7
compound commands
command1 AA command2 67
command1 B B command2 67
command1C command2 67
compress 85
con*igure 156p)
cp @7
Ctrl D 98
cut ?:
D
dd 2E @6
Debian 112
debug*s 7:
d* 78
dirsync 85
DI,.%AF 1:9
display manager 1:?
display managers
gdm)con* 175
kdmrc 175
Gaccess 171
#dm-con*ig 175E 1*1
Grescources 171
Gser!ers 171
D-A 11
dmesg 11
dpkg 112
du 78
dump 85
dumpe2*s 7:
3
e2*sck 7:
echo 8@
egrep 121E 122
en! 89
erege#
" 121
H 121
B 121
e#ec 68
e#pand ?2
e#port 89
e#t: 85
F
*disk :1
*g 98
*grep 122
$ile Attributes 7?
*ile globbing 6@
*iles
isapnp)con* 12
'de!'tty,5 1@
'de!'tty,1 1@
'de!'tty,2 1@
'etc'isapnp)con* 12
'etc'ld)so)con* 15:
'etc'mtab 78
'etc' updatedb)con* @:
'proc'dma 11
'proc'interrupts 11
'proc'ioports 11
'proc'mounts 78
'proc'pci 11
'!ar 'log'dmesg 11
*ilesystem
absolute path @2
data blocks 72
e#t2 72
e#t: 72
inodes 72
permissions 76
relati!e path @2
superblock 72
*ilesystem hierarchy /$(,0
base directories 71
essential root /'0 subdirectories 75
*ind @2
______________________________________________________________________________________________
Page 169
LinuxIT Tehnial Trainin! "entre
Index
______________________________________________________
*ips :
*mt ?7
*sck 7:
*sck)e#t2 7:
*stab ::
*stab options
grpIuota :7
noauto :7
owner :7
rwEro :7
user :7
users :7
usrIuota :7
G
gdm 175
grep 121E 122
(
head ?1
he#dump ?2
history 6:
hotplug 1:
I
I'> address 11
immutable 85
IRJs 11
isapnp 12
isapnptools 12
I,DK 25
isdn7k- utils 25
?
Lobs 96
Loin ?7
\
kdm 175
kill 9:
kill signals
,I;(<.E,I;IKTE,I;2I%%),I;T&R- 9:
killall 97
L
%DM%I=RARFM.AT( 15:
ldcon*ig 152
ldd 152
ln @8
locate @:
ls @:
lsattr 7?
lspci 11
lsusb 1:
,
make 15@
-ake*ile 155E 156
man 66
-anpages 68
-AK.AT( 66
-=R :1
-etacharacters
command substitions
` command` 63
$(command) 63
*ile globbingE 62
Iuotes
`` 63
' ' 63
" " 63
range
[ ] 62
{string1,string2} 62
wildcards
? 62
* 62
mkdir @7
mke2*s72
mk*s 72
mk*s)e#t2 72
modem1@E +2, 16*
mount ::E 78
m! @8
+
network cards 18
nice 97
nl ?2
nohup 96
0
od ?2
>rlo! block allocator 85E 82
P
partitioning scheme -
.artitions
e#tended 29
logical 29
mounting ::
naming con!ention 29
primary partition 29
root /'0 75
unmounting :7
paste ?7
.ID 92
pnpdump 12
...o& 25
pr ?8
ps 92
pstree 92
pwd @2
=
Iuotas
aIuota)user :8
edIuota :8
grace :8
Iuota :8
Iuotacheck :8
Iuotaon :8
Iuotastats :8
repIuota :8
usrIuota :8
'etc'*stab :8
/
rawrite 2
______________________________________________________________________________________________
Page 170
LinuxIT Tehnial Trainin! "entre
Index
______________________________________________________
redirection and pipes
2N 61
2NA1 62
tee 62
O 65
OO 67
N 65
NN 65
B 61
rege#
P 121
) 121
Qt 121
RO 121
S 121
renice 98
rescue mode 7
resource allocation 11
rm @7
root /'0 8
rpm
maLor mode 159
minor mode 159
package integrity 115
package names 159
package signatures 15?
Iuery modes 159p)
S
,C,I
booting 18
Channel 17
De!ice ID 17
%<K 17
,C,I ID 17
scsiMin*o 18E 26
'proc'de!ices 29
'proc' scsi 'scsi 18
sed 12:
set 89
setting up modems 16
C>-1 1@
C>-2 1@
C>-: 1@
setserial 1@
w!dial 19
'de!'modem 19
,;ID 7?
sndcon*ig 22
sort ?7
split ?2
start# 1:?
stderr 8?
stdin 8?
stdout 8?
sticky bit 7?
,<ID 79
sync 85
synchronous 85
system-con*ig-network 25
T
tac ?5
tail ?1
tail-merging 81
tee 62
top 9:
touch @6
tr ?8
tune2*s :7
1
umask 7@
umount :7
undeletion 81
une#pand ?2
uniI ?:
updatedb @:
<,=
&(CI ehci-hdc)o 1:
>(CI usb- ohci)o 1:
<(CI usb- uhci)o 1:
usb)agent 17
usb)usermap 17
usbmgr 17
usbmodules 26
'etc' hotplug 1:
'etc' usbmgr' 17
<,= ,upport 1:
4
!i
aEAEiEoE>EsE, 12?
bEeE0ETEw 129
cEr 12?
dEddE#Ep 12?
hELEkEl 129
uEPR /undoE redo0 1:5
y 1:5
PESE1;E; 129
U4 1:1
UIuitEUI4EUwIEUe#itEU#EUeEDD 1:1
'E" 1:5
2
wc ?1
whatis 68
whereis @:
which @:
winmodems 1?
7
#auth 1:?
Gclients 1:?
Gde*aults 1:8
Gde*aults 1./
#dm 1*0
#dm 1:?
#*96con*ig 1:6
G$96Con*ig 1:8p)E 1.0
G$96,etup 1:6
#host 1:9
______________________________________________________________________________________________
Page 171
LinuxIT Tehnial Trainin! "entre
Index
______________________________________________________
#init 1:?
#initrc 1:?
Gresources 1:8E 1./
Gsession 1:?
#!idtune 1:6
Z
Vombie 177
______________________________________________________________________________________________
Page 172