Linux Admin I II
Linux Admin I II
Linux Admin I II
.
:
.
:
Linuxcbt
red hat administrator 1
red hat administrator 2
/
John_Wiley_Redhat_Linux_Networking_and_System_Administration
RHCSA_Hands-on.Guide.to.the.Red.Hat.Exams
.
janateba@hotmail.com
https://www.facebook.com/?q=#/tibea2004
RHCSA/RHCE Egypt
---------------------------------------------------------------------------------------------------------------(History)
(4-----6)
(6-----7)
/
(8-----9)
/
-------------------------------------------------------------------------------------------------- (starting with login)
(10---13)
(13---16)
(help)
---------------------------------------------------------------------------------------------------- (File System)
(17---24)
FHS
(25---29)
(examine the file)
------------------------------------------------------------------------------- (user & permission)
(---30---)
(31---34)
/etc/passwd
(35---38)
(group)
(38---40)
(permission)
(---41---)
Umask
(42---43)
Special permission
(43---47)
Network user modules (Ldap Nis)
------------------------------------------------------------------------------------------- (linux management)
(48---49)
Inode
Links
(50---51)
(51---53)
Search
(53---55)
Archiving and compression
(56---66)
(string process manage)
(66---74)
(process management)
(74---77)
Job schedule (crond atd)
(---78---)
DF DU
------------------------------------------------------------------------------------------- (working with shell script)
(79---82)
Shell
(82---83)
Shell script
(83---84)
Return value
(84---96)
Shell variable
(96--100)
Standard I/O
(100-103)
(scripting)
--------------------------------------------------------------------------------------------- (storage drive)
(104-106)
(106-112)
Partitioning
(112-114)
File system
(114-116)
Mount
(116-118)
Secure erase
(118-120)
Swap
(120-126)
Logical volume management
(126-130)
RAID
(130-132)
QUOTA
(132-134)
ACL
(134-135)
F.S management
(135-137)
Autofs
RHCSA/RHCE Egypt
(141-146)
Basic install
(146-152)
Network install (kickstart)
(152-164)
Hardware device and (proc sys)
-------------------------------------------------------------------------------------- (package installation)
(165-166)
(166-174)
RPM
(174-179)
YUM + REPO
------------------------------------------------------------------------------ (BOOT SEQUANCE)
(--180---)
(181-186)
Grub
(187-191)
Init
(192-198)
Service
(198-204)
Kernel (update install)
-------------------------------------------------------------------------------------- ( ) System admin tool
(205-213)
(cups)
(213-218)
Rsyslog
(218-226)
(Luks attr)
--------------------------------------------------------------------------------------------------------------networks
(227-238)
network management
(239-242)
network utilities
NFS
(243-245)
(--246---)
SSH-NTP
(--247---)
Selinux
------------------------------------------------------------Exams sample----------------------------------------------------
RHCSA/RHCE Egypt
Linux
History
1969
MULTICS
) (Bell telephone labs AT&T .
BLT
General Electrics .MIT .
BTL MULTICS
) (compiler )(loading program
DEC PDP7
) (
) ( .
. .
)
( . ) (
( PDP11.
)
.
RAM .
) ( .
.(man-page BTL
) Troff
BTL .
:
.
.
.
1971
. ) (1972 ) V2
( V5
.
1973
. AT&T
. .
.
USENIX 1974
.
.
1975
) (sun Microsystem .
Ex Vi
.
.
.
RHCSA/RHCE Egypt
.BSD
: .
BSD
BSD.
. 1977 PDP
IBM Interdata V7 1979
. C
) (BOURNE SHELL . expr findcpio
.
: Xenix
SCO Intel 8086 BSD
AT&T V7
.
.
.
AT&T
Minix 1991 .
BSD ) - ( 4.1
SUN Microsystems ,BSD 4.2
SunOS . 1983 :
SUN
IBM AIX DEC Ultrix HP HPUX SECO Xenix .
1980 AT&T " " " UNIX System V
SV3 BSD 4.x
.
IEEE POSIX UNIX97 FHS.
System V AT&T BSD .
.
AT&T )
(
: 1990 OSF UI USL
BSD . .
SCO OSF SCO
.
RHCSA/RHCE Egypt
. Microsoft DOS
. .
.
Minix - 1984
.
Minix Intel 8086
. IBM )
(C ,
.
FSF GNU
. HURD
.
1991 0.0.1
. Intel 386 GPL
.
.
.
RHCSA/RHCE Egypt
:
-1 :
.
GPL
-2 ) ( : ) (
C GCC GNU .
.
/ x86 : IA86 x86 - x86-64
AMD MIPS sun PowerPC - Silicon - IBM S390 - - m68k -
.........
:
Monolithic
-3
. Microkernel .
)( .
) ( .
modules .
-4 ) :(modules : )(FS
) (udev ) ( .
.
)( :
-5
) (
. .
.
.
GCC
FSF
GNOME
) Xfree (X Window KDE
.
/
/ .
.
FSF .
.
/
.
.
1991 .
HURD /.
/ BSD .
MacOS X
.
RHCSA/RHCE Egypt
/:
/:
/ .
/ :
-1 : .
-2 : FSF .
-3 : .
. /
.
/
. )( )(
/ .
/ .
.
.
)
( : (gtk) + ) (QT
. XFCE, :
FVWM,Motif, Enlightenment, BlackIce.
www.distrowatch.com
. iso
.
.
.
1993 / .
.
" "
.
APT DEB APT
. APT
)(ftp web CD
linex
.
RHCSA/RHCE Egypt
/:
/ .
.1994
. ) :(
) (
) (.
.
) (
.
) (2003 ) (9x
/
.
) ( .
.
.
) Open SUSE SUSE(
) (
RPM .SUSE
RHCSA/RHCE Egypt
10
Beginning
The Linux
) (username ) (password /
)CUI (tty GUI .
) (GUI xdm X WINDOWS gdm) (gnome kdm )(KDE
/ 6 ) (virtual console ) (virtual console 1
.Figure 1-1 tty
Ctrl + alt + Fn n 1-6 #chvtn
Ctrl+alt+F1 ) x server
( .
)(CLI
Figure 1-1
)(GUI
Figure 1-1
)(terminal
(Real Console)-1 )(tty) (CUI
.
(Fake(Pseudo)-2 )(gnome KDE other
real console ).(ssh GUI terminal
terminal tty
(Pseudo) terminal GUI
open terminal Figure 1-2
RHCSA/RHCE Egypt
11
Terminal
Figure 1-4
ssh
)- : (How write command in Terminal
/
) (Figure 1-5
Figure 1-5
RHCSA/RHCE Egypt
12
) (command )(-
) .(-- ) (command ) (--help
) (-- ) (-
ls Figure 1-6
ls Figure 1-6
) (Figure 1-7
Figure 1-7
RHCSA/RHCE Egypt
13
HELPS
)(terminal
)(
HELPS
.
/:
(manual page) man . /
. :
#manncommand #mancommand
n . man less
man Figure 1-11
Figure 1-11
man
man
/
.
RHCSA/RHCE Egypt
14
HELPS
- :man
info
. .
man .
info #infocommand pinfo
pinfo info
RHCSA/RHCE Egypt
15
HELPS
/usr/doc/ - /usr/share/doc/ . .
RHCSA/RHCE Egypt
16
HELPS
)(--help
man
whatis man .
whatis - :
)#mandb ------- (Ubuntu, SUSE
)#makewhatis------- (Red Hat
-1 )(define problem
-2 )(search docs and kbase
-3 )(gather background information
-4 (gather relevant diagnostic info (sos report)) log file
-5 )(determine severity level
-6 )(contact redhat by web
tab
m m tab m
y n m tab
. Figure 6.4
Figure 6.4
.en_US.UTF-8 ) (Figure 6.5& 6.6
System-config-language systemadministration language
/etc/sysconfig/il8n
LANG
=#LANG
RHCSA/RHCE Egypt
17
File system
Basic
.
.
/
/ . .
Linux Standard Base] LSB [
Filesystem Hierarchy Standard] FHS [
/ .
/ hardware .software
)FHS (FILESYSTEM HIERARCHY STANDARD
) (File system )(root directory) (/
).(/
) (fully qualified name /home/alice/website /home/alice/website/songs/song1.midi
Standard Linux Directory Scheme
RHCSA/RHCE Egypt
18
Path
name
Contents
) (files ) (directory )(root
) (binary code
/bin/ls /bin/bash
) . (User Excitable /bin
/usr /usr/bin
.(kernel and boot loader) /boot/vmlinuz
)(devices devices
. /dev/console /dev/mouse /dev/cdrom
: -
/dev/mouse /dev/psaux PS2 /dev/cdrom /dev/hdc
. IDE
IDE /dev/hdx SCSI /dev/sdx x .
/
) (hotplug , udev /dev/
.
configuration file ./etc/passwd
/home
.a .so
libc. /lib/modules
mount mnt/cdrom/ .
.
./ usr/local/
. root /bin/fsck/
. /usr/sbin
. )
(/usr/share/ ) .(/usr/share/doc/
/usr/local/
/
/bin
/boot
/dev
/etc
/home
/lib
/mnt
/media
/opt
/sbin
/tmp
/usr
/
/var/log/ /var/spool/mail/
./var/spool/lpd
services
root
/proc /selinux
/var
/srv
/root
/ ) (X graphical environment
) (Nautilus ) (explorer .
-1 computer
application system tools File Browser-2
Figure 1-2 &1-3&1-4
RHCSA/RHCE Egypt
19
Figure 1-3
Nautilus
- :
-1 spatial mode
-2 browser mode
File management
Figure 1-5
behavior
RHCSA/RHCE Egypt
20
cd : )(Table 1-1
- : ---
---
absolute pathname
relative pathname
RHCSA/RHCE Egypt
21
.(option) ls
-F
) (/ )*(
exec )@( symbolic link )=(
socket )|( FIFO (named pipe) First in First out %
-a
...
-R directory + sub directory
-l
-i
Inode number
- : ls-l ll
RHCSA/RHCE Egypt
22
ls l :
-1 ) ( ) (d ) (c (b) character device .block device
-3 soft link .hard link
-2 .permissions
-5 .
-4 .
-8
-7 .
-6 .
FILE HANDLING
-
creating file
touch
copying file .
cp[OPTION]SOURCEDIRECTORY
myprog1 myprog2
mohammed cp
p cp
-f
r R
cp
cp r
a p + r
i
RHCSA/RHCE Egypt
23
test2 test1
mv
Jana ls
test 2
mv test1
jana
mohammed
mv
deleting file
:
}rm [OPTIONS] {FILE...
r rm
jana
rm
r
-f
create directory
mkdir :
}mkdir [OPTIONS] {DIRECTORY...
RHCSA/RHCE Egypt
24
teba jana1 teba jana1
teba jana1 p
ls R
- : ) (. ls a
wild cards
RHCSA/RHCE Egypt
25
text file-1 .
executable file-2 .
data file -3
.binary code
-
file
stat
ls l
cat
-n
-b
-s
-A
RHCSA/RHCE Egypt
26
) (Table 6-1
headtail a tail
10 n )($tail-n3text1
-f log file
b head
10
RHCSA/RHCE Egypt
27
Text editor
TEXT EDITOR
.
html
/ :
nano-1gedit
vi-2 vim) emacs (
nano
Pico :
]nano [OPTIONS] [FILE
nano
Ctrl + k =^k
-m
-v
RHCSA/RHCE Egypt
28
Text editor
)Delete (cut
)Change (replace
yy or Y
dd
cc
Line
yl
dl
cl
Letter
yw
dw
cw
Word
)y
)d
)c
Sentence ahead
(y
(d
(c
Sentence behind
{y
{d
{c
Paragraph above
}y
}d
}c
Paragraph below
:set all
RHCSA/RHCE Egypt
29
Text editor
emacs
Ctrl+h t (emacs tutorials).
i Ctrl+h . manual
f Ctrl+h
p Ctrl+h
alt+x c++-mode java-mode calendar
RHCSA/RHCE Egypt
30
Users
&Permission
/ ) (
. )
( .
- : user name UID .
- : group name .GID
:
root
-1 ) (root or super user
.
.
UID 0
-2 ):(human user
) (/temp/
UID 500
) : (system users) ( lp, news ,wheel ,www-data
-3
.
.
( )( UID 1 499
)
/etc/passwd : /etc/shadow /etc/group /etc/gshadow
/ .task
UID
) (user UID ) (user identification number
32 0 .4,294,967,295
login
. UID
user /etc/passwd
etc/shadow/ UID GID id .groups
id UID n ls lsln
RHCSA/RHCE Egypt
31
UID
/ UID Directory services
UID
- :
1- Login name
: x
root user security service
. system account
chfn GECOS service user /sbin/nologin
The /etc/shadow file
password root
user - :
123456789-
RHCSA/RHCE Egypt
32
passwd -e
/etc/skel/ .
. ) (skeleton skel
.
user manger )(x window environment
system-config-users ) (terminal system admin user&group
useradd HOME
useradd-D
- :/etc/default/useradd
useradd userdelusermod
useradd -D
.
]useradd-D[option
-e expire date
-g
-s shell
RHCSA/RHCE Egypt
33
: root user
sudo useradd . root
/etc/login.defs. /etc/default/useradd
)useradd[options]LOGIN_NAME (username
:
)(primary group
)(secondary group
home
home
UID 500 999
)system user (service user
option
-c comment
-e expire_date
-g group_name_or_NO.
-G group_name_or_NO.
-m
-M
-p password
-s shell_name
-u uid
-r
)(primary group
)(secondary group
home -d
L
uid
option
-l new_username
-c comment
-e expire_date
-g group_name_or_NO.
-G group_name_or_NO.
-m
-p password
-s shell_name
-L
-U
-u new userid
RHCSA/RHCE Egypt
34
chpasswd chpasswd
user_name: password
. c ) (-cMD5 , -cNONE e
passwd --stdin
)(#echo1321983|passwd--stdin
chage l
]chage[options][LOGIN
/etc/shadow
chaged0jana
-l )(chage-luser01
chshch chsh
chfn finger /etc/passwd
finger .
.
RHCSA/RHCE Egypt
35
# finger rich
Login: rich
Name: Rich Blum
Directory: /home/rich Shell: /bin/bash
On since Thu Sep 20 18:03 (EDT) on pts/0 from 192.168.1.2
No mail.
No Plan.
#
USING LINUX GROUPS
- : ID
(group identifier number) GID .
primary group
) (secondary group
. 31 ).(secondary group
/etc/group /etc/gshadow
The /etc/group file
/etc/shadow GID
/ GID
Directory services UID
- :
1- The group name
2- The group password
3- GID (group ID) number
4- The list of user account
user manger )(x window environment
groupadd :
groupadd[options]group_name
r system group g group id
groupmod :
groupmod[options]group_name
gid
G :
groupdel
gpasswd
.
option
-n new_groupname
-p password
-g GID_NO.
#groupmod-Ggroup_nameuser_name
RHCSA/RHCE Egypt
36
.
.
Information Systems NetworkLDAP NIS+ NIS
.
/ /
.
- : shadow passwd pwunconv
shadow passwd shadow passwd
pwconv
pwconv shadow passwd
pwunconv passwd passwd+shadow
grpconv gshadow group
grpunconv group group+gshadow
: )(process userid groupid primary .groupid secondary
) (owner userid owner groupid .12 mode bits
.
12 mode bit
:user bit-1 3 ) ( userid
:group bit-2 3 ) ( primary groupid
secondary groupid groupid
:other bit-3 3 ) ( userid groupid
:special bit-4 3 ) suid sgid(sticky bit
/
id ) uid gid ( :
]id[OPTION][USERNAME
gid primary group
gid
uid
uidgid
whoami
users )(who logon now
elvis 5 ) (terminal
) (terminal )(session
.
RHCSA/RHCE Egypt
37
w users
]#w[-h | -s | -f][USERNAME
:
from
tty
who w
/
su sudo
]su[OPTION][-] [USER [ARG]...
Non-login shell
login shell
RHCSA/RHCE Egypt
38
env
) (root user $ #
) (primary group
secondary group primary group
]newgrp[GROUP
newgrp=sg
) (-rwxrwxrwx ) (- )(file
- :
- for files
d for directories
l for links
c for character devices
b for block devices
n for network devices
] [rwx
read r write w execute x x
cd
RHCSA/RHCE Egypt
39
Changing Permissions
:
:chown-1
:chgrp-2
:chmod-3 ) (rwx
R
)(recursive
Changing Permissions
chown[user] [:group]file...
chgrpGROUPFILE...
chmod - :
#chmodoptionsmodefilename
chmod chown chgrp
RHCSA/RHCE Egypt
40
Changing Permissions
t , s
][ugoa][[+-=] [rwxXstugo
og-r
))(who(u+g+o+a) operator(+ - =) permission (r+w+x+S+t
o g - r .
:
o chmod ugo+r file:
o chmod o-wx dir:
o chmod --reference file1 file2
--reference option
numeric method
user group
.other
4 r 2 w 1 .e
properties
.
RHCSA/RHCE Egypt
41
umask :
) (user) (group) (other umask ) (octal digit chmod
.umask
umask .
(-rw-rw-r--) 664 .umask
umask .
) ( - :
) 666-umask (files
666
) 777-umask (directory
777
777 binary
#umask 022
RHCSA/RHCE Egypt
42
special permission
umask 002 022 root
- : 664 775
) :(root user 644 755
SPECIAL PERMISSION
SUID, SGID, Sticky bit
Special permission
set-groupid bit
groupid set-groupid
.
RHCSA/RHCE Egypt
43
Permission
U
rwx
s
s = SUID + X
G
rwx
S=SUID
s
s = SGID + X
O
rwx
S=SGID
t = sticky bit + X
T
T= sticky bit
SUID
symbolic
SGID
Sticky bit
numeric
#chmod 4777
special permission 7
[root@localhost ~]# ls -l /usr/bin/passwd
-rwsr-xr-x. 1 root root 27012 Aug 22 2010 /usr/bin/passwd
permission
$ mkdir testdir
$ ls -l
drwxrwxr-x 2 rich rich 4096 Sep 20 23:12 testdir/
$ chgrp shared testdir
$ chmod g+s testdir
$ ls -l
drwxrwsr-x 2 rich shared 4096 Sep 20 23:12 testdir/
$ umask 002
$ cd testdir
$ touch testfile
$ ls -l
total 0
-rw-rw-r-- 1 rich shared 0 Sep 20 23:13 testfile
$
NETWORK BASED USER MODELS
:
authconfig-tui
A menu-based configuration utility for network authentication clients
authconfig
A command-line based version of authconfig-tui
NSS(Name Service Switch) NSS ( Naming Service)
.( ) name resolution /etc/nsswitch.conf
RHCSA/RHCE Egypt
44
LDAP
-2 ) (source
-1 )(date base
-1 ) (database ) (: passwd shadow group hosts
.
-2 ) (source .
.
Database
Passwd shadow group hosts automount
passwd ) (file
/etc/passwd .ldap
Source
file-1 /etc/passwd
(network information system) nis-2 1980 UNIX.
.
nisplus-3 nis public key mechanism
(Lightweight Directory Access Protocol) ldap-4 standard network-based naming protocol
.
) (directory service . (Distinguished Name) DN
.
NIS LDAP
(system security service) sss-5 )(authentication provide
) (authentication configuration tool SSSD
LDAP .
hesiod-6 ) (MIT )(DNS
.
/etc/nsswitch.conf
nsswitch.conf source
.
/etc/nsswitch.conf :
RHCSA/RHCE Egypt
45
RHCSA/RHCE Egypt
46
RHCSA/RHCE Egypt
47
getent
getentpasswdgetent .
/etc/passwd LDAP.
. ) (override .
LDAP 4200 userid
workstation client 500
System-config-authentication authconfig-tui :
LDAP
authconfig-gtk
RHCSA/RHCE Egypt
48
Inodes
Linux
Management
INODES
- :
-1 )(data
-2 )(Inode) (meta data
-3 )(dentry
Inode
/
Inode X
56689 Inode
Inode
Inode table 1M
.
Inode number ) (metadata :
file type, permissions, UID, GID
UID, GID
)the link count (count of path names pointing to this file
)the file's size and various time stamps(time access
)pointers to the file's data blocks on disk (location of data in hard disk
other data about the file
)(file type
o
o
o
o
o
Timing information
atime ctime mtime
Inode number .Inode number
.
RHCSA/RHCE Egypt
49
Inodes
-1 stat
-2 ls i
RHCSA/RHCE Egypt
50
) (link hard soft links
.
hard link-1- :
(symbolic)soft link -2
Hard link
Inode
media
partition
.
ls l
2 hard
link 3 hard
link . hard link
ln- :
]ln[OPTION...]TARGET[LINK
or
]cp[-l]TARGET[LINK
Soft link
hard link Inode
l . media
ln s- :
]cp[-s]TARGET[LINK
or
]ln[-s]TARGET[LINK
soft link
hard link
RHCSA/RHCE Egypt
51
/ :
-
)(X server
search for files places search for files
locate
updatedb
locate [OPTION]... PATTERN...
]>[-i <remove case sensitive
find find
criteria-2 root directory (directory)-1 action-3
)find (root directory) (criteria) (action
find
Directory-1 )(.
criteria-2
action-3 print
RHCSA/RHCE Egypt
52
criteria name .
criteria find
RHCSA/RHCE Egypt
53
which
whereis
which
whichcommand
Archive
Compressing
Compressing- :Uncompressing
) (x server archive mangerapplication accessories archive manger
gzipgunzip
1) #gzipfile1
2) #gunzipfile1.gz
.gz
#gzip-cfile1>file1.gz
RHCSA/RHCE Egypt
54
bzip2 bunzip2
.bz2
#bunzip2jana.bz2
#bzcatfilename
) (Compression Ratio Compression Ratio bzip2 gzip
Compression Ratio
.
zip zip PKZIP MS-DOS /
. zip
#zip
#zipcloak
#zipnote
#zipsplit
#unzip
#zcat
tar . :
tar[OPTION...][FILE]...Function
archive
RHCSA/RHCE Egypt
55
tar f
) (- tarct = tar-c-t
tar
gzip
bzip2
tar.xz
)(verbose
-A
-r
-z
-j
-J
-v
-c new_dir
RHCSA/RHCE Egypt
56
$
tab ^I
Ctrl ^n
cat -A
TAB CTRL
wc
)(word
/ tab
.
RHCSA/RHCE Egypt
57
finding text
FINDING TEXT
grep
. - :
$ grep -e t -e f file1 :
capitalsmall
-P FOR Perl-regex
-f FOR
-G FOR basic-regex
-x FOR match whole line
-E FOR extend-regex
-v FOR invert match
)REGULAR EXPRESSION(regex
:
@ . com
,
a h
. regex
regular expression
) (patternregex
^ cart ) (line that begin with
RHCSA/RHCE Egypt
58
finding text
] [ bracket expression
] [abc a b c
] [a-f a f small
] [A-F A F capital
] [^a-f a f
] [a-fA-F A (capital &small) F
] [1-9 1 9
] [!
) ( modifiers
Modifiers
= n
1 7 n=minimum m=maximum
m
n
*
+
?
}{n
}{n,m
}{,m
}{n,
RHCSA/RHCE Egypt
59
finding text
\ )(escape . \. .
grouping
) (
| )(or
RHCSA/RHCE Egypt
60
finding text
sort
sorting
.
) sort ( .
) ( ) (sorting )
( .
sort
RHCSA/RHCE Egypt
61
finding text
sort n
o u
sort
) sort key (.
ls k
n
sort key k5 k7
t : )(-t :
uniq ) ( . .sort
cut sort ) (
-d tab
RHCSA/RHCE Egypt
62
finding text
Paste
tab
diff
RHCSA/RHCE Egypt
63
finding text
tr
#tr a-z A-Z < lowercase.txt
tr :
split--lines=190-<oldfile.txt
split-190oldfile.txt
.
split--lines=190- newfiles<oldfile.txt
split-190<oldfile.txt
RHCSA/RHCE Egypt
64
awk
.
)-: regex grep
) (redirection pipes
&& || - (
awk #awk'BEGIN{print"Test Program"}' :
" "Test program awk
awk pattern {action} : " "pattern " "action
" "BEGIN
" "print "."Test program
) $0 $1 - $2 - (
)( -F fs v
< ): < = , == , =! , > = , > ,
~ , ) ( !~ , ) ( ( regex /../
awk'{print $0}' grep.test.txt
awk'{print $1}' grep.test.txt
awk'{print $2}' grep.test.txt 2
2 awk'{print $2,$1}' grep.test.txt
awk'/Red/{ print $0}' grep.test.txt
2012 awk' {if ($2 ~ /2011/){print $0 }' grep.test.txt
awk'/2011$/{ print $0 }' grep.test.txt 2011
awk:
`1- name=`whoami
'}#awkvname=$name'BEGIN{print "Welcome",name
'}2- awk'BEGIN{name="Khalid"}{print"Welcome",name
.
RHCSA/RHCE Egypt
65
awk
+) : - , * , / , % , ) 0 1 ,
( () , += , -= , *= , /= ,
%= , ++ , -- , 1 (
""AWK
:NF
:NR
: FS
:FILENAME
:RS ,
:ORS
:OFS
}) {do this action ( ) {do this action}else ( 1) if
}) { the action ( 2) while
}) (3) do{the action}while
;continue or ;break }) { the action ( 4) for
#!/usr/bin/awk-f #awk-f program_name
AWK
awk :
" "
)atan2(y,x
)cos(x
)exp(x
)int(x
)log(x
1 0
)(rand
)sin(x
)sqrt(x
)(rand
)srand(x
:
) gsub(r,s,t) -gsub(r,s " "r " "s " "t
$0
" "t " "s " "t
)index(s,t
""x
)length(x
" "r ""s
)match(s,r
" "s " "r ""r
)split(s,a,r
)tolower(s
)toupper(s
}){Action(functiontest1
awk
: awk
:
arrayname[string]=value
:value
:string )(index
:arrayname
for.in for(var in arrayname){action } :
:arrayname :action
:in
:var
)(index
]deletearrayname[index
delete :
awk :
]for(var in arrayname){delete array[var
.
RHCSA/RHCE Egypt
66
Process Management
PROCESS MANAGEMENT
) (application ).(process
) .(application RAM ).(process
) (execute exe msi .binary
) (process ps tty
pts PID
:
: ) " (" daemons
). (Services
) ( ) .(client
) (root user
lp, bin, www, mail).( .
: .
: .
PID
process process PID PPI
Parent Process ID Process .
write on fault
nano bash bash parent nano bash
10 MB RAM nano Size on RAM , Instruction
set ) ( Customize .
(1 load
(2
(3 tty 3 tty 3
child.
1) Foreground Apps:
web server ) (2) Background Apps :
ps .
man ))(Unix option (-) BSD option GNU option (--
parameter ps
pid
terminal
.
a x terminal
RHCSA/RHCE Egypt
67
Process Management
ps-ef psaux
Z
register format
PID text
editor nano
stat stat
process SN
(1
)1. Runnable (R
)2. Voluntary (Interruptible) Sleep (S
)3. Involuntary (Non-interruptible) Sleep (D
)4. Stopped (Suspended) Processes (T
)5. Zombie Processes (Z
:Runnable (R)-1 Runnable .
) ( runnable
. runnable
.
:Voluntary(Interruptible) Sleep (S)-2 .
network daemons httpd . )) (client (
.
:Involuntary (Non-interruptible) Sleep (D)-3
. block block .
. .runnable
:Stopped (Suspended)Process (T)-4 .
. CTRL-Z .
:Zombie Processes (Z)-5 zombie stat
. zombie process executing .
.
:
<: The process is running at high priority
N: The process is running at low priority.
L: The process has pages locked in memory.
s: The process is a session leader.
l: The process is multi-threaded.
+: The process is running in the foreground.
Services Daemons Daemons d
http =httpd ,vsftp =vsftpd
.
RHCSA/RHCE Egypt
68
Process Management
top ps
.
.
top top
gnome-system-monitor
top )(x server
Application system tools system monitor
RHCSA/RHCE Egypt
69
Process lifecycle
pgrep
]pgrep [SWITCHES] [PATTERN
PROCESS LIFECYCLE
Process Admin
1) Start
)2) End (Kill
- start-1 ) (start process :
-1 )(process creation
-2 )(command execution
:
.
- :
-1 ) (creating new process Forking
forking .
) (child ) (parent
. umask
-2 ) (new command creation Exec-ing
execing
.
execing . umask
:
forking execing network daemons execing forking login /sbin/init process Mother of all Process and Parent of it self
init kernel process management Scheduler
kernel
init pstree
RHCSA/RHCE Egypt
70
process SCHEDULING
pidof
pid
strace
redhat$sudostrace-p5810
)(ending process
) (normal exit
) (signal ) status code (return value .
.status code
R S D T Z
PROCESS SCHEDULING
.
)(cpu .
) .(scheduling ) (dynamic value
) (fixed value .
) (priority ps top PRI
: backup 3 Access Data
30 3 Access Data
backup . Antivirus
.
static value niceness value 20- 19 0
)(priority
nice value )( priority )(
: 3
.
nice process niceness :
RHCSA/RHCE Egypt
71
process SCHEDULING
simulation 19
NI nice value PRI priority
20- 19
nice priority
19 ) (- nice -19 19
Priority root
Priority 15 0 )(greedy process
load
- end-2 :end process signal kernel / .kill
signal
.
) Software interrupts( .
. .
RHCSA/RHCE Egypt
72
process SCHEDULING
)(signals
signals .
Hardware exception
.
Software condition
Terminal Interrupts
ctrl + c signal 2 ctrl+z signal 20
Other process
signals
kill Kill signal .
signal
-1
:
) Terminate( : )(killed
) Ignore( :
:
Core
core .
: .
) Stop(
-3
-2
-4
RHCSA/RHCE Egypt
73
process SCHEDULING
kill 9
15 9 .
terminated (Default Signal) Process #kill-15: gracefully end
#kill-9: Force Kill
# kill-1: service
pkill
Killall
]pkill[-signal][SWITCHES][PATTERN
RHCSA/RHCE Egypt
74
) (job )(foreground
) (background & & $cat teba
job number ) (background jobs
&>$nohup <command
+
background foreground fg jobs bg
kill job %
: at crontab
Cron ) (cron services 10
. crontab
)(cron crond daemon .single user mode
cron )(/etc/cron.allow,/etc/cron.deny
)- :(/etc/cron.allow cron
cron ./etc/cron.deny
)- :(/etc/cron.deny .cron
).(root user
.
RHCSA/RHCE Egypt
75
anacron
anacron .
.
.
. anacron ./etc/anacrontab
:
cron table
cron table /etc/crontab cron table
-1 ) comment( )(#
-2 ) environment variable( =name
-3 ) cron command (cron table .
RHCSA/RHCE Egypt
76
/etc/crontab /etc/cron.d
crontab crontab :
./etc/crontab
. run-parts
crontab /etc/cron.d crond
/etc/cron.d ./etc/crontab /
crontab crontab :
-1 crontab /var/spool/cron
crontab .
-2 crontab
) (run as administrator in windows .
/etc/cron.d . sysstat
./etc/cron.d
run-parts /etc/cron.hourly/
anacrontab run-parts .cron.period
: /etc/cron.d/ 0hourly anacrontab run-parts
/etc/cron/hourly
run-parts .
.
RHCSA/RHCE Egypt
77
/etc/cron.hourly/ 0anacron
anacron . /etc/cron.d/0hourly
anacron run-parts .
)( )(
. >crontab
) /tmp/ crontab (
:tmpwatch /tmp/
240 /tmp/
.
. crontab /etc/cron.daily
.
at) atd daemon (at "
" 2:00 am . :
at atd daemon
) (/etc/at.allow , /etc/at.deny cron .
atd daemon at f
at[-f filename | -m]TIME
-d
-c
Ctrl+d
-l
batch at
:at
# at 9am
# at now + 3 days
# at 1:30 3/22/10
# at 10:07am
>at
at> wall Hello World
>at> <EOT
RHCSA/RHCE Egypt
78
df
DF
df
DU
df
df
.
-h
) ( -s
RHCSA/RHCE Egypt
79
Working
With Shell & script
.
.
/
-1 : kernel .
.
-2 : FSF
emacs gcc .
-3 : . .
-4 CLI GUI
/ . " "Package
.
package manger
.
SHELL
"" shell /.
) . (shell scripts .
:
-1 history
history terminal .login
./bach_history c history c history
!! !-5 !c .c
-2 tab
tab .
RHCSA/RHCE Egypt
80
TYPE OF SHELL
TYPE OF SHELL
Shell
)(Description
.
/ Bash
AT&T . ) $ root .(#
Sh
Bourne shell
bash
) .( Bourne-Again Shell / .
) ( AT&T
.$
- C .
Ksh
Korn shell
ash
-
) (alias
. .%
.
. tcsh
csh
.zsh
Bash . .
) ( . .
SHELL CONFIGURATION FILE
sh
ksh
tcsh
zsh
bash
/.profile
) (
/.kshrc & /.profile
) (
RHCSA/RHCE Egypt
81
TYPE OF SHELL
RHCSA/RHCE Egypt
82
shell script
/etc/skel
.
. . home directory
)(.
- );(
subshell ) (
: , automation ) (script
.
interpreter . interpreter
) /bin/bash ( /bin/sh . ) (interpreter
.
Prog:
prog App:
)Window : .exe or .msi (Microsoft Installer
Linux .bin
RHCSA/RHCE Egypt
83
shell script
Interpreter
binary file
Bash PerlPython
C++C
-2
-3 ) (executable chmod
>#chmodu+x<scriptname
Script
) (script foo.sh ) (home directory
foo.sh ) ("no such file or directory" error.
. PATH PATH
-1 ./script ~/script ) (.
-2 PATH
-3 /bin root ~/bin
RETURN VALUE
.
) (requesting process parent child child .
) ( return value .exit status
parent ) return value ( child.
.
RHCSA/RHCE Egypt
84
shell variable
return value 0
description
code
Description
Successful completion of the command
128
Invalid exit argument
General unknown error
128+x
Fatal error with Linux signal x
Misuse of shell command
130
Command terminated with Ctrl+C
The command can't execute
255
Exit status out of range
Command not found
RUNNING MULTIPLE COMMAND CONDITIONALLY
code
0
1
2
126
127
-1
-2
-3 ;
-4 && || EXIT STATUS
&& | | . .
return value .
.
.
.
SHELL VARIABLE
shell variables
shell variable .
) (shell variable ) (scripts .
environmental variable -2
)local variable -1 (shell variable
.
RHCSA/RHCE Egypt
85
shell variable
local variable
environmental variables
environmental
. .
environment .
#echo$variable_name
echo $ - :
local variable
#A=apple - : A apple
)=( .
.
.
. .
environmental
ALIASES
.
variable
BASH
BASH_ALIASES
BASH_ARGC
BASH_ARGV
RHCSA/RHCE Egypt
shell variable
86
BASH_CMDS
BASH_COMMAND
BASH_ENV
BASH_EXECUTION_STRING The command(s)passed using the bash c option
BASH_LINEO
BASH_REMATCH
BASH_SOURCE
BASH_SUBSHELL
.0 .
(minor & major)
BASH_VERSION
BASH_VERSINFO
(major)
If set to a valid file descriptor (0,1,2), then trace output generated from the set x debugging option can be
BASH_XTRACEFD
BASHOPTS
BASHPID
COLUMNS
COMP_CWORD
COMP_LINE
COMP_POINT
COMP_KEY
COMP_TYPE
COMP_WORDBREAKS
COMP_WORDS
COMPREPLY
DIRSTACK
EMACS
EUID
FCEDIT
FINGNORE
FUNCNAME
GLOBIGNORE
GROUPS
PID
The final key used to invoke the current completion of a shell function.
An integer value representing the type of completion attempted that caused a completion shell
function to be invoked.
The Readline library word separator characters for performing word completion
A variable array that contains the individual words on the current command line.
A variable array that contains the possible completion codes generated by a shell function.
TAB
A variable array that contains the current contents of the directory stack.
Indicates the emacs shell buer is executing and line editing is disabled, when
set tot.
EMACS
The numeric eective user ID of the current user ID
The default editor used by the fc command
A colon-separated list of suxes to ignore when performing file name completion.
RHCSA/RHCE Egypt
shell variable
histchars
HISTCMD
HISTCONTROL
HISTFILE
HISTFILESIZE
HISTIGNORE
HISTSIZE
HISTFILE
HOSTNAME
HOSTTYPE
IGNOREEOF
INPUTRC
LANG
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MESSAGES
Determines the locale setting used when interpreting double- quoted strings preceded by $.
LC_NUMERIC
LIENO
LINES
MACHTYPE
MAILCHECK
OLDPWD
OPTERR
OSTYPE
PIPESTATUS
POSIXLY_CORRECT
PROMPT_COMMAND
PROMPT_DIRTRIM
PS3
87
PS4
RHCSA/RHCE Egypt
88
shell variable
The prompt displayed before the command line is echoed if the bash -x parameter is used.
The current working directory.
Returns a random number between 0 and 32767. the random number generator.
The default variable for the read command.
The number of seconds since the shell was started. Resets the timer to the value.
PS4
PWD
RANDOM
REPLY
SECONDS
SHELL
A colon-separated list of enabled bash shell options.
Indicates the shell level, incremented by one each time a new bash shell is started.
A format specifying how the shell displays time values.
read
Directory name where the bash shell creates temporary files for its use.
SHELLOPTS
SHLVL
TIMEFORMAT
TMOUT
TMPDIR
UID
) (environmental variable
. ) (environmental variable
LANG . unset environmental variable local variable
.
-1 set local variable environmental variable
RHCSA/RHCE Egypt
89
shell variable
.
- :set )> (set [-/+] <option ) (- on ) (+
off ) (set +m .
) (set o
)> (set [-/+]o <set_name ) (- on ) (+ off set_name ). (set o
shopt set shopt shopt-p
shopt-s on shopt-u off
)(using parameters in shell script
i i love you
) (positional parameter $n } ${n n , 2 , 1, 0
3
} ${0 ./teba.sh
i hate love you i love you
* $
} ${#
} ${:- } ${1} ${2
PATH
PATH
RHCSA/RHCE Egypt
90
PATH :
PATH
COMMAND LINE EXPRESSION
) ) ( (wild cards .
) (file globing .
.
} {
history
) brace expansion (
}{c,b,r . cat , bat , rat ) brace expansion (
postfixes prefixes .
brace expression
.
RHCSA/RHCE Egypt
91
~
tilde expression ~ home
~username home .
RHCSA/RHCE Egypt
92
-2 $[1 + 2] brackets
-3 expr
* \ ) (back slash
expr 5 \*2
escape character * *\
-4 bash calculator bc
bc q
bc script - :
bc .
command substitution .
command substitution ) (back tick ` `command
) $(subcommand .
$
RHCSA/RHCE Egypt
93
single quoting-3
) \ ( Backslash
Quoting prevents expansion
o Single quotes (') inhibit all expansion
o Double quotes (") inhibit all expansion, except:
$ (dollar sign) - variable expansion
` (back quotes) - command substitution
\ (backslash) - single character inhibition
! (exclamation point) - history substitution
ALIASES
aliases .built-in command))alias
ls
RHCSA/RHCE Egypt
94
aliases dir ls
aliasNAME=VALUE
dir
aliases alias p
; .
SHELL PROMPT
) (prompt .
RETURN
RHCSA/RHCE Egypt
95
PS1
DNS
ASCII
12 )(HH:MM:SS
)(cwd
\d
\h
\j
\n
\s
\T
\u
\V
\W
\#
\nnn
[\
ASCII 07
esc 033
FQDN DNS
)(terminal
enter
24 )(HH:MM:SS
24 )(am , pm
history number
$ # )(root
\a
\e
\H
\l
\r
\t
@\
\v
\w
!\
\$
\\
]\
RHCSA/RHCE Egypt
96
shell
.
shell :
.1 ) :(redirection /
.
.
. 2) : (Pipes .
.3 :
. .
.1 ) :(redirection .
commandoperator_file_name
RHCSA/RHCE Egypt
97
<< : .
#mail s please call jana@example.com <<END
> hi
> please give me a call
> END
: /dev/null
/dev .
; )(..
semantic } {.
syntactic ) (ls; pwd ;file } { ls; pwd ;file
$cat /etc/jana 3>file1.txt 4>file2.txt 5>file3.txt
.2) : (Pipes .
command 1 | command 2 | command 3
.
RHCSA/RHCE Egypt
98
tee pipes
$uniq|tee /tmp/x.x|awk-ftransform.awk
.3 : & shell
. ps .
.
-1 - :echo built-in command
.
.
echo
wild cards.
echo :
echo ) (. ) (.
.
% .
%f floating
%c char
%s string
%d decimal
%o octal
%x hexadecimal
%u
jana s jana c
j
echo n
printf
\c
\t \b TAB backspace
\n
RHCSA/RHCE Egypt
99
left align - )(right align +
) (field width 0
field width
) Precision (. s c g
flages d x ou
-1 10 JANA -2 10 JANA
%5.10s 10 5 %10.5d 10 2
.
RHCSA/RHCE Egypt
100
:
test expressions expression ] [
) return value (exit status . test
. .
return value 0 0
:
-1
-eq
=
-ge
-gt
-le
-lt
-ne
-2
=:
=
=!
-n
-z
>
<
\ >\ <\
-3
-r
-x
-4
!
not
-o
OR
-a
AND
- : ) (
.
-f
-w
-G
-d
-s
-O
SCRIPTING :
.1 : if then .
.2 : if then else , command 1
. command 2
RHCSA/RHCE Egypt
101
]If [expression
then
commands
]elif [expression
then
commands
else
commands
fi
expression command ] [
exit status exit status = 0
:
:
#!/bin/bash
$ ./test1
# testing the if statement
Sat Jan 23 14:09:24 EDT 2011
if date
it worked
then
$
echo it worked
fi
:
#!/bin/bash
$ ./test2
# testing a bad command
./test2: line 3: asdfg: command not found
if asdfg
we are outside of the if statement
then
$
echo it did not work
fi
echo we are outside of the if statement
IF THEN
if command; then
commands
fi
:IF THEN
(( expression )) Double parentheses . [[ expression ]] double Brackets else if fi elif .fi .4 select case .
switch case if statement
: yes no .
) (syntax :
case string1(variable) in
)str1
;;commands
)str2
;;commands
)*
;;Default commands
esac
RHCSA/RHCE Egypt
102
.5 :for )(loop
)(loops .
)(Iteration )(loop
) (Iteration .
for c :
(( for
variable
; assignment
; condition
iteration
)) process
RHCSA/RHCE Egypt
103
1
2
3
4
5
6
7
8
9
10
.6 :while
] while [ expression
do
commands
done
1) Break
2) let x=$x+1 :
read
- n Input
.7 until while
] until [ expression
do
commands
done
.8 functions
{ ) ( fname
commands
}
{ ) fname2 ( arg1, arg2, argN
commands
}
RHCSA/RHCE Egypt
104
Storage
Device
- :
) (partition
partitioning .
) (mount /.
) ( )(dmesg
/proc/partition
) (cfdisk, sfdisk parted
fdisk
fdisk
cfdisk-1 ) partition table ( partition table
. fdisk
fdisk-2 BSD disk label) (other non-DOS partition Table
sfdisk-3 fdisk cfdisk .
parted gpt.
- :
-1 /etc/fstab ) (mounted ) (boot .
. .
-2 - :mount )
(/proc/ ./etc/mtab
-3 - :df -h .
-4 : /proc/partitions
) ( )(HARD DISK
7200 15000
RHCSA/RHCE Egypt
105
raw device
.
) (HARD DISK ) (
) Intel/IBM/PC/DOS(
) (partition MBR Inode table sun gpt.
- :
-1 Intel/IBM/PC/DOS (Logical block address) LBA
BIOS
primary-1- : .
extended-2 .
). (logical partition
partition - :
Logical part
RHCSA/RHCE Egypt
106
partitioning
master
hdc
master
hda
slave
hdb
24 (48 pin)parallel 24
.
)2- SATA (serial
sdx x )(a,b,c,d
)(sda, sdb, sdc, sdd, sde -------------------------------------------------and soon
)3- Other (SCSI, SSD, SAS, FLASH DRIVE, CD-ROM
sdx x )(a,b,c,d
)(sda, sdb, sdc, sdd, sde -------------------------------------------------and soon
- : ) (hot removable .
/dev /dev/sda
PARTITIONING
Parted
MBR, GPT
fdisk
MBR
2
RHCSA/RHCE Egypt
107
partitioning
fdisk
/dev/sda1 /dev/sda2 /dev/sdb.
Device-1
) (bootable partition * .
Boot-2
) (cylinder .
start and end-3
Blocks-4
partition block block .1024 bytes
hexadecimal ).(partition id no.
Id-5
Id .
System-6
-2 parted l :
]#parted[options][device
CREATE PARTITION
-1 fdisk
fdisk :
partition n
m fdisk
partition d
w
(MBR GPT) partition table o
partition table p
q
F.S partition t
w
RHCSA/RHCE Egypt
108
partitioning
partition fdisk
partition n
partition
partition
partition
partition
partition p
-2 sfdisk
fdisk gpt
:
-1 partition
-2 partition
-3 partitions
-4 (repartitioning) partition
-1 partition s
]#sfdisk-s[device
device device
.
RHCSA/RHCE Egypt
109
partitioning
-2 partition l
-3 partition V
-4 partition repartition
)> (#sfdisk <device ) (partitioning
) (standard input ) (partition table .
sfdisk
-T
]-g[device
-Nnumber
# sfdisk /dev/hdb -N5
-Anumber
active inactive
sfdisk :
><start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s
> <start> <size ><type
) (,
L is (LINUX_NATIVE (83)) (default) , S is LINUX_SWAP (82), E is EXTENDED_PARTITION (5),
and X is LINUX_EXTENDED (85).
sfdisk
partition
u sfdisk
uS -uB ) ( -uC -uM
-uS, -uB, -uC, -uM: accept/report in units of sectors/blocks/cylinders/MB
RHCSA/RHCE Egypt
110
partitioning
5 ) (5 partition ) 50 (/dev/sdd1
uM sfdisk ) 50 (/dev/sdd2 ) 200 (/dev/sdd3
) 2 (/dev/sdd4 ) (/dev/sdd5 .
/dev/sda
I O:
) (partition table c
b :
.
RHCSA/RHCE Egypt
111
partitioning
-1 ) (partition table d
#sfdisk-d/dev/hda>/hda.out
-2
#sfdisk/dev/hda<hda.out
sfdisk gpt
gpt sgdisk
partition map (partx) kpartx
multipath
image
-3 parted
gpt parted
) (parted parted .
help
partition parted
RHCSA/RHCE Egypt
112
)(File system
-1 select device_name
-2 ) (partition table gpt MBR
-3 partition :
-4 print
)mkpart (primary/extend) (fs type) (start) (end
partition
parted quit
)(FILE SYSTEM
/ .
-1- : / ext2 2.4
ext3 ext4 ext2 journaling
. Reiser
-2 / NTFS VFATMSDOS : FAT16
FAT32 .NTFS HFS.HFSplus
-3 - CDs/DVDs ISO9660.UDF
-4 JFS2 XFSReiserfs
-5 NFS.SAMBA
-7 /proc//sys/
: GFS.Coda
-6
partition
file system )(name and ID
RHCSA/RHCE Egypt
(File system)
113
ext4 partition
#mkfs-text4/dev/sda
or
#mkfs.ext4/dev/sda
#mkfs.ext2/dev/sda
or
RHCSA/RHCE Egypt
- : ext2
#mkfs-text2/dev/sda
or
mke2fs/dev/sda
.
114
mounting media
mke2fs .ext2
)(block size
inode
#dumpe2fs/dev/sda1
/dev mount .
) (mount - :
OPTIONS
/etc/fstab
(verbose) mount
)(file system
) (device
) (device
label
UUID
) ro rw loop (
) Check=none (
label e2label
) (file system = F.S no F.S
mount -a -t nomsdos,ext
-a
-v
-s
-r
-w
-L
-U
-o
-l
-tF.S
RHCSA/RHCE Egypt
115
mounting media
async
atime
/etc/filesystems partition
) (floppy )(removable device
auto
defaults
dev
exec
suid
nouser
/etc/fstab
remount
ro
rw
)(mount
)/etc/fstab (file system table .mount
Check order
Dump
Option
Fs type
Mount point
) (device
RHCSA/RHCE Egypt
116
secure erase
-4 ) (option #mount-ooption
Dump-5 user . . 0
Dump 1 Dump . 2 1
Check order-6 fsck . 0 1 2
1 .2
0 fsck.
label
devices devices mount
label device label
#e2label/dev/sda1 data or #mount-l/dev/sda1 data
#e2label/dev/sad1
label device
#findfsLABEL
device label
>Syntax: findfs LABEL=<label>|UUID=<uuid
fstab device name ) (Label=data data label
-2 ]UUID [universal unique identified
format partition
#blkid
UUID partition
fstab device name ) NO. (UUID=NO. UUID partition
umount device :
#fuser [options] MOUNT_POINT | FILE SYSTEM
OPTIONS
-c
)(mounted
-k
) (device
-m
) (device
-u
user id
-v
#lsofdevice
#lsof-mdevice
.mount iso image
#mount-oloopmage-namemountpoint
cdrecord
SECURE ERASE
) (RECOVERY TOOLS 2000 PATA
SATA recovery
. secure erase
-1 recovery .
-2 )(magnetic trace
.
)-: (secure erase
DOS HDDErase .
/ - :
-1 hdparm ) (root user - :
1-#hdparm--user-masteru--security-set-passpassword/dev/sda
)2-#hdparm--user-masteru--security-erasepassword/dev/sda (or --security-erase-enhanced password
u 1 2
password NULL
- : hdparm
) (firmware PATA SATA
) (power option noise reduction )(read only flag
.
.
RHCSA/RHCE Egypt
117
secure erase
- :
#hdparm[flags ][device] ..
)1-(#hdparm-I /dev/sda
)2-(#hdparm-i /dev/sda
)3-(#hdparm
)4-(#hdparm-t--direct/dev/sda
)5-(#hdparmtT/dev/sda
hdparm tT t ) (device read timingT
.(cache read timing) cache
4 5 .
)6-(#hdparm-d1/dev/sda
DMA
DMA .
hdparm-dx x DMA.
)7-(#hdparm-S24/dev/sda
)(24*5=120sec
)8-(#hdparm/dev/sda
)9-(#hdparmX66 /dev/sda
d
RHCSA/RHCE Egypt
118
swap
SWAP
:( .RAM(
RAM swap space
virtual memory
RAM RAM
) (swap space ) (swap partition
). (swap file
Swap partition
Swap file
) (virtual memory swap RAM
=2*RAM
:
- :/etc/fstab swap fdisk /proc/swaps
RHCSA/RHCE Egypt
119
swap
- :ps .
- :top ps . .
- :free . m
.
- :vmstat .
- :slabtop
- : sar sysstat
#sar 10 5
10
#sar B to see paging #sar r to see ram usage #sar W to see swap activity
#sar q to see run queue #sar u traditional cpu usage #sar w
swap
swap :
mkswap swap
swapon swap swapoff
dd
-2 file
-1 partition
-1 partition
partition
F.S partition swap swap
mkswap swap sfdisk fdisk :parted
swap swapon
.
RHCSA/RHCE Egypt
120
LVM
/dev/sde1
-2
swapfile :
#ddif=dev/zeroof=/swapfilebs=1Mcount=2012
F.S swapfile swap :
#mkswap/swapfile
swap swapon
#swapon/swapfile
partition swap swapon-s
fstab F.S swap
LVM
) (advanced partition management .
Logical Volume Manager LVM
) HP-UX
(HP LVM2 .
LVM :
: .
-1 : Physical Volumes PV
) software RAID (RAID hardware VG
physical extent PEs 4
-2 : Volume Groups VG .
LV PV
-3 :Logical Volumes LV
LV .
)
(
.
:
-1 )(resize
-2 ) LVM1 / (snapshot) (LVM2
RAID0-3 1 5 LVM RAID
LVM .
-4 .
): 1 PV )2 VG )3
.
RHCSA/RHCE Egypt
121
LVM
vgdisplay VG vgs .
-4 LV lvcreate- :
-lPE_vol PE
.
RHCSA/RHCE Egypt
122
LVM
30M 30 3G 3
lvdisplay LV lvs .
/dev/vg0/lv5
-5
) (logical volume
RESIZING LOGICAL VOLUME
unmounted.
LVM ) (volume group .
SCSI / dev/sdb1 .
SCSI / dev/sde1 :
.
RHCSA/RHCE Egypt
123
LVM
-1 vg pv :
-2 vg0 /dev/sdb1
/dev/sdb1
vg pvmove
-3 /dev/sdb1 VG
-4 pv
12G ( resize)20G
-1
-2 ) (physical volume
-3 old volume group vgextend
-4
#lvextend--size+8G/dev/vg0/lv5
or
#lvresize-L20G/dev/vg0/lv5
-5 ) (logical volume
#resize2fs/dev/vg0/jana
20G (resize) 8G
unmount
-1 umount
#umount/backup
-2 F.S e2fsck-f
)(force check
#e2fsck-f/dev/vg0/jana
-3 20G 8G
#resize2fs/dev/vg0/jana8G
-4 ) (logical volume
#lvreduce--size-12G/dev/vg0/jana or #lvresize-L8G/dev/vg0/jana
#mount/dev/vg0/jana/backup
3 4
#lvreduce-r--size-3G/dev/vg0/jana
resize to Inode table resize to volume
Resizing the root partition
partition/LVM umount .
) (root partition
) (unmount . ""
" rescue" disk/CD/DVD .
LVM .
rescue mode .mount
-1 rescue-mode
-2 skip shell start shell
RHCSA/RHCE Egypt
124
LVM
-3 LVM vgchange a y vg
a y yes:
-4 VG mapping VG .
VG root partition lv_rootlv_swap
-5 e2fsck f
-6 lv-root resize2fs
-7 lvreduce
15G
- :logical volume
- : LVM1-1 2.4 basic LVM
- : LVM2-2 2.6 LVM1
:
snapshots-1
logical volume
backup LV )(active
.
RHCSA/RHCE Egypt
125
LVM
.
logical volume :
LVM physical volume
RHCSA/RHCE Egypt
126
RAID
PV VG
LVM Volume Group )PEs (physical extend size
VG ""add
volume group ) (mount F.S.
RAID
Redundant Array of Inexpensive Disk
RAID
.
.
.
RAID ) (
.
.
) (
) RAID disk matrix (RAID array .
100
100 ) 30 (70
.
/etc/raidtab RAID
RAID software RAID hardware RAID . hardware RAID
hardware RAID ) (RAID controller ) (H.D
.
RHCSA/RHCE Egypt
127
RAID
) RAID
( :
- :(stripping) (RAID0)-1
.
.
- :(mirror) (RAID1)-2
)( )
( .
) (
.
. )
( .
.
- :(RAID2)-3
bit
) (parity
32
39.
- :(RAID3)-4
RAID1+0=RAID10
RAID0+1=RAID01
RHCSA/RHCE Egypt
128
RAID
) (for recovery .
3
) ( raid6
2 ) (.
RAID - :
-1 .
-2 .
-3 RAID .
-4 .
-5
RAM .
-6 .
RAID .
- : RAID .
(multiple disk) md
modconf .
mdadm .
)-:(RAID
-1 Linux raid auto fdisk.parted
-2 .RAID
>#mdadm[mode]<raiddevice>[options]<component-devices
)(10 ,5 ,1 ,0
spare
RAID
RAID1
RAID5
/dev/md0 RAID
level=5 RAID )(RAID5
raid-devices=3 RAID
) (
mdadm --detail or mdadm D
RAID /proc/mdstat
RHCSA/RHCE Egypt
129
RAID
-3
-4 ) (mount point- :
fstab
#mount/dev/md0/backup
sda3 - :
-1 RAID sda3 :
.
RHCSA/RHCE Egypt
130
quota
#mdadm/dev/md0-f/dev/sda3
#cat /proc/mdstat
-2 RAID
#/mdadm/dev/md0-r/dev/sda3
-3 sde1
#mdadm/dev/md0-a/dev/sde1
-4 synchronization RAID recovery RAID .
RAID
#mdadm--scan
)#mdadm--stop(-S
#mdadm-A--scan
#mdadm--removeraid_name
boot partition basic partition ) RAID1 partition(software RAID grub
hardware RAID GRUB .
QUOTA
- : quota
quota quota
.quota F.S .
: storage limitation .
) (Inode
). (disk block
) (disk block ).(Inode
quota soft limit hard limit
hard limit soft limit
hard limit hard block limit
.
soft limit soft block limit
hard limit
soft limit
soft limit ) (
soft limit hard limit
hard limit soft limit .
quota .
) (hard limit .
QUOTA - :
QUOTA F.S )(implement in kernel )(data base for quota quota - :
-1 (mount with quota support) quota
-2 (create dB for quota) quota
-3 quota ))(switch on quota (kernel
-4 (change/set quota) quota
#yum install quota
: RPM quota
-1 quota mount fstab
fstab
quota
:usrquota
:grpquota .
.
RHCSA/RHCE Egypt
131
quota
quotas
mount
/dev/sdc1
/opt/company_data
ext4 defaults,usrquota,grpquota 1 2
mount
#mount-oremount/mnt/exmple
Mount
#mount-ousrquota,grpquotadevice_namemount_point
- : quota selinux :
#setenforce0
selinux enforce permissive
#chcon--reference/home//data/
security policy home /data/ journal quota
-3 quota a quota
#quotaon/mnt/example
-4 quota quotas u -g :
#edquota-uuser-name
aquota.user
:
soft limit 50
hard limit 100
#edquota-t
RHCSA/RHCE Egypt
132
#quotacheck-amvug
quota :
quota #repquota/data/
setfacl acl.
physic physics_theme
bob ventura .
getfacl 3
RHCSA/RHCE Egypt
133
getfacl
:
-1 )(u|g|o|m
-2
.
-3 .
ACL
RHCSA/RHCE Egypt
134
. ACL ACL
default d
getfacl sgid ls -ld
ACL .
ls-l ACL ""+ .
mv ACL .
cp P ACL
ACL EXT3 .(acl mount) acl
5 EXT3 ACL .
mount fstab
acl fstab
/dev/sdc1
/opt/company_data
ext4 defaults,acl 1 2
- :
File based ACL chmod
Network based ACL .
File based ACL
ACL - :
-1 (mount with ACL support) ACL
-2 ACL ))(switch on ACL (kernel
#yum install acl
: RPM acl
-1 ACL mount fstab
-2 ACL
# setfacl-mu:user01:rwx/opt/backup/file1
#setfacl-xu:user1/opt/backup/file1
acl x m:
#setfacl-b/opt/backup/file1
acl b:
)(miscellaneous filesystem management commands
-1 fsck
- : .
.
fsck
) (File System ChecK .
RHCSA/RHCE Egypt
135
)Autofs (Automount
(fsck.<version>) mkfs
t t ) (.
.
#fsck.ext2 = #fsck-text2 = #e2fsck
fsck .
.
fsck y .
ext2 /lost+found .fsck
fsck .
-2 tune2fs
tune2fs ext2 ext3 .
tune2fs ).(unmount
.tune2fs
/etc/sysconfig/autofs
/etc/auto.master
DEFAULT_TIMEOUT=300
"DEFAULT_BROWSE_MODE="no
RHCSA/RHCE Egypt
136
)Autofs (Automount
-2 /etc/auto.misc
automount
NFS directory
boot
floppy
SCSI
IDE slave
auotmount
cd
-fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
:
][Relative pathname
][Mount options
][Location
RHEL .autofs
/dev/cd automounter
ls /misc/cd automounter .ISO9660
))(RO ) .((nodev) (nosuid 300 automount /etc/sysconfig/autofs
# # automount
.
RHCSA/RHCE Egypt
137
)Autofs (Automount
-rw,sync
rhel01:/opt/company_data
mount NFS
*
-rw,sync
&:/home&/
mountuser home directory
: indirect map wild cards )&(*,
:direct map
/usr/data
-rw,sync
rhel01:/opt/company_data
indirect map direct map absolute pathname indirect map
.
-3 /etc/auto.net
NFS IP
DNS /etc/hosts ./net
512 sector
sector track
tracks cylinder
= head * cylinder * track * sector
company_data
RHCSA/RHCE Egypt
138
Installation
Of RHEL
:
-1 )(CD\DVD usb )(boot.iso
-2 ) (network manual automated
:CD/DVD
)( :
-1 )(Anaconda Stage 1
) (bootable media
.
:
installation disk-1
boot.iso image-2 4 CD
/images
diskboot.img-3 /images usb
(Pre eXecution Environment) PXE-4
-2 )(Anaconda Stage 2
rpm )(2-3G
:
-1 DVD
-2 HTTP server
-3 FTP server
-4 NFS server
) (CD\DVD :
RHCSA/RHCE Egypt
139
DVD
-1 . curl
curl
-C
-O
``url
-2 :
tab .
RHCSA/RHCE Egypt
140
VNC
)(graphical mode
)(text mode
) (X SERVER .
boot.iso
)(text mode
)(graphical mode
) (video card
RHCSA/RHCE Egypt
141
VNC
next
"
"
)(Basic storage Devices
)(Specialized storage devices
5
iSCSI.
iSCSI
RHCSA/RHCE Egypt
142
) (upgrade an existing
).(Fresh installation
fresh installation ][next
) (host name.
configuration Network
)(NIC
. NIC IP
)(DHCP
IP
NIC )(wired
).(wireless
add
IP netmask
default gateway DNS
DHCP
.
. .
RHCSA/RHCE Egypt
143
NEXT NEXT
partition
PARTITIONING
RHCSA/RHCE Egypt
144
RHCSA/RHCE Egypt
145
RHCSA/RHCE Egypt
146
Network Installation
kdump
.
.
24
.
NETWORK INSTALLATION
boot.iso .
) (boot.iso
) (installer server FTP HTTP NFS
kickstart http .
:
-1 RHEL01 http :
#yum install -y httpd
-2 httpd:
-3 redhat http:
/var/www/ ) apache server (http server
client pub .
-4 /var/www/pub/:
-5 kickstart kickstart
):(/var/www/pub/kickstart/
.
RHCSA/RHCE Egypt
147
Network Installation
-6 kickstart /var/www/pub/kickstart:
selinux.firewall
-7 . iptables
.
port 80 http :
.
boot.iso Esc tab
:
RHCSA/RHCE Egypt
Network Installation
148
Enter -5
: Enter -6
-7
Installation Virtual Console Commands and Functions
Command
Console and Function
CTRL-ALT-F1 Text installation display; if you're running in graphical mode
CTRL-ALT-F2 Accesses a bash shell prompt.
CTRL-ALT-F3 Lists the log of installation messages
CTRL-ALT-F4 Displays all kernel messages, including detected hardware and drivers.
CTRL-ALT-F5 Installation displays partition formatting
CTRL-ALT-F6 Graphical installation display; active only if installation in graphical mode
Interactive shell
.( CTRL-ALT-F2)
/mnt/source /mnt/sysimage /proc
SCPSSH FTP ping ifconfig interactive shell
:
RHCSA/RHCE Egypt
149
kickstart
KICKSTART
RHCSA/RHCE Egypt
150
Automating KICKSTART
kickstart
ks boot Kickstart .
> ks=file:/<file
ks=file:/mydir/ks.cfg
> ks=hd:<device>:/<file
ks=hd:sda3:/mydir/ks.cfg
> ks=nfs:<server:>/<path
>ks=http:<server:>/<path
> ks=cdrom:/<path
ks for auto kfs from DHCP server
ks=http://rha-server/pub/ist191-ks/student-ks.cfg
AUTOMATING KICKSTART
-2 :
-5 :
-6 syslinux
:
.
RHCSA/RHCE Egypt
151
Automating KICKSTART
/tftpboot:
-7 default PXE :
# touch /tftpboot/pxelinux.cfg/default
:
tftp
PXE boot-2
) client ( .PXE boot
.
DHCP ip . .PXE
dhcp :
# yum install y dhcp
# rpm -qa | grep dhcp
dhcp-4.1.1-12.P1.el6.x86_64
RHCSA/RHCE Egypt
152
firewall:
bios
boot LAN PXE
HARDWARE AND DEVICE CONFIGURATION
.
:
.
:
.
.
https://hardware.redhat.com/
.
dmesg-1
) ) ( (add new device
).(boot
) (dynamic kernel buffer
.dmesg buffer /var/log/dmesg
dmesg " ".
.
dmesg dmesg
.
-2 hald lshal
)(hot attached device
USB
. ) (2.6 hald
)") ("Hardware Abstraction Layer Daemon (.
) (hald D-BUS system message bus .
6 D-Bus APIs
) (Hardware Abstraction Layer
hald lshal
.
RHCSA/RHCE Egypt
153
lshal m
USB .
-3 /proc
. ) (option parameter
) ( SysFsproc registry file
Solaris .ndd
) (proc ) (virtual file system
/proc .
proc
/proc/kcore RAM
512 512 .
/proc/cpuinfo
/proc/interrupts
/proc/ioports
/proc/iomem
RAID .
/proc/mdstat
/proc/meminfo
lsmod .
/proc/modules
).(memory fragmentation
)(boot time parameter
. swap partition
.
.
/proc/kcore
/proc/buddyinfo
/proc/cmdline
/proc/swaps
/proc/version
RHCSA/RHCE Egypt
154
File name
Content
. scsi
*/proc/scsi/
) arp a .( arp
/proc/net/arp
/proc/net/dev
).(snmp
/proc/net/snmp
/proc/net/sockstat
*/proc/sys/fs/
/proc/sys/net/core/
. 300
netdev_max_backlog
.0 ICMP
1 .
/proc/sys/net/ipv4/
_icmp_echo_ignore
all
.0 ICMP
broadcast address multicast address 1
.
/proc/sys/net/ipv4/
_icmp_echo_ignore
broadcasts
32768 .61000
/proc/sys/net/ipv4/
ip_local_port_range
0 off on
/proc/sys/net/ipv4/
.SYN flood attack
tcp_syn_cookies
/proc process id
)(PID .
. proc
. etc/rc.d/rc.local sysctl
sysctl.conf kernel
IDE
IDE bus IDE
master.slave
IDE primary.secondary
IDE primary master primary slave
.
RHCSA/RHCE Egypt
155
SCSI
sdx x .
.ISCI ID sda .sdb
sda
sdb label UID
/proc/scsi dmesg
SATA
scsi
.
.
USB . device driver
) (device driver .
)( .
) (device driver :
Static kernel image
Kernel module
The static kernel image
. /boot
vmlinuz version version .
IDE .
) (device driver
) (boot loader grub lilo .
/proc/cmdline
RHCSA/RHCE Egypt
156
modules r
) (modules /etc/modprobe.d/*.conf
) (modules .
""demand /etc/modprobe.d/*.conf .
sb kernel ) (device driver ) (
type=N N
. /etc/modprobe.d/custom.conf
.sb kernel
:
) (modules .
.
RHCSA/RHCE Egypt
157
/proc/sys/
/proc/
/proc/sys/ /proc/sys/
. /proc/sys/
sysctl
sysctl /proc/sys/ .
/proc/sys/fs/file-max sysctl fs.file-max
(PCI DEVICE) PCI
PCI bus . x86 PCI
PCI hardwired VendorDevice IDs
PCI ) (expansion cards
) (bridge ) (devices PCI.
lspci PCI v
RHCSA/RHCE Egypt
158
)(I/O ports
IRQ
.
x86 16 .I / O
I / O ) (device .
/proc/ioports .
.hexadecimal
RHCSA/RHCE Egypt
159
RHCSA/RHCE Egypt
160
Assigning Resources
. boot time Plug n' Play protocol
PCI .
lspci -v .
) (assigning devices
modprobe.d/*.conf .
/usr/share/doc/kernel-doc-kernel_ver/Documentation/
. kernel-doc package :
: .
" )?(How do processes communicate with device drivers
.
. ) (process ) (device driver )(file system type
.device node
device node process driver
.
:device node
character device node-2
block device node-1
device node /dev
device node .
device node
)( . device node
character device node ) ""( .
. ) (terminal ) (serial ports
.
RHCSA/RHCE Egypt
161
) (device driver :
) Major Number-1 ( .
/proc/devices
major number
block device character device pty
character device ) (major number 2 fd block device 2.
) Minor number-2 (
device node
floppy driver minor number 2
Primary IDE controller major number 3 minor number ) (partition
.
RHCSA/RHCE Egypt
162
) (device node .
) (device driver
device node .
device node
. ) (hot swappable devices
.
RHEL3 "pre-populating
device node /dev device node
RHEL4 2.6 .
) (notification device udevd
udevd
udevd
./etc/udev udevd device node
.node
udevd .device node
udevd hot swapped device
.
/dev device node device node
.
mknod device node ./dev
Node /dev udevd node
.
PERFORMANCE MONITORING
uptime
RHCSA/RHCE Egypt
163
load average
R D 15 15.
0.56 10.23 5
0.12 15.
- :top
top .
"q
top
.uptime
.
.
: (user) -us "" .
.
:(system) -sy "" )(services
) (
.
:(idle) -id runnable
(nice) -ni " "niced
(I/O wait) -wa I/O
I / O
(Hardware Interrupt) -hi ) (low level hardware
" "
.
(Software Interrupt) -si
.
(Stolen) -st
. ).(xen
RHCSA/RHCE Egypt
164
physical RAM
Swap
/proc/meminfo
) SysFs ( /sys/
proc
/dev driver udev ) (mange driver
dev/ )/sys/ (SysFs
SysFs
RHCSA/RHCE Egypt
165
Installation
Of Application
) (package manger .
) (software package repositories
) (package manger
) (dependencies
rpm dpkg
Kpackage rpm Gnome-apt dpkg
) (package
)}(Package_name)-(Version)-(release)-(architecture).(type of package {rpm or dpkg
postfix-2.6.6-2.el6.x86_64.rpm
Package_name
----
Version
Release
Arch
Noarch package
1386 32 bit and 64 bit
1586 Pentium I AMD
1686 Pentium I , II , III , IV AMD Duron , Athlon
X86_64 Intel core 46 bit AMD 64
Ppc 32 bit IBM
uname-a arch
cat /etc/redhat-release
lsb.release-a DebianUbuntu
(package manger
rpm&yum------------------------red hat based system as Fedora and RHEL
dpkg&apt ----------------------- Debian based system as Ubuntu,Kubuntu&debian
/ rpm
-1 )(source code installation
RPM-2
YUM-3
- 1 )(SOURCE CODE INSTALLATION
RHCSA/RHCE Egypt
166
rpm
-1 )(install update remove
-2 )(query
-3 )(verify
invocation
Use
.
rpm -e
rpm -q
)(Verify
rpm -V
rpm --checksig
-1 RPM
package rpm -i --install:
]#rpm-ihv[name-version-release-arch.rpm
RHCSA/RHCE Egypt
167
package rpm -F
--freshen:
]#rpm-Fhv[name-version-release-arch.rpm
RPM
#rpm-ihvhttp://------------------------------------
v verbose
h ) progress bar (
package rpm -e --erase:
]#rpm-e[Package_name
RPM
--replacepkgs
.
--prefixnew_directory .
RHCSA/RHCE Egypt
168
-2 rpm rpm q
) RPM (rpm query :
-c-d
RHCSA/RHCE Egypt
169
--last
--last RPM .
.
RHCSA/RHCE Egypt
170
-3 )(package verification
verification package
verification package
) (data base rpm package .
RPM :
every file which is associated with an installed package
the file's user and group owners
)( permission
file length
MD5 MD5 finger print
.
RHCSA/RHCE Egypt
171
-V .
RPM .
) (admin . pam
MD5 :
rpm .
.GPG
GPG
:
-1 www.redhat.com
-2 RPM-GPG-KEY-redhat-release
-3 /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
RPM rpm --import keyfile
RPM
.GPG-pubkey
RHCSA/RHCE Egypt
172
:
:
#rpm-Kpackage_name
#rpm--checksigpackagefilename
#rpmbuildpackage.src.rpm
srpm rpm
/usr/scr/redhat
Converting an RPM Package into a cpio Stream
) (formatting RPM cpio .tar tar
" cpio )"(stream ) (standard in
). (standard out
rpm cpio rpm2cpio :
: yum rhn_register
RPM :
-1 )(directory hierarchy
-2 .
-3 ).(spec file
-4 .RPM
RHCSA/RHCE Egypt
173
: make rpm-build
# yum install y rpm-build make
: first_file mysample -2
SOURCES -3
specs : spec -4
Summary: This package is a sample for the Red Hat exams.
Name: mysample
Version: 1.0
Release: 0
License: GPL
Packager: Jana Tester
Group: Development/Tools
Source: %{name}.tar.gz
BuildRoot: /usr/src/fedora/tmp/%{name}-%{version}
BuildRoot source
%description
This package is just a sample for the Red Hat exams.
%prep
%setup n mysample
BUILD SOURCE
%install
mkdir p $RPM_BUILD_ROOT/opt/sample_pkge
cp R * $RPM_BUILD_ROOT/opt/sample_pkge
%files
/opt/sample_pkge
%clean
rm rf $RPM_BUILD_ROOT
%post
chown user01:user01 R /opt/sample_pkge
chmod 775 R /opt/sample_pkge
SPEC
#vim /usr/src/fedora/SPECS/mysample.spec
: rpm-build rpm -5
# rpmbuild v bb /usr/src/redhat/SPECS/mysample.spec
RHCSA/RHCE Egypt
174
rpm rpm-i
binary ( (rpm package) ) rpm :
-1 binary
) dependency (
-2
-3 ~/rpmbuild/SOURCES/ ~/rpmbuild/SPECS/
.
) (source rpm :
-1 " ) "(pristine source .tar
-2 " ) " (patch files .
-3 ) " (spec files
) (patches )(compile RPM.
rpm
dependency yum
) (library file YUM .dependency +
yum (yum repository) yum .
RHCSA/RHCE Egypt
175
) (unique repository id
(baseurl) rpm
) (repo YUM .
.YUM
yum tetex-dvips dependency .tetex-fonts
yum.
yum ) (repository library
.
RHCSA/RHCE Egypt
176
yum
#yuminstallpackage_name
#yumupdate
#yumupdatepackage_name
#yumsearchpackage_name
#yumremovepackage_name
#yumerasepackage_name
#yuminfopackage_name
#yumlist
#yumresolvdepdep_name
dependency
update up2date
RHCSA/RHCE Egypt
177
yum
RHCSA/RHCE Egypt
178
yum update
update yum
" " . )(yum list update
tar .yum
system-config-packages
repo :
-1 createrepo
#yuminstallcreaterepo
-2 ftp
#rpm-ivhvsftpd.rpm
#servicevsftpdstart
-3 ftp
#cprpm/var/ftp/pubs
-4 repo
#mkdir/opt/yum/myrepos
#cd/opt/yum/myrepos
#cp~/nano-2.2.6-1.x86_64.rpm /opt/yum/myrepos
-5 repo
#createrepo/opt/yum/myrepos
or #createrepo/var/ftp/pubs
-6 /etc/yum.repos.d repo
#cd/etc/yum.repos.d
#nanomyrepo.repo
][base
name=My Custom Yum Repository
baseurl=ftp://rhel01/opt/yum/myrepos
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
repo package
ftp repo
baseurl=ftp://rhel01/opt/yum/myrepos
repo
][iso-repo
Baseurl=file:///mnt/cd
enabled=1
.
RHCSA/RHCE Egypt
179
rpm dpkg -1
#dpkgoptionactionpackage_name
action
-i
--configure
-r
-P
-p
-I
-l
yum aptitude -2
#aptitudesearchpackage_name
#aptitudeinstallpackage_name
#aptitudefull-upgrade
#aptitudesafe-upgrade
#aptitudedist-upgrade
#aptituderemovepackage_name
#aptitudepurgepackage_name
apt-get -3
#apt-getinstallpackage_name
(update[ ] upgrade[ ] remove [Package_name] check[) ]
#apt-cachesearch[package_name]
#apt-cdrom[package_name]
RHCSA/RHCE Egypt
180
BOOT UP
SEQUENCES
system
ready
system
V init
kernel
Boot
loader
Bios
RHCSA/RHCE Egypt
181
GRUB
GRUB
Grub
grub lilo
grub minimal shell shell .bash
)(Fedora, red hat enterprise linux, open SUSE, Ubuntu, Mandrake and other
file sys ext3,2fat
)(multi boot specification
Grub /etc/grub.conf ----- shortcut
/boot/grub/grub.conf-------
MBR Grub - :
-a ) (stage_1 MBR
) stage_2 (stage_1_5
-b ] [actual image stage_2 optional image stage_1_5
stage_1_5 stage_1 stage_2 x_stage1_5 x
) (File system type ] [ext4, ext3, and other stage_2.
fat fat_stage_1_5
file system
stage_2
(GRUB CONFIGURATION) GRUB
/boot/grub/grub.conf .
grub GRUB grub :
.
RHCSA/RHCE Egypt
182
GRUB
grub ) (floppy disk CDROMhard disk
0 grub IDE SCSI ) (hd 0,0 kernel
-1 : primary master IDE hd0
" " BIOS Drive #1 . GRUB HD0 /dev/hda
-2 :partition
partnum 1 .GRUB 0
dev/hda1
-3 df
RHCSA/RHCE Egypt
183
GRUB
grub
grub
Splashimage
os
gimp
xpm
GRUB
5
GRUB :
Secure mode :
grub.conf
grub.conf
.
RHCSA/RHCE Egypt
184
GRUB
basic mode :
grub .
:
Grub Boot Options:
e Edit the commands before booting
a Modify or append the kernel arguments before booting
c Open the GRUB command line
Edit mode :
. grub
grub.conf .
.
(grub.conf) stanza b
Esc basic mode
) (boot only
grub .
:Append mode
run level run level .quit
) (edit & append mode :
Single-User Mode
)Used to perform maintenance tasks or if you forget the root password (1 or s
Runlevel 2 or 3
Used to load only partial services during the boot process
)(2 or 3
Emergency Mode
Used to perform tasks on an unbootable system
)(emergency
Rescue Mode
Used to fix boot issues or reinstall GRUB
)(need boot-cd
Command mode :
grub.conf grub
initrd . Esc
.
boot loader NTLDR BOOT.ini
(GRUB INSTALL) GRUB
boot loader
boot loader
. MBR
. grub stage_1 bootloader MBR
GRUB
grub-installgrubs native command line
RHCSA/RHCE Egypt
185
GRUB
-2
-4 No
-6 /mnt/sysimge
-1
-3 rescue cd/dvd
-5 continue
/ CD-ROM
/mnt/sysimge
/ /mnt/sysimge
chroot /mnt/sysimge
/ exit
stage1 MBR
grub-install /dev/sda
RHCSA/RHCE Egypt
186
GRUB
stage_1
stage1
grub boot loader MBR
.quit
/ DVD reboot
c grub shell
: root OS run level 1 grub
Kernel e quiet 1 s S OS run level 1
) (#passwd exit root.
grub
.
.
.grub.conf ) (not plaintext password
root password
terminal
#grub-md5-crypt
md5
grub.conf /boot/grub/grub.conf
.
RHCSA/RHCE Egypt
187
INIT PROCESS
lock
KERNEL
- :
-a )) initrd (initial RAM drive) (initramfs Grub
RAM kernel
kernel device modules kernel device
.drivers
) kernel kernel) modules(initrd kernel
modules kernel
kernel
modules on or off
-b kernel
Mount to (root file sys (/)) -c
Remount (root file sys (/)) -d read &write
)(dmesg |less
-e )initial process (init
grub
INIT PROCESS
INIT PROCESS
upstart
1) /etc/rc.d/rc.sysinit then run upstart
2) /etc/rc.d/rc?.d/
3) /etc/rc.d/rc.local
4) X display manger #startx
open GUI in run level 3
process init
/etc/inittab process
run level /etc/inittab initdefault :5
/etc/inittab ./etc/init
) init(upstart ./etc/sysconfig/init
RHCSA/RHCE Egypt
188
INIT PROCESS
)init(upstart
/sbin/init
process ID .1 init .
process Id 1 .(signal 9) SIGKILL
init
. /etc/inittab system
V 6 upstart
.
upstart /etc/inittab
/etc/init/ (system v) V . inittab
init boot non-kernel process
initupstart ) (jobs ) (boot
run level ) (jobs ./etc/init/
) init(upstart .
UPSTART .
/etc/init ) (event /etc/event.d
.SYS V init RHEL6 UPSTART )
syslog ( )(events
.system script
upstart
RHCSA/RHCE Egypt
189
INIT PROCESS
3 5 /etc/init/prefdm.conf 5
/etc/X11/prefdm X server
getty virtual console 2
. .
init ) init (system V
/etc/inittab ) init(upstart /etc/inittab
/etc/init
/etc/sysconfig/init /etc/event.d
initctl
initctl
) init (upstart
upstart service :
>#initctl[start stop restart reload status list] <job_name
inittab
) (run level 5
.
RHCSA/RHCE Egypt
190
INIT PROCESS
run level
runlevel
- halt
- Single User Mode
- Multi-user Mode without NFS
- Multi-user Mode
- unused
- Multi-user with X
- reboot
run level runlevel who-r
0
1
2
3
4
5
6
N
init
init Unix init telinit
init telinit
init 0 )(shutdown
shutdown :
-1 at crontab
-2 ) (broadcast .
shutdown hprc 1
:
) (root user .
hprc :shutdown
shutdown
RHCSA/RHCE Egypt
191
INIT PROCESS
shutdown
-k
-F
FSCK
-n
-t SECS
halt shutdown now poweroff
reboot
/etc/init/rcS.conf
/etc/init ) init(upstart
boot :
-1 ) /etc/rc.d/rc.sysinit (script
system initialization .
-2 /etc/inittab ) . (run level
runlevel . rcS.conf .boot
run level ./etc/inittab
-3 ) (runlevel /etc/rc.d/rc?.d
.
/etc/init/rcS.conf
) (script .
/etc/rc.d/rc.sysinit
rc.sysinit
) (root file system ) (mount .
-1 /etc/sysconfig/network ).(set hostname
-2 ) (mount /proc
-3 selinux (activate udev and selinux) a relabeling of the system
-4 /etc/redhat-release .
-5 RAID array
LVM (encrypted partition .
-6 rc.sysinit fsck -T -t noopts=_netdev -A $fsckoptions
fsck -A ) (file system .
) (root file system fsck
. fsck
) (read only) (root file system
/etc/fstab ).(rescue shell
-7 ) (root file system
#mount-oremount,rw/
#mount-a-tnonfs,nfs4,smbfs,ncpfs,cifs,gfs O\no_netdev
)(mount other local file system
fstab
-8
o Sets kernel parameters in /etc/sysctl.conf
o Sets the system clock
o Loads keymaps
o Enables swap partitions
o Enable disk quotas
init init
init q
.
RHCSA/RHCE Egypt
192
rcS.conf rc.sysinit
/etc/rc.d/ /etc/init/rc.conf
/etc/rc.d/ ) (runlevel :
symbolic
etc/rc.d/init.d/
/etc/rc.d/init.d/
/etc/rc.d/init.d
. ) (scripts ) (run level .
RHCSA/RHCE Egypt
193
) (services stop
)(services
)(scripts /etc/rc.d/init.d
)(service
service
/etc/rc.d/init.d/service_name command
) (daemon
daemon ) (scripts
./etc/rc.d/init.d/
daemon daemon .
service httpd start
service sshd status
command
/etc/rc.d/rc
runlevel runlevel
.
.
RHCSA/RHCE Egypt
194
/etc/rc.d/rc?.d
) (directory runlevel . service ? runlevel
) (soft link service /etc/rc.d/init.d
L S runlevel K
runlevel dd service_name
rc K .S
init runlevel rc
-1 first booting rc ) (run level .
" ("kill") "K rc .
) (service script .
-2 rc ) (run level . ""S
)" ("start rc .
) (service script .
chkconfig .
:
]--list[name
>--add<service_name
>--del<service_name
>--level<run_levels
><service_name><on|off|reset
--list )(run level
--list
RHCSA/RHCE Egypt
195
/etc/rc.d/rc.local
) (boot up .rc.local
) (script .
). (Script rc.local
.
S99local
-1 /etc/rc.d/rc.local
-2 etc/rc.d/init.d/
rc.local init.d
service runlevel
#chkconfig --level2 servicename on
#chkconfig --level2 servicename off
Xserve
service
service
.
RHCSA/RHCE Egypt
196
ntsysv
#ntsysv --level 35
3 5
chkconfig .
RHCSA/RHCE Egypt
197
.
. name=value
) . (Env variable ).(first process
.
) (two .
-1 ):(run level 1
) (init 1 ""1 . " "1
.init
init "1 1
.
-2 (bypass init process) init
fstab /etc/inittab
etc/rc.d/rc.sysinit 1 . init
.
/sbin/init ) (interactive shell
init .
.
RHCSA/RHCE Egypt
198
)(kernel
init=/bin/sh init=/bin/bash .
init=boot_prameter = init
) (/
exit
) (
) (interactive shell PID PID=1 .
exit:
init
)( KERNEL
)/( :
.
kernel
open source code
kernel
BSD
) (Hardware
.
.
) ( :
.1
.2
.3
.4
.5
. :
: management
:
) :(I/O ) (terminal .
: .
: .
RHCSA/RHCE Egypt
199
)(kernel
" "
" "
""patch
.
: ""
2.6
production
) Experimental
1.3 2.1 (2.5
) 1.2 2.0 2.2 2.4(
.
.
) ( .
.
: X.Y.Z X Y
: Y
Z
http://www.kernel.org
:
): (monolithic kernel .
-1
-2 / )(modules
RHCSA/RHCE Egypt
200
)(KERNEL
-4 :
. .
-1 ) (monolithic kernel
:
:
-2 Microkernels
-3 Hybrid (or) Modular kernels
XP ) (Mac OS
) (Microkernels
-4 nanokernelsexokernels
)(KERNEL
-1
-2
-3 ALSA 2.6
OSS ntfs
-4 SM56
2.4.5
-5
modules
-6
kernel
SCSI
: Stable .
:
-1 yum update
rpm rpm i
.www.kernel.org
rpm:
rpm U i
.
-2 src.rpm rpmbuild:
-1 ftp://distro.ibiblio.org
ftp://ftp.redhat.com
kernel-2.6.38.6-26.rc1.fc15.src.rpm
rpm rpm
. (BUILD,SOURCE,RPMS,SRPMS,SPECS,tmp) rpm
.
RHCSA/RHCE Egypt
201
)(KERNEL
-2 rpm mockbuild
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
mockbuild system
#useradd s /sbin/nologin mockbuild
or #useradd r mockbuild
src.rpm rpmbuild ${HOME}/
. /{HOME}/rpmbuild/SOURCE$
linux-3.6.38tar.xz patch-3.6.38.xz
-3 SPECS SPECS rpmbuild:
.rpm
-4 ${HOME}/rpmbuild/RPMS/i686/
kernel-3.6.10-4.fcl8.root.i686.rpm
kernel-smp-3.6.10-4.fcl8.root.i686.rpm
kernel-debuginfo-3.6.10-4.fcl8.root.i686.rpm
: debug
-3
configurationcompiling
Config . (.
:
y (no & yes) n
:make config
.
:make oldconfig ) .config (
make config
:make menuconfig
) n y - ?- m (loadable module
:make xconfig . x window tcl/tk .
RHCSA/RHCE Egypt
202
)(KERNEL
.
. make config make menuconfig
:make gconfig make xconfig GTK :make defconfig -
kernel kernel
#makeclean
-1 Pentium I Pentium IV
-2 SMP !!
-3 modules
kernel module loader loadable module support
.
-4 ext2 ext3 vfat msdos minix Reiserfs
ntfs hpfs jfs xfs
: menuconfig export TERM=linux export TERM=ansi
make xconfig
.4 ) :(compiling make 2.6
make bzImage make modules make
#make
.bz
.
-5 : :
#makemodules
#makemodules_install
#makeinstall
make /boot/
GRUB modules /lib/modules make install modules
make modules_install /boot/ .
:make install
cp arch/i386/boot/bzImage /boot/
cp system.map /boot/
RHCSA/RHCE Egypt
203
/boot/ /boot/
bzImage
vmlinuz . .
. system.map
.
/boot/
initrd / . Install
) mkinitrd 2.6.12( mkinitramfs
-4 new-kernel-package initrd
grub .
]new-kernel-package [-v] [--mkinitrd] [--rminitrd] [--dracut] [--initrdfile=initrd-image [--depmod
][--rmmoddep] [--kernel-args=args] [--remove-args=args] [--banner=banner] [--multiboot=multiboot
][--mbargs=mbargs] [--make-default] [--add-dracut-args] [--add-plymouth-initrd] [--host-only
><--install | --remove | --update | --rpmposttrans> <kernel-version
PATCHING THE KERNEL
ASCII
) :(patch
. ) (man patch
)(
. ) (
. .
.
patch hotfix patch kernel hotfix
-1 patch
)(patch . ) (http://www.kernel.org
)(patches .
http://www.linuxhq.com
""
) ( ) (NVIDIA
-2 patch bz2
)bzip2 bunzip2 gzip (.gz
patchxxxx-2.6.21-pversion.bz2
:
xxxx
2.6.21 )(patch
pversion
readme
) (
:
-3 kernel
( cd /usr/src/linux
/usr/src/linux2.6.21
)
bunzip2 patch-xxxxx-2.6.21-version.bz2
-4 patch p1
patch -p1 < patch-xxxxx-2.6.21-version or patch d patch_name -p1
.
RHCSA/RHCE Egypt
204
: patch patch p1 -R
)(MODULES
kernel
-1 vmlinuz----- core
-2 initrd----- modules /lib/modules
)( )
1.2
( . )) ((driver
modules ) (driver
) kmod
2.0 (kerneld modprobe
.
/etc/modules.conf
lib/modules/version_kernel/modules.dep/ .
( insmod
) /lib/modules/version_kernel
#uname-r
: Modules ) (Modules ) (Driver
.
modutils module-init-tools 2.6
:lsmod.1 ) (/proc/modules
.
#lsmodusb_storage
lsmod
:modprobe.2 r
#modprobe-rusb_storage
:insmod.3
:depmod.4 .
:rmmod.5 .
.6 : modinfo
ksyms 2.4 ) (/proc/ksyms
insmod .
DMA .IRQ:
#insmodsoundxio=0x320irq=5
: KERNEL
1- kernel-PAE (SMP) support
x86 ------up to 32 processes & 16G RAM
2- Kernel
support x86 ------up to 32 processes & 4G RAM
x64 ------up to 64 processes &512G RAM
3-kernel-xen
support
)x86 ------up to 32 processes & 16G RAM (Dom0 limits
)x64 ------up to 126 processes&512G RAM (Dom0 limits
#modprobeusb_storage
RHCSA/RHCE Egypt
205
11
System
Admin Tolls
. CUPS
LPRng CUPS / .
) CUPS (LPRng
lpr
BSD System V
:
:BSD LPD
:LPRng
) .(LPRng
/ :
) : (filtering system .
: / CUPS
) Epson(HP Gimp
; Foomatic Ghostscript.
RHCSA/RHCE Egypt
206
:lpq .
15 lprm -P Epson 15
cups
BSD LPD
) IPP (http CUPS CUPS
.
PPD
RHCSA/RHCE Egypt
207
system-config-printer
)(lpr, lprm, lpstat, lpadmin and other
http TCP 631 http://localhost:631
RHCSA/RHCE Egypt
208
.( appropriate filter) -3
.system-config-printer
Figure 1 the system-config-printer
Figure 2 selecting a Queue type
RHCSA/RHCE Egypt
209
RHCSA/RHCE Egypt
210
Figure 1.14. Naming The New Remote Printer with system-config-printer Application
system-config-printer ) (cups printing queue
:
SERVER SETTING
RHCSA/RHCE Egypt
211
RHCSA/RHCE Egypt
212
RHCSA/RHCE Egypt
213
System Logging
lpadmin cupsenablecupsdisable
lpadmin
.
cupsenable cupsdisable .
system-config-printer cups
System-config-printer
:
.
) (network sharing )(browsing.
:
.
.
cups
:
) .(links
.
:
.
.
:
automate
.
.
.
:
.
.
SYSTEM LOGGING
:rsyslog
rsyslog ) (log message .
rsyslog) facility( ) priority( .
facility
RHCSA/RHCE Egypt
214
System Logging
priority
RHCSA/RHCE Egypt
215
System Logging
rsyslogd daemon
:
-1
-2
-3 ) (application or facility .
-4 process ID .
-5
RHCSA/RHCE Egypt
216
System Logging
logger
logger log server .
(debugging the rsyslog service) rsyslog .
logger .
RHCSA/RHCE Egypt
217
System Logging
logger
logger /var/log/messages
logrotate secure
. crontab
/etc/cron.daily/
logrotate /etc/logrotate.conf
/etc/logrotate.d/ logrotate
RHCSA/RHCE Egypt
218
logrotate 4
- : /etc/motd
x windows /etc/x11/xorg.conf
) (system login )(lastlog faillog
lastlog
Lists login records
faillog
Lists failed login attempts
lastlog:
-b DAYS
Displays results older than DAYS
-u LOGIN
Displays results for the user LOGIN
faillog:
-a
Displays all events
-l SEC
Locks the account for SEC seconds after a failed login
-u LOGIN
Prints records for user LOGIN
RHCSA/RHCE Egypt
219
encryptionhashing
encryption password key data unreadable form decryption key data data ).(readable
hashing (readable form) data ) (unreadable form key salt .one way salt
hashing
#passwdredhat
redhat salt (MD5 hash) hash rehashing .
- : encryption
((DIRECTORY ENCRYPTION) ) ENCFS
-3 encrypted encfs
1 AES Blowfish
RHCSA/RHCE Egypt
220
) (key volume
) (Block Null stream = block
.
-3 ) source directory (/encrypted
) mount directory (/decrypted mount directory
mount umount
.
.
RHCSA/RHCE Egypt
221
partition)(file encrypted
-1 1 :
-2 partition losetup e :
losetup ) cipher (
aes :
-1 yum install util-linux util-linux
-2 ) (cryptoloop_modules aes_modules
partition :
-3
-4 :
umount
5 .
fstab :
/secret.img
/mnt.encrypted
ext4 defaults,noauto,loop,encryption=aes,user 0
0
(DISK AND FILE ENCRYPTION) LUKS
RHCSA/RHCE Egypt
222
-3 partition :
RHCSA/RHCE Egypt
223
encrypted
partition luks-data /dev/mapper/luks-data/
-4 ex4 :
-5 luksClose cryptsetup:
UUID:
rc.sysinit:
[root@www ~]#vim /etc/rc.d/rc.sysinit
fstab .auto mount fstab
encryption .crypttab fstab /etc/crypttab
.encrypted file system
.
RHCSA/RHCE Egypt
224
CHECKSUM
). (MD5, Sharp
hi
checksum
test checksum
- : checksum checksum
.
checksum
)md5sum (128 bit ))sha (sha1sum (160 bit) , sha256sum (256 bit) , sha512sum (512 bit
checksum redhat checksum
checksum checksum
torrent peer to peer
.
ATTRIBUTES ACL
chattr chattr
" "root DOS attrib
) (:
: A "Access time" .
: a , ).(append
: c "(compression) "kernel
: D , .
: d (no dump) dump
: i ).(immutable
: s ). (secure deletion
.
RHCSA/RHCE Egypt
225
: S D , .
: u , ). (undeletable
: j journaling
h (hidden) - T (top of directory hierarchy) - t ( no-tail merging) - e (extend attribute) :
chattr:
i .
) (attribute
.(mount option) user_xattr
UUID=661ab9f1-c381-4962-bcfc-0b5e2aab1ce9 /home
ext4 defaults,user_xattr,acl
12
setfattr setfattr ) (set extended attribute to filesystem
extend attribute name
:
-nname = --name=name
attribute
-vvalue = --value=value
attribute
-xname = --remove=name
attribute
Extend attribute name
) (metadata )
( . ) (extend attribute
. attribute .chattr
).(character encoding of a plain-text, a checksum, cryptographic hash or digital signature
ext2 ext3 ext4 JFS XFS Reiserfs .Btrfs ) extend attribute (.
) (extend attribute ).(metadata
- : ) .(name. :
)(user trusted - security system
user.mime_type - trusted.md5sum - system.posix_acl_access - security.selinux
. ) (extend attribute
user space program
extend attribute 2.6 BeagleDropbox
Beagle is a search system for Linux and other Unix-like systems
Dropbox is a file hosting service operated by Dropbox
security attribute security kernel modules .selinux
security_attribute security security module
security_modules
) CAP_SYS_ADMIN (.
system attribute kernel system object ACL .CAPILITES
system_attribute system_attribute .
.
RHCSA/RHCE Egypt
226
RHCSA/RHCE Egypt
227
NETWORK MANGER
NETWORK
NETWORK MANGER
- : IP dynamic ) static (
) IP (submask .
6 )(Network manger
) (wirless . .
.
:
-1 )- :(connect automatically .
-2 )- :(Available to all users
. .ifcfg
) (network manger
.
.
RHCSA/RHCE Egypt
228
NETWORK MANGER
) (bonding ) (adaptor
load_balance ). (network manger
ip forwarding ) (network manger
. router
. chkconfig
.
.
IP addressing. netmask
. default gateway
. DNS
.
Ifconfig .ip addr
. route
. System-config-network-tui
.
./etc/sysconfig/networks
. /etc/sysconfig /network-script/ifcfg-ethX
./etc/hosts
. /etc/resolv.conf
)(NIC
) (Network Interface Card) (NIC . PCI
. lspci
NIC
) (device node /dev/ NIC
NIC ). (network interface
NIC ) (network interface eth0 tr1
) (type of underlying data link technology
.
wlan0 . wifi
ip addr RHEL6 ) ifconfig ( .
.
RHCSA/RHCE Egypt
229
: ip
#ip[options]object{command | help}
Object: = {link | addr | addrlabel | route | rule | neigh | tunnel | maddr | mroute | monitor}
Options: = {-V[ersion] | -s [tatistics] | -r [esolve] | -f [amily] {inet | inet6 | ipx | dnet | link} | -o [neline]}
ip addr add -1
#ipaddraddlocaladdressdevdev_name
RHCSA/RHCE Egypt
230
ip link set:
ip.
ifcfg-ethX
Variable
Ex.
Description
eth0
DEVICE
MAC
MAC address
HWADDR
IP
192.168.16.1
IPADDR
none|static|dhcp
BOOTPROTO
netmask
255.255.255.0
NETMASK
yes no
.
yes | no
ONBOOT
no
yes .
Yes | no
USERCTL
192.168.0.254
GATEWAY
gateway.
.
RHCSA/RHCE Egypt
231
Description
NIC yes = NetworkManager no=network
TYPE=Ethernet
Ex.
Variable
NM_CONTROLLED Yes | no
Etherent|Wirles
TYPE
System eth0
NAME
IP aliases
IP IP aliasing
255 ) (additional aliases
: (eth0:1 eth0:191) : label ip addr add:
ifcfg-ethX
RHCSA/RHCE Egypt
232
IP
Virtual LAN
VLAN
Virtual LAN ) ( .
eth0 eth0:2 eth0.2
eth0 /
eth0:2 Alias IP
Subnet .
eth0.2 VLAN LANs
Switch Sub Interface
VLAN
.1 : ifcfg-eth0.2
DEVICE=eth0.2
VLAN=yes
.2 : vconfig
VLAN vconfig add
VLAN /proc
VLAN
VLAN vconfig
IP
IP ) .(router IP
) (network part ) . (host part IP
) (netmask .
IP .
)(netmask ) (network part .IP IP
. ). (CLASS A CLASS B CLASS C
.IP
4 IPv4 IP 20 . " " IP
IPv4 .
6 IPv6 inet6.
IPv6
.
RHCSA/RHCE Egypt
233
IP
IPv6 128 ) (,
) hexadecimal 0000 .(FFFF
) (netmask . prefix
prefix / 64 .
/ 48 65535 .
IPv6 :
:0db8: :db8: :0000: :0:
::
2001:db8:0:0:0:0:0:1 - : 2001:db8::1 0:0:0:0:0:0:0:1 ::1
IPv6 broadcast address multicast address
.
unicase (::1): IPv6 127.0.0.1 IPv4
MAC address
IP address MAC address
RHCSA/RHCE Egypt
234
192.168.16.0/255.255.255.0
eth0 hosts
gateway
)(internet
) (route table gateway IP
n :route
gateway ifcfg-eth0 :
GATEWAY=192.168.16.1
# routeadddefaultgw192.168.1.1 eth0
(Domain Name Service) DNS
.DNS
DNS IP .
resolv library
ip resolv library /etc/hosts )(static lookup
/etc/resolv.conf )(dynamic lookup
.
RHCSA/RHCE Egypt
235
nameserver
nameserver IP DNS .
nameserver primary nameserver
. secondary nameserver DNS primary name server
secondary nameserver.
search
(FQDN) Fully Qualified Domain Name
station5.example.com
Domain
. station5 Domain /etc/resolv.conf
. search
nameserver Domain
server1 server.isp.net : .server1.example.com :
domain
search domain search
domain
Proxy server
) (station ). (proxy server
FTP IP .
DNS .
DNS /etc/resolv.conf
)(hostname
hostname
.
hostname .
hostname
.
.
RHCSA/RHCE Egypt
236
/etc/sysconfig/network
) (hostname
/etc/sysconfig/network .
network
Description
Ex.
Variable
Yes no
yes | no
NETWORKING
No ip 6 yes
yes | no
NETWORKING_IPV6
localhost.localhost
Jana.teba
HOSTNAME
NIS
RHA130
NISDOMAIN
192.168.0.254
gateway
ip dhcp eth1
gateway
eth1
GATEWAY
GATEWAYDEV
:
=ifdown
=ifup
#servicenetworkstop
#servicenetworkstart
#servicenetworkrestart
ip forwarding /etc/sysctl.conf
) ( ) (network interface ip .
) (gateway .
.
ip
IP .IP forwarding
IP forwarding .
.
/etc/sysctl.conf
net.ipv4.ip_forward = 1
0 sysctl p
RHCSA/RHCE Egypt
237
DHCP
)(IP GATEWAY NETMASK DNS
DHCP dhclient daemon dhcp
dhclient daemon :
/var/lib/dhclient/dhclient-name.leases
)name = eth0 (example
system-config-network-tui
.
.
RHCSA/RHCE Egypt
238
ok
network ifdown ifup
dhclient dhcp
RHCSA/RHCE Egypt
239
ping
ping 2 IP
ping ) ICMP (echo request ICMP
) (echo replay .
CTRL + C:
ping
host
DNS lookup ip
traceroute
.
RHCSA/RHCE Egypt
240
tcpdump
CTRL + C
WIRESHARK
wireshark
:
yum clean all
yum install wireshark wireshark-gnome
wireshark
RHCSA/RHCE Egypt
241
netstat
" "netstat
.
t tcp u udp n ip a
r routing table p process id e
:
:Proto )(UDP ,TCP
:Local Address )( , ". ":
:Foreign Address , ".":
:State " ,ESTABLISED " "TCP "."UDP
netstat-ntap
netstat:
" "listen:
" "listen :
netstat-ntlp
RHCSA/RHCE Egypt
242
Etherent Bonding
nslookup
:
dig nslookup
ethtool
mii-tool
ETHERENT BONDING
-3 : :
)DEVICE=eth1 (eth1 and eth2
BOOTPROTO=none
.
RHCSA/RHCE Egypt
243
ONBOOT=yes
MASTER=bond0
SALVE=yes
USERCTL=no
#ifconfig bond0 up
:
)NFS (THE NETWORK FILESYSTEM
)(NFS ) (directory.
.NFS NFS
.NFS
server1 /var/ftp/pub .readme
NFS
NFS (NFS server) NFS ). (NFS client
station7 (SERVER1) NFS /mnt/pub.
NFS mount
mount ) remote hostname-1 NFS
directory-2 NFS
Remote Hostname: Directory
.
NFS protocol CIFS protocol NFS CIFS
rpcbindnfslock
nfs
t .mount
umount:
.
RHCSA/RHCE Egypt
244
mount NFS .
fstab
) (admin .
noauto fstab :
noauto mount user
.
RHCSA/RHCE Egypt
245
#smbclient-Lcifsserver.domain
#mkdir/remote2
#mount //cifsserver.domain/sharename/remote2
NFS
NFS mount .hard mount ) (NFS mount NFS
.uninterruptible sleep D
) (uninterruptible sleep uninterruptible kill
CTRL + C .
intr:
interruptible sleep S D
NFS soft mount:
ls 30 .
/etc/auto.net automounter NFS
/net/hostname/exported/path
/var/ftp/pub /rha/data NFS
/net.
automounter NFS .
IP /net DNS etc/hosts/
.net/
access file remotely
RHCSA/RHCE Egypt
246
www.ntp.org add
. speed up initial synchronization advanced options
:
#ntpq -p
RHCSA/RHCE Egypt
Selinux
247
SELINUX
sestatus selinux
: selinux
sestatus
getenforce
setenforce
getsebool
setsebool
chcon
restorecon
RHCSA/RHCE Egypt
exams
248
EXAMS
Every questions in this is mandatory for you to complete.example.com and remote.test has 192.168.0.0
and 192.168.1.0 network respectively.
You have one system with one virtual system in build
Packet filtering should not affect the network integrity.
Yum baseurl is baseurl=ftp://192.168.0.254/pub/rhel6/dvd.
Exam time: 2 1/2 hrs.
Questions 1 | CREATE LVM
Create the "LVM" with the name volgrp by using with the extends of 10 from the volume group named as
logical. Consider the PE size as "16MB". Mount it on /lvm1 with filesystem vfat.
Questions 2 | USER'S GROUPS AND PERMISSION:
Create a group named "manager"
A user sarah and natasha should belongs to "manager" group as a secondary group . A user harry should not
have access to interactive shell and he should be a member of "manager" group as secondary. passwd for all
user created should be "jenny".
Questions 3 | DIRECTORY COLLABORATION:
Create the Directory "/home/manager" with the following characteristics. Group ownership of
"/home/manager" should go to "manager" group. The directory should be have full permission for all
members off "manager" group but other users don't have any permissions accept "root". Files created under
"/home/manager" should get the same group ownership is set to the "manager" group.
Questions 4 | UPDATE THE KERNEL:
Install the appropriate Kernel from ftp://instructor.example.com/ftp/pub/updates. Your machine should boot
with updated kernel.
Questions 5 | CRON JOB:
The user sarah must configure a cron job that runs today at 23:14. and executes "/bin/echo "linux Is
freedoM" and deny the user max for creating cronjob .
Questions 6 | RESIZE LVM:
Resize the lvm "/dev/vgsrv/home" so that after reboot size should be in between 90MB to 120MB..
Questions 7 | BIND THE "LDAP" FOR USER AUTHENTICATION:
Note the following. BASE DN: dc=example,dc=com ldap path ldap://instructor.example.com/ Download the
certificate from "ftp://instructor.example.com/pub/EXAMPLE-CA-CERT" ldapuserX should login into your
system . Where "X" is your system no.
Questions 8 | "NTP" CLIENT:
Configure your system as "NTP" client for "instructor.example.com".
Questions 9 | AUTOMOUNT THE HOME DIRECTORY FOR LDAPUSER
Note the following. instructor.example.com(192.168.0.254) "Nfs exports" /home/guests to your system
where "x" is your station ip. Ldapuser's home directory is instructor.example.com:/home/guests/ldapuserX.
Ldapuser's home directory should be automounted locally beneath at /home/guests/ldapuserX. While login
with any of the ldapuser then only home directory should accesible from your system that ldapuserX.
Questions 10 | ACCESS CONTROL LIST:
Copy the file /etc/fstab to /var/ and configure the "ACL" as mention following. The file /var/fstab is owned
by the "root". The file /var/fstab belongs to the group "root" The file /var/fstab should not be executable by
other's. The user "sarah" should able to read and write to the file. The user "natasha" can neither read nor
write to the file. other users (future and current) shuold be able to read /var/fstab.
Questions 11 | CONFIGURE FTP SERVER:
Configure FTP access from your system. Clients within the example.com should have anonomyous FTP
access to your system.
Questions 12 | CONFIGURE "web server":
Configure your system as "web server" for the site http://serverX.example.com . Download the web page
from ftp://instructor.example.com/pub/updates/station.html Rename the the downloaded page as
"index.html" Copy the "index.html" page to the "document root" Do not make any modifications to the
content of index.html.
Questions 13 | ADD USERS:
Create the user "john" with uid 4223 with password john.
RHCSA/RHCE Egypt
SOLUTION
249
Solution 1partprobe
fdisk -l
pvcreate /dev/sdb
vgcreate -s 16M logical /dev/sdb
lvcreate -n volgrp -l 10
mkfs.vfat /dev/logical/volgrp
mount /dev/logical/volgrp /lvm1
Solution 2groupadd manager
useradd sarah -p -G manager
useradd natasha -p -G manager
useradd harry -p -G manager -s /sbin/nologin
Solution 3ckdir -p /home/manager
chown root:manager /home/manager
chmod 770 /home/manager
chmod g+s /home/manager
Solution 4Wget ftp://instructor.example.com/ftp/pub/updates/kernel.rpm
Rpm -ivh kernel.rpm
Solution 5Crontab -e
14 23 * * /bin/echo "linux is freedoM"
echo "max" > /etc/cron.deny
Solution 6 partprobe
lvs
umount /dev/vgsrv/home
e2fsck -f /dev/vgsrv/home
----to reduce
resize2fs /dev/vgsrv/home 100m
lvreduce -l 100m /dev/vgsrv/home
----to increase
lvextend -l +100m /dev/vgsrv/home
resize2fs /dev/vgsrv/home
Solution 7system-config-authentication
To ensure getent passwd username_name(ex ldapuser1)
Solution 8system-configure-date
RHCSA/RHCE Egypt
SOLUTION
250
RHCSA/RHCE Egypt