Sunteți pe pagina 1din 63

-

Pra c t i ce: B a c k i n g U p a n d Resto r i n g F i l es From a tar A rc h i ve


-

Pra ct i ce: B a c k i n g U p a n d Resto r i n g F i l es Fro m


-

a ta r A rc h ive
-

Guided exercise
-
I n t h i s l a b, students w i l l c reate a n d extract a r c h i ves w i t h t a r .

Outcomes:
-
Students w i l l b a c k u p a d i rectory t ree a n d extract t h e a rc h ive content to another l ocation.

D 1. S i nce o n l y t h e root user ca n read a l l t h e contents o f t h e / e t c d i recto ry, we a re g o i n g to


-
b a c k u p t h e d i rectory and l o g i nto s e rverX as root.

-
� [student@desktopX -]$ s s h root@se rverX

D 2. C reate a n a rc h ive o f / e t c u s i n g g z i p com press i o n to back u p t h e confi g u ra t i o n f i l e


- d i rectory / e t c . Save t h e f i l e a s / t mp/e t c . t a r . gz.

I [ root@serverX -]# tar czf /tmp/etc . t a r . gz /etc


- i

D 3. Verify that the backup f i l e e t c . t a r . g z i s a va l i d a rc h ive by d e c o m p re s s i n g the f i l e to a


-
n e w l y created d i rectory n a m e d / b ac k u p t es t on se rverX.

I [ root@serverX -]#
D 3.1 . C reate t h e target d i rectory / b ac k u p t e s t .

-
mkdir /backuptest
'

- D 3.2. Switch to the /bac k u p t e s t d i rectory, w h e re we w i l l extract t h e f i l e s from t h e

I [ root@serverX -]#
e t c . t a r . gz a rc h i ve.

-
cd /bac kuptest
(

-
D 3.3. E x t ract t h e e t c . t a r . gz a rc h i ve to t h e /bac k u p t e s t d i recto ry.

[ root@serverX backuptest]# t a r xzf /tmp/etc . ta r . gz


-

- R H 1 24- R H E L 7 -en -1-20140606 297

-
-

C h a pte r 1 2 . A rc h i v i n g a n d Copy i n g Fi l es Between Syste ms


-

Copy i n g Fi l es Betwe e n Systems Sec u re l y -

Objectives -

After co m p l e t i n g t h i s sect i o n , stu d e nts s h o u l d be a b l e to copy f i l e s s e c u re l y to or from a remote

Copy files to or from a remote location with s c p


system r u n n i n g s s h d .
-

The ssh com m a n d i s usefu l fo r sec u re l y r u n n i n g s h e l l com m a n d s o n re mote systems. I t c a n a l s o


be u s e d to sec u re l y c o p y f i l e s from o n e m a c h i n e to a nother. T h e scp com m a n d t ra n sfers f i l e s
f r o m a remote h o s t to t h e l oca l system o r f r o m t h e l o c a l system to a remote host. I t u t i l izes t h e
S S H server for a u t h e n t i c a t i o n a n d e n c rypted data t ra n sfe r. -

Remote f i l e syst e m l o c a t i o n s a re a l ways specified i n t h e format [ u se r @ ] h o s t : /pat h for e i t h e r


t h e s o u rce o r t a rg et l ocation of t h e f i l e s to be t ra n sfe rred. T h e u s e r@ port i o n i s o pt i o n a l a n d , if
-
it is m i s s i n g , the c u rrent l oca l user that i nvokes the s c p co m m a n d i s used. Before the t ra n sfer is
i n it i ated, the u s e r m u st a u t h e nticate w i t h t h e S S H s e rver by pa ssword o r SSH keys.

T h i s exa m p l e s h ows how to copy the loca l f i l e s o n d e s ktopX, / e t c /yum . conf a n d -

/etc/hos t s, s e c u re l y to t h e acco u n t s t u d e n t o n t h e remote system serverX i n t o t h e d i rectory

j [student@desktopX -]$ scp /et c/yum . conf


/home/ s t u d e n t /:
-
I

j yum . conf
I student@serverX ' s password : s tu dent
/etc/host s se rverX : /home/student

100% 813 0 . BKB/s 00 : 00


hosts 100% 227 0 . 2KB/s 00 : 00
-

I
A user ca n copy a f i l e from a remote accou nt o n a re m ote m a c h i n e to t h e l o c a l f i l e syst e m with -

scp. In this exa m p l e, copy t h e f i l e /e t c/host n ame from t h e accou nt student o n t h e serverX
machine to t h e l o c a l d i rectory /home/ s t u d e n t / .

[student@desktopX - ] $ s c p se rve rX : /etc/host name / home/s t u d e n t /


-

student@serverX ' s password : s t udent


hostname 100% 22 0 . 0KB/s 00 : 00 -

To copy a w h o l e d i rectory t ree rec u rs ive l y, t h e - r o p t i o n is ava i l a b l e. I n t h e fo l l o w i n g exa m p l e,


t h e remote d i rectory /va r /log o n s e rverX is c o p i e d rec u rs ive l y to t h e loca l d i rectory / t mp/ o n -

d e s ktopX. To b e a b l e to r e a d a l l t h e c o n t e n t s of t h e / e t c d i recto ry, t h e root u s e r m u st con nect t o


t h e remote l o c a t i o n .

[student@desktopX -]$ scp - r root@s e rverX : /var/log


-

root@serverX ' s password : redhat


/tmp

Transfer fi les remote l y with s f t p


-

I f a n i nteractive tool i s p refe rred w h e n u p l o a d i n g o r d ow n l o a d i n g fi l es to a S S H server, t h e sft p


c o m m a n d c a n be us ed. A session w i t h s f t p is s i m i l a r to a c l a s s i c FTP sess i o n , but u ses t h e
sec u re a u t h e nt i c a t i o n m e c h a n i s m a n d e n c rypted d a t a t ra nsfer o f t h e S S H server. -

To i n itiate a s f t p sess i o n , t h e sf t p expects a remote l ocat i o n i n t h e fo r m a t [ u se r @ ] hos t ,


w h e re t h e u s e r@ port i o n is o pt i o n a l a n d , i f i t i s m i s s i n g , t h e u s e r i nvo k i n g t h e s f t p co m m a n d -

-
298 R H 1 24- R H E L7-en-1-20140606

-
-

Tra nsfer f i l es remote l y with s f t p


-

i s u s e d . To esta b l i s h t h e s f t p sess i o n , a u t h e nticating w i t h a n y o f t h e methods t h e S S H server


accepts i s n e cessa ry.

[student@desktopX ] $ sftp serverx


-

student@serverX ' s password : student


Connected to serverx .
-

sftp>
-

-
The s f t p session accepts va r i o u s c o m m a n d s t h a t work t h e s a m e way on the re mote f i l e syst e m
a s t h ey d o i n t h e l oca l f i l e syst e m , s u c h a s ls, c d , m k d i r , r m d i r , a n d pwd. I n a d d i t i o n , t h e re a re
t h e p u t a n d get com m a n d s for u p l o a d i n g a n d d ow n l o a d i n g f i l es. T h e exit co m m a n d exits t h e
-
s f t p session.

U p l o a d t h e l oc a l f i l e / e t c/hos t s to t h e n e w l y c reated d i rectory


-
/home/ s t udent/host bac k u p o n t h e remote h ost serverX. The s f t p sessi o n a l ways ass u m es
t hat t h e put com m a n d i s fo l l owed by a fi l e o n t h e l oca l file system and sta rts i n t h e c o n n e ct i n g
u s e r ' s h o m e d i rectory; i n t h i s case, / home/ s t u d e n t :

sftp> mkdir hostbackup


-

sftp> cd hostbackup
sf tp> put /etc/hosts
Uploading /etc/hosts to /home/student/hostbackup/hosts I
- ·

/ e tc / h o st s 1 0 0% 2 2 0 . 2K B / s 0 0 : 0
L_sftp>
_-___------�--�-��--�-�-�--7 _____ _ 0-·-����-__J'
_
_
__ __
- _

To d ow n l oa d the remote f i l e /e t c/yum . conf from t h e re mote host to t h e c u r rent d i rectory o n


- t h e loca l f i l e syste m , execute t h e c o m m a n d get /et c/yum . c o n f a n d e x i t the s f t p sess i o n
w i t h t h e e x i t co m m a n d .

sftp> get /etc/yum . conf


Fetching /etc/yum . conf to yum . conf
---------�- -----,

I
-

/etc/yum . conf 100% 813 0 . BKB/s 00 : 00


sftp> exit
-
[student@desktopX - ] $

References
-
R
s c p(l) a nd sft p(l) m a n pages
-

- R H 1 24- R H E L 7-en-1-20140606 299

-
-

C h a pte r 1 2. A rc h i v i n g a n d Copy i n g F i l es Betwe e n Systems


-

P ra ct i ce: Co pyi n g F i l es Ove r t h e N etwo rk Wit h


scp
-

Guide d exercise
-
I n t h i s l a b , students w i l l copy f i l es from a remote syste m to a loca l d i rectory by u s i n g scp.

Outcomes:
-
Students w i l l copy fi les from a re m ote host to a d i rectory o n the local m a c h i ne.

D 1. Rem ote l y copy t h e / e t c / s s h d i rectory o n t h e serverX m a c h i n e to the new l y c reated


-
d i rectory /home/s t u d e n t / s e rve rbac k u p o n desktopX by using scp.

D 1 .1 . C reate t h e ta rget d i rectory /home/ s t u d e n t / s e rve r ba ck up on d e s kto p X .

[student@desktopX -]$
-

!
i mkdir /home/ s t u d e n t / s e rverbackup
i

-
D 1 .2 . Recurs i ve l y c o p y t h e d i rectory / e t c / s s h from s e rverX to t h e
/home / s t u d e n t / s e rve rbac k u p d i rectory o n d e s ktopX w i t h t h e s c p
c o m m a n d . N ote t h a t o n l y t h e root user can rea d a l l t h e c o n t e n t i n t h e / e t c / s s h -

d i recto ry.

[ student@desktopX -]$
l
s c p - r root@serverX : /e t c / ssh /home/student/ -

serve rbackup

300 R H 1 24- R H E L 7-en-1-20140606 -

-
-

Sy n c h ro n i z i n g F i l es Betwe e n Syste m s Securely


-

Syn c h ro n i z i n g Fi l es B etwe e n Syste m s S ec u re l y


-

-
O bjectives
After c o m p l e t i n g t h i s sect i o n , st u d e nts s h o u l d be a b l e to effi c i e n t l y a n d secure l y sync h ro n i ze t h e
contents o f a l oca l f i l e o r d i rectory w i t h a remote co py.

Synchronize files and fol d ers with r sy n c


-

- The rsy n c tool i s a n o t h e r way t o securely copy f i l e s from o n e system t o a n ot h e r. I t d iffers from
scp i n that if two f i l e s o r d i recto ries a re s i m i l a r betwe e n two systems, rsy n c o n l y needs to copy
t h e d i fferences betwee n t h e syste m s , w h i l e s c p wou l d need to copy eve ryt h i n g .
-

O n e o f t h e a d va ntages o f rsync i s t h a t it ca n c o p y f i l e s between a loca l system a n d a remote


system s e c u r e l y a n d effi c i e n t l y. W h i l e the i n it i a l sy n c h ro n ization of a d i rectory t a kes a bout t h e
- s a m e t i m e a s copy i n g it, a ny s u bs e q u e n t syn c h ro n izat i o n o n l y req u i res t h e d iffe re nces to b e
copied ove r t h e network.

- O n e of t h e most i m portant options of rsync i s t h e - n option to perform a d ry run. A d ry r u n i s a


s i m u l at i o n of w h a t h a p pens w h e n t h e com m a n d rea l l y gets exec uted. I t w i l l d i s p l a y t h e c h a n g e s
it w i l l p e rfo r m w h e n t h e com m a n d i s executed w i t h o u t t h e d ry r u n o p t i o n . I t i s reco m m e n d e d
- to perfo r m a d ry r u n of a ny r sync o p e ra t i o n to e n s u re n o i m porta nt f i l es g e t ove rwritten o r
d e l eted.

- The two most co m m o n options when sy n c h ro n i z i n g files and fo l d e rs w i t h r sync a re t h e -a and -


v opt i o n s . W h i le t h e - v option a d d s verbos ity to t h e o u t p u t as t h e sy n c h ro n i z a t i o n proceeds, t h e
- a o p t i o n sta n d s f o r " a rc h ive m o d e " a n d e n a b l e s t h e fo l l owing opt i o n s a l l i n o n e :
-

· - r , sy n c h ro n ize rec u rs i ve l y t h e w h o l e d i rectory tree

- · - 1, sy n c h ro n i z e sym b o l i c l i n ks

• - p, preserve p e r m i s s i o n s
-
· - t , preserve t i m e sta mps

• - g, prese rve g r o u p owners h i p


-

• - o p rese rve t h e o w n e r o f t h e f i l e s
,

- • - D, s y n c h r o n i z e d e v i c e f i l es

W h i l e t h e - a a l re a d y sy n c h r o n i zes symbo l i c l i n ks, t h e re a re a d d i t i o n a l o p t i o n s necessary to


- p reserve h a rd l i n ks, a s t h ey a re t reated a s sepa rate f i l e s i n stead. The - H o p t i o n e n a b l e s t h e
h a n d l i n g of h a rd l i n ks, so t h e rsync com m a n d w i l l i d e n t ify t h e h a rd l i n ks p resent i n t h e sou rce
fo l d e r a n d l i n k t h e f i l e s accord i n g l y in the d e s t i n a t i o n fo l d e r i n stead of j u st copy i n g t h e m a s
- s e p a rate f i l es.

- R H 1 24- R H E L7-e n-1-20140606 301

-
-

C h a pter 1 2 . A rc h i v i n g a n d Copy i n g F i l es Betwe e n Systems

.:. ''41.:. '


Note
� -

The - a o p t i o n does not syn c h ro n i z e a d va n ced f i l e permissions, s u c h a s A C L s o r


S E L i n u x f i l e contexts. To e n a b l e t h e sy n c h ro n i z a t i o n o f A C L s , t h e - A o p t i o n i s req u i red
i n addition to t h e - a option, while to sy n c h ro n i z e t h e S E L i n u x contexts from the s o u rce -

f i l e s to t h e t a rget fi l es , t h e - X option is to b e a d d e d .

The b a s i c w a y of u s i n g r sync is to sy n c h ro n i z e t w o l o c a l fo l d e rs. I n t h e fo l l o w i n g exa m p l e, t h e


/ v a r/ lo g d i rectory g ets a sy n c h ro n ized c o p y i n t h e / t m p fo l d e r. The log d i rectory w i t h i t s
content i s c r e a t e d i n t h e / t m p d i rectory. -

[student@desktopX -)$ su
Password : redhat
-

[ root@desktopX - ] # rsync
-

- av /var/log /tmp

To o n l y sy n c h ro n i ze the content of a fo l d e r w i t h o u t n e w l y c reat i n g the fo l d e r i n the ta rget


d i recto ry, a t ra i l i n g s l a s h n e e d s to be a d d e d a t t h e end of the s o u rce d i recto ry. In t h i s exa m p l e,
t h e log d i rectory is not created i n t h e / t m p fo l d e r. O n l y t h e content of t h e /va r/log/ d i rectory -

i s synchronized i nto the /tmp fo l d e r.

[ root@desktopX - ] # rsync - av /var/log/ /tmp


-

Important
W h e n e n t e r i n g t h e s o u rce d i rectory for rsy n c , it i s very i m p o rtant to re m e m b e r t h a t -
w h et h e r a t ra i l i n g s l a s h i s present o n t h e d i rectory n a m e m atters. I t w i l l d ete r m i n e
w h et h e r t h e directory o r j ust t h e contents o f the directory a re syn c h ro n i z e d to t h e
target. N ote: Ta b-com p l et i o n w i l l a utomatica l l y a d d a t ra i l i n g s l a s h to t h e e n d of -

d i rectory n a m es.

-
S i m i l a r to scp, t h e r sync com m a n d ex pects remote fi l e system locations to b e specified i n t h e
fo rmat [ u s e r @ ] h o s t : / p a t h . I n c a s e t h e o pt i o n a l u s e r@ portion is m i s s i n g , t h e u s e r invo k i n g
t h e r s y n c c o m m a n d i s used to c o n n e c t to t h e re m ote l ocat i o n . I t i s poss i b l e to use a remote -
location a s e i t h e r sou rce o r ta rget. In the fo l l o w i n g exa m p le, the local fo l d e r /var /log gets
a sy nchronized copy i n t h e /tmp d i rectory on the serverX m a c h i ne. Fo r rsync to sy n c h ro n i ze
own e rs h i p of t h e t ra n sferred f i l es, t h e t a rget l o c a t i o n m u st be w r itten a s u s e r root, so c o n nect -

to the rem ote system serverX as the root u s e r. The c o n n e c t i n g user root m ust t h e n a ut h e nticate
with t h e SSH server by any of t h e accepted methods; for exa m p l e, password o r SSH keys.

[ root@desktopX -)$ rsync


-

root@serverX ' s password :


- av /var/log serverX : /tmp
redhat
-

In the s a m e way, the remote fo l d e r /var /log on serverX can be syn c h ro n ized to t h e loca l
d i rectory / t m p o n d e s ktopX: -

I [ root@desktopX -)$ rsync - av se rverX : /var/log /tmp


-

302 R H 1 24- R H E L 7-en-1-20140606 -

-
Sy n c h ro n i z e f i l es a n d fo l d e rs w i t h rsync

root@serverX ' s password : redhat

References
-
r sync(1 ) m a n p a g e

...

·-

R H 1 24- R H E L7-e n-1-20140606 303

-
-

C h a pter 1 2 . A rc h iv i n g a n d Copy i n g F i l es Betwe e n Systems


-

P ra ct i ce: Syn c h ro n i z i n g Two D i recto ries


S ec u re l y Wit h r sync
-

Guided exercise
-
I n t h i s l a b , st udents w i l l sy n c h ro n ize a fo l d e r w i t h a remote syst e m by u s i n g r sync.

Outcomes:
,-
A d i rectory w i l l be sy n c h ro n i zed from a remote m a c h i n e to t h e loca l m a c h i n e. After files o n the
re mote m a c h i n e have c h a n g e d , it w i l l b e sy n c h ro n ized with t h e loca l m a c h i n e again and o n l y t h e
m o d ifica t i o n s w i l l b e t ra nsferred. Both systems w i l l e n d w i t h i d e ntica l content i n t h e d i rectories
sy n c h ro n ized w i t h rsy n c .

D 1. S e c u r e l y c reate a n i n i t i a l c o p y of t h e / v a r / l o g d i rectory t ree o n serverX to a n e w l y


-
c reated d i rectory n a m ed / s e rve rlogs o n d e s ktopX w i t h t h e r s y n c com m a n d .

D 1 .1 . I n order t o c reate t h e ta rget d i rectory /se r ve r logs, switch t o t h e root u s e r


-
account w i t h t h e s u co m ma n d .

[student@desktopX -]$
Password : redhat
su -

[ root@desktopX -]#
-

!_
-
D 1 .2. C reate t h e ta rget d i rectory /se rve r logs o n d e s ktopX w h e re the l o g f i l es of
se rve rX w i l l b e sy n c h ro n ized.

j' [ root@desktopX -]# m k d i r /se rverlogs


-

-
D 1.3. U s e t h e rsync com m a n d to synchronize t h e /var /log d i rectory tree o n s e rverX
to the /s e rve rlogs d i rectory o n d e s ktopX. N ote t h a t only t h e root u s e r can
read a l l t h e content i n the /va r /log d i rectory o n s e rverX. All f i l es w i l l b e
-
t ra n sferred i n t h e i n it i a l s y n c h ro n i z a t i o n .

[ root@desktopX -]# rsync - av root@serve rX : /var/log /serverlogs


-

D 2. As root o n serve r X , r u n log g e r " Log files syn c h ronized " t o g et a n ew e n t ry i n -

t h e log f i l e /var /log/messages to ref lect w h e n t h e l a st sy n c h ro n ization took p l ace.

[ root@desktopX -]#
Password : redhat
s s h root@se rverx ' logger " Log f i l e s synch ronized " ' -

[ root@desktopX -]#
-

D 3. Securely syn c h ro n i z e the /var /log d i rectory t ree o n s e rverX to the /server logs
d i rectory o n d e s kto p X with the r sync co m m a n d a g a i n . N ote that t h i s time o n l y t h e

i [ root@desktopX -]#
-
c h a n g e d l og f i l e (s) w i l l be t ra n sfe rred.
i-

rsync - av root@serverX : /var/log / s e rverlogs


-

304 R H 1 24- R H E L 7-en-1-20140606 -

-
G u i d e d exerc i s e

·-

- R H124-R H E L 7 - e n -1 -20140606 305

-
-

C h a pter 1 2 . A rc h i v i n g a n d Copying F i l es Betwee n Systems


-

L a b : A rc h iv i n g a n d Co pyi n g F i l es Betwe e n
-

Syste m s
-

Perfor mance checklist


-
I n t h i s l a b, students w i l l u s e r sync, scp, a n d t a r to a rch ive a n d back u p fo l d e r contents.

Outcomes:
-
S t u d e nts w i l l sy n c h ro n ize a remote fo l d e r to a local d i rectory; a n arch ive i s then created w i t h the
syn c h ron ized fo l d e r a s content; t h e a rc h ive gets copied to t h e rem ote m a c h i n e and extra cted to
a newly c reated d i recto ry. -

Before you begin ...


Reset yo u r serverX syste m . -

1. Syn c h ro n i z e t h e / e t c d i rectory t ree o n serverX t o t h e /configsync d i rectory o n


desktopX.
-

2. O n desktopX, c reate a n a rch ive n a m ed / r o o t / c o nfigfile - bac ku p - s e rve rx . t a r . gz


with the /configsync d i rectory as content. a n d copy the a rc h ive to the / root d i rectory on
-
serverX for backu p p u rposes with the scp c o m m a nd.

3. To p repa re the a rc h ived d i rectory t ree for c o m p a rison with the c u r re n t l y


-
active l y u s e d confi g u ra t i o n f i l e s o n serverX, extract t h e contents of t h e
/ root/configfile - backu p - se rverX . t a r . g z archive t o t h e / t mp / savedconfig/
d i rectory o n serverX.
-

306 R H 1 24- R H E L7-en-1-20140606 -

-
-

-
Solution
-
Solution
-

I n t h i s l a b, students w i l l use rsync, scp, a n d t a r to a rc h ive a n d b a c k u p fo l d e r contents.


-
Outcomes:
S t u d e nts w i l l syn c h ro n i z e a remote fo l d e r to a l o ca l d i rectory; a n a rc h ive i s then created with t h e
-
syn c h ro n i zed fo l d e r a s content; t h e a rch ive g e t s c o p i e d to t h e remote m a c h i n e a n d extracted t o
a n e w l y c reated d i recto ry.

-
Before you begin ...
Reset yo u r se rve rX syste m .

- 1. S y n c h ro n ize t h e / e t c d i rectory t ree o n serverX to t h e /configsync d i rectory o n


desktopX.

-
1 .1 . To be a b l e to c reate t h e t a rg et d i rectory I configsync, switch to t h e root u s e r a c c o u n t

j [ student@desktopX -]$
u s i n g su.

Password : redhat
su

[ root@desktopX -]#
-

1.2. C reate t h e t a rget d i rectory for t h e config u rat i o n f i l es o n d e s ktopX.

' [ root@desktopX -]# mkdir /configsync


-----����--- -��--- �-�����--

L_ -------�-

-
1 . 3 . Use t h e r sync co m m a n d to sy n c h ro n i z e t h e / e t c d i rectory t ree on serverX to t h e
/configsync d i rectory o n desktopX. Be awa re t h a t o n l y t h e root u s e r ca n read a l l t h e
content i n t h e I e t c d i rectory on serverX.

[ root@desktopX -]#
-

rsync - av root@se rve rX : /e t c /configsync

2. O n d e s ktopX, create a n a rc h ive n a m e d / root /configfile - bac k u p - se rve rx . t a r . g z


w i t h t h e /configsync d i rectory as content. a n d copy t h e arch ive to the / root d i rectory o n
- serverX f o r b a c k u p p u rposes w i t h t h e s c p c o m m a n d .

2 .1 . Sto re t h e /configsync d i rectory i n t h e


- / root/configfile - bac kup - se rverX . t a r . g z a rc h i ve.

-
I [ root@desktopX -]# tar czf / root /configfile - backup - serverX . t ar . gz /configsync

2.2. C reate a b a c k u p copy of t h e / root/configfile - backu p - se rve rX . t a r . gz o n


-
serverX

[ root@desktopX configsync]# scp / r oot/configfile - bac kup - serverx . ta r . gz

Password : redhat
-
root@serve rX : /root

- R H124- R H EL 7-en-1 -20140606 307

-
-

C h a pter 1 2 . Archiving a n d Copy i n g F i l es Betwee n Systems

3. To prepare t h e a rc h ived d i rectory t ree f o r c o m p a r i s o n w i t h t h e c u rre n t l y


active l y used confi g u ra t i o n f i l e s o n se rve rX, extract t h e contents o f t h e
/ root /configfile - backu p - se rverX . t a r . g z arch ive to t h e / t mp/savedconfig/ -

d i rectory o n serve r X .

3.1 . C o n n ect t o t h e s e rverX m a c h i n e a s root by u s i n g s s h . -

[ root@desktopX configsync] #
Password : redhat
s s h root@serverX

[ root@serverX -]#
-

-
3.2. C reate t h e t a rget d i rectory / t mp/savedconfig/, w h e re t h e contents o f t h e
/ rootlconfigfile - bac ku p - se rve rX . t a r . g z a rc h ive w i l l b e extracted.

[ root@serverX -]# mkdir /tmp/savedconfig


-

3.3. C h a n g e to the t a rg e t d i recto ry /tmp/savedconfig/ on serverX. -

[ root@serverX -]# cd /tmp/savedconfig


[ root@serverx savedconfig] # l -

3.4. Extra ct the contents of t h e / root /configf ile - bac ku p - serve rX . t a r . gz a rc h ive
-
to the / t mp/savedconfig/ d i rectory o n serverX.

[ root@serverX savedconfig]# t a r xzf /root/configfile - backu p - serverX . ta r . gz -

308 R H 1 24- R H E L7-en-1-20140606 -

-
-

Sol ution
-

S u m m a ry
-

M a n a g i ng Co m p ressed t a r Arch ives


The tar co m m a n d p rovides a set of d iffe rent c o m p ress i o n methods to a rc h ive f i l e s a n d
-
restore t h e m from a n a rc h ive.

Copyi n g F i l e s Betwee n Syste m s S e c u r e l y


-
Besides p rovi d i n g a s e c u re remote s h e l l , the ssh s e r v i c e a l s o p rovides t h e scp a n d
s f t p a s s e c u re ways to t ra n sfer f i l es f r o m a n d to a remote syste m r u n n i n g t h e S S H
se rver.
-

Syn c h ro n i z i n g F i l e s Betwe e n Syste ms S e c u r e l y


T h e r s y n c com m a n d sec u re l y a n d eff i c i e n t l y sy n c h ron izes f i l es w i t h a rem ote locat i o n .
-

- R H 1 24- R H E L 7-en-1 -20140606 309

-
-

·�
I

310


'
red h at ®

®
TRAINING

C H A PT E R 1 3

INSTALLING AND U PDATING


SOFTWARE PACKAGES

Overview

Goal To down load, insta l l , u p d ate, a n d m a nage softwa re packages


from Red Hat and YUM p a c kage repositories.

Objectives • Register systems with yo u r Red H at account a n d e n t i t l e


them to software u pd ates f o r i n sta lled p roducts.

• Explain what a n RPM p a c kage i s a n d how R P M packages


a re used to m a n a g e software on a Red Hat E nterprise
L i n u x system.

• Find, i nsta l l , and u p d ate software packages using the yum


command.

• E n a b l e a n d d is a b l e u s e of Red Hat or t h i rd-pa rty Y U M


re positories.

• E x a m i n e and i nsta l l d o w n loaded software package files.

Sections • Att a c h i n g Systems to S u bsc riptions for Software U pdates


(and Pra c t ice)

• R P M Software Packages and Y U M (a n d Pra c t ice)

• M a n a g i n g Software U pd ates with yum (a n d P ract ice)

• E n a b l i n g yum Software Repositories (and Pra c t ice)

• E xa m i n i n g RPM Package F i l e s (a nd P ract i ce)

Lab • I nsta l l i n g a n d U pd a t i n g Software Packages

RH124- R H EL 7-e n-1-20140606 311


-

C h a pter 13. I nsta l l i ng a n d U pd a t i n g Softwa re Pa ckages


-

Atta c h i n g Syst e m s to S u bscri pt i o n s fo r


-

Softwa re U pd ates
-

Objectives
-
Reg ister syste m s with yo u r Red H a t accou nt a n d e n t i t l e t h e m to s oftwa re u pdates for i n sta l l ed
prod u cts.

-
Red Hat Su bscription Manage ment
Red Hat S u bscription M a n a g e m e n t p rovides too l s t h a t c a n be u s e d to e n t it l e m a c h i n es to
product s u bscriptions, a l l ow i n g a d m i n istrators to get u pdates to s oftwa re packages and track -

i nfo r m a t i o n a bout s u p p o rt co n tracts a n d s u bscriptions used by t h e syste ms. Sta n d a rd too l s such
a s Pa c k a g e K i t a n d y u m c a n o b ta i n softwa re packages a n d u pd ates t h ro u g h a content d is t r i b u t i o n
-
netwo r k p rovided b y Red Hat.

T h e re are fou r basic tasks perfo r m e d w i t h Red Hat S u bs c r i p t i o n M a n a g e m e n t too l s :


-

• Register a system to a ssociate t h a t system to a Red Hat accou nt. T h i s a l l ows S u bs c r i p t i o n


M a n a g e r to u n iq u e l y i nventory t h e system. W h e n n o l o n g e r i n u se, a system may be
-
u n registered.

• S u bscribe a system to e n t i t l e it to u p dates for s e l ected Red H a t p ro d u cts. S u bs c r i p t i o n s have


specific l eve l s of su pport, e x p i ra t i o n d ates, and defa u l t repositori es. The too l s can be used to -

e i t h e r a uto-atta ch o r s e l ect a specific e n t i t l e m e nt. A s needs c h a nge, s u bscript i o n s may be


removed.
-

• Enable repositories to p rov ide softwa re packages. M u lt i p l e repos itories a re e n a b l e d by


d efa u l t with each s u bs c r i p t i o n , b u t ot h e r repositories such a s u pdates o r s o u rce code can be
enabled or disabled as needed. -

• Review and track e n t it l e m e nts w h i c h a re ava i l a b l e o r co n s u m e d . Su bscript i o n i nfo r m a t i o n c a n


b e viewed l o ca l l y on a s p e c i f i c syste m o r, f o r a n a c c o u n t , i n e i t h e r t h e Red H a t Custo m e r Porta l -

S u b s c r i pt i o n s page o r t h e S u bs c r i p t i o n Asset M a n a g e r (SA M ) .

R e g i ster a system
-
To register a system w i t h the s u bs c r i p t i o n m a n a g e m e n t service, l a u n c h s u b s c r i p t ion ­
manage r - gu i by s e l e ct i n g A p p l i c a t i o n s > O t h e r > R e d H a t S u b s c r i p t i o n M a n a g e r from t h e m a i n
G N O M E m e n u . E nter t h e password f o r root w h e n prom pted to a u t h e nti cate. T h i s w i l l d i s p l a y t h e -

fo l l o w ing S u b s c r i p t i o n M a n a g e r w i n d ow.

312 R H1 24- R H E L7-en-1-20140606 -

-
Red H a t S u bscription M a n a g e m e n t

Subscription Manager

System H elp

. My I nstalled Products

My Subscriptions
�����
j
�� ������������������������----,!

Keep system up to date by registering. R eg i ste r

I
Status: your

Product Version Status Start Date End Date


I

111••e•·l'@@!l.§i?7�:ft;lji.ft;@E
-

I
1 • Red H a t Enterprise Linux 7 Public Beta 7 . 0 Beta Unknown
I
! I

I
Product's S u b s c ription Details

e rs
Status: System is not registered.

Product: Red H at E n t rp i e Linux 7 Server High Touch Beta

Arch: x86_64

Figure 13. 1: The main window of Red Hat Subscription Manager

To reg iste r t h e system, c l ick t h e Register b u tton in t h e top-r i g h t corner of t h e S u bscription


Manager w i n dow. This will bring up the fo l l ow i n g d i a lo g :

System Regi stration

The s u b s u i p t i o n m a n a g e m e n t s e rvi c e yo u 1· e g i s t e r •.-vith w i ll p r o v i d e your

system vv i th u p d a t e s and a l l mN a d d i ti o n a l m a n a g e m e n t .

I will register with:


[ l!•tUi1�11iM�'lli"�'"""-¥f•ii§J!-@ [ Defa u l t J
n I v;iLL u s e an A c tivation Key

/b. If r e q u i r e d, p l e a s e c o n fi g u r e your p r oxy b efo r e m ov i n g fo r w a 1· d . I C o nfi g u 1· e P ro x yj

Cancel N ex t

R H124- R H EL 7-en-1 -20140606 313


-

C h a pte r 1 3. I n sta l l i n g a n d U pd a t i n g Softwa re Pa c k a g e s

Figure 1 3. 2: The service location dialog of Red Hat Subscription Manager


-
T h i s d i a l o g box registers a system w i t h a s u bs c r i p t i o n server. The d efa u l t
(s u bs c r i pt i o n . r h n . re d h at.com) wi l l reg ister t h e server t o Red H a t ' s " hoste d " content d i s t r i b u t i o n
network.
-

System Regi strati o n


-

Plea s e enter yo u r R ed H at a c c o u nt i n f o rm ati o n : -

Login: I demo-accoun �
-

Password: · • • • • • •

u Tip : F o r g ot yo ur L o g in o r pa s sw o r d ? Lo o k it up
at ht t p ://redhat . c o m/f o rg o L pa s sword
-

Plea s e enter the follow i n g fo r th i s system :


-

System N ame: d e mo . e x a m p l e . c o m

-
·-., M a n u a l ly a tt a c h s u b s c r i pti o n s aft e r r e g i s trat i o n

Cancel Register
-

Figure 1 3. 3: The account information dialog of Red Hat Subscription Manager

C l i c k N e x t , t h e n a u t h e nt i cate u s i n g t h e Red H a t account to w h i c h t h e syst e m s h o u l d be


reg i stered.

By defa u lt , S u b s c r i p t i o n M a n a g e r w i l l try to find the best s u bscription for this system out of a l l -

ava i l a b l e s u bscriptions. I f m o re t h a n o n e s u bs c r i p t i o n i s ava i l a b l e, o r a specific s u bscription is


req u i re d , c h e c k the M a n u a l l y atta c h s u b s c r i p t i o n s a ft e r re g i s t ra t i o n c h e c kbox. With this option
-
c h e c ked, S u b s c r i p t i o n M a n a g e r w i l l only reg ister t h e system and not a utomat ica l ly assign a ny
su bscript i o n s .

-
Click the R e g i st e r b u t t o n to com p l ete t h e reg istra t i o n .

A s s i g n i n g s u bs c r i pt i o n s
-
To a s s i g n s u bs c r i pt i o n s to a syst e m , n a v i g a te to t h e A l l Ava i l a b l e S u bs c r i p t i o n s t a b i n t h e m a i n
wi ndow of S u b s c r i p t i o n M a n a g e r , t h e n c l i c k t h e U p d ate b u t t o n to ret ri eve a l ist o f ava i l a b l e
su bscript i o n s .
-

-
314 R H 1 24-R H EL 7-en-1-20140606

-
Red H a t S u bscription M a nagement

Subscription Manager-

System Help

- -- I
• My Installed Products J My Subscriptions Jr.A ll Available Subsc riptions L _

2014·02-14 t!J] Update 2 applied


'
Show subscriptions active on: Filters
.
• Click to Adjust OU:intity

Red Hat Employee Subscription Both Unlimited

Red Hat E m oy e
pl e Subscription Both m
Un li i ted

;,

90 Day Self-Supported Red Hat Sat ellite 6 MDP-2 Physical

q
Subscription Details

Products: Pro duc t

Red Hat Beta

Red Hat Enterprise Linux 7 Public Beta

Red Hat Enterprise Linux Server

Red Hat Software Collections Beta (for RHEL Server)

Attach

Figure 13. 4: All Available Subscriptions tab of Red Hat Subscription Manager

Fro m t h i s l i st, select o n e or m o re s u bscriptions to a s s i g n to t h i s syst e m , then c l i c k t h e Attac h


button.

I f t h e re i s m ore t h a n one cont ract for a specific s u bs c r i p t i o n , a n ew d i a l o g will open u p, a s k i n g


y o u to s e l ect w h i c h c o n t ra ct to u s e. N ote t h a t t here a r e d iffe rent cont racts f o r Physical a n d
Virtual systems.

Contract Selection

Choose the specific co ntract to use:

S ubscription: 30 Day Self-Supported Re d Hat E n t e r·prise Linux Server, (2 sockets) (Up to 1 guest) Evaluation

Total Contracts: 4
• Click to Adjust Qu;, ntity
I
!
'
Contract Type U sed I Total Start Date E n d Date Quantity
I
--

1 10365182 Virtual 0/1 0 1/19/2014 0 2/ 1 7/ 2 0 1 4 1

' 1 0 3 8 0689 Physical 0/1 0 2/10/20 14 0 3/ 1 1/2014 1

j 1 0 3 6 5 18 2 Physical 0/1 01/19/ 2 0 14 0 2/17/ 2 0 1 4 1


I

I __ _

Cancel 11 Attach
'�-·--

Figure 13. 5: Contract selection dialog of Red Hat Subscription Manager

After a s u bscription h a s been a s s i g n e d , c lose t h e S u b s c r i p t i o n M a nager w i n d ow. T h e system i s


n o w p ro p e r l y s u bs c r i b e d a n d ready to receive u p d ates a n d /o r i nsta l l n e w softwa re f r o m Red Hat.

RH124- R H E L7-e n -1 -20140606 31 5


-

C h a pt e r 1 3 . I nsta l l i n g a n d U pd a t i n g Software Pa ckages


-

Auto mating registrations and subscriptions


-
U s e s u b s c r i p t ion - manag e r ( 8 ) to reg ister a syste m w i t h o u t u s i n g a g ra p h i c a l e n v i ro n m e nt.
T h e s u b s c r i p t ion - manag e r c o m m a n d can a u t o m a t ica l l y attach a system to t h e best-matched
c o m p at i b l e s u bscript i o n s for t h e system.
-

• Reg i ster a system to a Red H a t account:

t [ root : @serverX - ] # subsc ription - manager regis t e r - - u s e r n ame=yourusername


pas swo rd=yourpassword
-

-
• View ava i l a b l e s u b s c r i p t i o n s :

[ root : @serverx - ] # subsc ription - manager list - - available I less -

• A u to-attach a s u b s c r i pt i o n :

[ root : @serverX
-

- ] # subsc ription - manager a t t ac h - - a u t o

I [ root : @serverx
• View consumed s u b s c r i pt i o n s:

r
-
- ] # subsc ription - manager list - - consumed


• U n re g i ster a syste m :

[ [ root :@serverx
-

-]# s u b s c ript on - manager u n regist e r


l -

-4i>.: '

� Note
-
s u b s c r i p t ion - manag e r c a n a l so b e used i n conj u n c t i o n w i t h activation keys,
a l l o w i n g reg istra t i o n a n d a ss i g n m e nt of predef i n e d s u b s c r i pt i o n s, without u s i n g a
u s e r n a m e o r password. T h i s method of reg istra t i o n ca n be very usef u l for a u t o m ated -
i n sta l la t i o n s a n d d e p l oy m e nts. Activation keys a re u s u a l l y issued by a n o n - p re m ise
s u bs c r i pti o n m a n a g e m e n t se rvice, s u c h a s S u bs c r i p t i o n Asset M a n a g e r, and w i l l n o t b e
d i sc u ssed i n deta i l i n t h i s cou rse. -

Entitle ment certificates


A n e n t i t l e m e n t is a s u b s c r i p t i o n t h a t ' s b e e n atta c h e d to a syst e m . O i g ita l certifi cates a re used
to sto re c u rrent i nfo r m a t i o n a bout e n t i t l e ments o n the loca l syste m . O n ce registere d , t h e -

e n t i t l e m e n t certificates a re stored i n / e t c / p k i a n d i t s s u b d i rectories.

· / e t c/pki/ p r o d u c t conta i n s certificates w h i c h i n d icate Red Hat products i n sta l l ed on the -

system .

· / e t c/pki/consume r conta i n s certificates w h i c h i n d icate t h e R e d Hat acco u nt to w h i c h t h e -

system i s reg i stered.

31 6 RH124- R H E L 7-en-1-20140606 -

-
-

Entit l e m e n t certificates
-

· / e t c / p ki/en t i t lement conta i n s certifi cates which i n d icate w h i c h s u bscriptions a re


att a c h e d to t h e syste m .
-

The certificates c a n be i n s pected w i t h t h e r c t u t i l ity d i re c t l y, but n o r m a l l y t h e s u b s c r i p t ion ­


manag e r too l s a re a m o re u s e r-fri e n d l y way to exa m i n e t h e s u bs c r i p t i o n s that a re attached to
-
the syste m .

- Important
O l d e r v e rs i o n s of Red H a t Enterprise L i n u x orig i n a l l y s u p ported a d i fferen t s u bscription
m a n a g e m e n t method, RHN Classic. R H N C l a ss i c i s not s u p p o rted by Red Hat
-
E n t e r p rise Linux 7.

T h e method covered i n t h i s section, Red Hat Subscription Management, i s t h e o n l y o n e


-
used by R H E L 7, a n d is t h e defa u lt m e t h o d used by R H E L 6 after R H E L 6 . 3 , a n d R H E L
5 after R H E L 5.9. R H E L 4 o n l y s u p p o rt s t h e o l d method. M o re i n f o r m a t i o n o n both
m e t h o d s i s a va i l a b l e i n the refe rences a t the e n d of this sect i o n .
-

- R References
s u b s c r i p t ion - manage r - g u i(8), s u b s c r i p t ion - manag e r (8), a n d r c t (8) m a n
pages
-

G e t started w i t h R e d H a t S u bscri p t i o n M a n a g e m e n t
https ://access.redhat.co m/s ite/a r t i c l es/433903
-

Red Hat S u bscription M a n a g e m e n t : M i g ra t i n g from R H N a n d Satel l ite


https://a ccess. red hat.com/s ite/d o c u m e n ta t i o n/en - U S/
-
Red_Hat_S u bscr i pt i o n_M a n a g e m e nt/1 /htm l -s i n g l e/ M i g rat i n g R H N /

- R H 1 24- R H E L 7-e n-1-20140606 317

-
-

C h a pter 13. I n sta l l i ng a n d U pd a t i n g Softwa re Packages -

P ract i ce: Red H at S u bsc ri pt i o n M a n a g e m e nt -

Quiz -

Match t h e fo l l o w i n g items to t h e i r c o u n t e r p a rts i n t h e t a b l e.


-

E n a b l e re p o s i t o r i e s Reg i st e r I Review a n d t ra c k I S u bsc r i be -

Descri pt i o n Ta s k
-

Dete rm i n e t h e n u m be r of ava i l a b l e
-
s u bsc r i p t i o n s

E n a b l e a syste m to u s e s e l ected Red H a t


p rod u cts
-

Atta c h a syste m to a Red H a t a c co u n t -

P rov i d e softwa re p a c ka g e s -

318 R H124-R H EL 7-en-1-20140606

-
-

Sol ution
-

Solution
-

Match t h e fo l l ow i n g ite m s to t h e i r cou nterparts i n t h e t a b l e.

Desc r i p t i o n Ta s k

Dete r m i n e t h e n u m be r of ava i l a b l e Review a n d t ra c k


-
s u bs c r i p t i o n s

- E n a b l e a syst e m to u s e s e l ected Red H a t S u bs c r i b e


p ro d u cts
-

Atta c h a syst e m to a Red H a t acco u n t Reg i st e r

Prov i d e softwa re p a c k a g es E n a b l e re pos ito r i e s


-

- R H 1 24- R H E L 7-e n-1-20140606 319

-
-

C h a pt e r 1 3 . I n sta l l i ng a n d U pd a t i n g Softwa re Pa ckages


-

R P M Softwa re Pa c ka g es a n d Yu m -

Objectives -

Afte r com p l et i n g t h i s sect i o n , stu d e nts s h o u l d be a b l e to e x p l a i n what an R P M package is a n d


how R P M packages a re u s e d to m a n a g e softwa re o n a R e d H a t E nterprise L i n u x syst e m .
-

Software packages and R PM


M a ny years ago, Red H a t d eve loped t h e R P M Pa c k a g e M a n a g e r , w h i c h provides a sta n d a rd
way to package softwa re for d ist r i b u t i o n . M a n a g i n g softwa re i n t h e form of RPM packages is
much s i m p l e r than w o r k i n g w i t h softwa re that h a s s i m p l y b e e n extracted i nto a file syst e m from
a n a rc h ive. I t l ets a d m i n i st rators t ra c k which f i l es were i n sta l l ed by t h e softwa re package a n d -

w h i c h o n e s n e e d t o be removed if it is u n i nsta l l ed , a n d c h e c k to e n s u re s u pporting packages


a re p resent w h e n it i s i n sta l l ed. I nfo r m a t i o n a bout i n st a l le d p a c kages is stored i n a loca l R P M
database o n e a c h syst e m . A l l softwa re p rovided b y R e d H a t f o r R e d H a t Enterprise L i n u x i s -

provided a s a n R P M package.

RPM package f i l es a re named using a combination of t h e p a c k a g e name - ve r sion ­ -

release . a r c h i t ec t u re:

�----- NAME
-

.------ VERSION
RELEASE
r- ARCH
I
-
I

httpd -tools -2 . 4 . 6-7 . el7 . x86_64 . rpm


,-1-, ,-1-, ,---1--,

-
----- - ------ --��- ---�--·__J
• N A M E is o n e o r m o re words desc r i b i n g t h e contents ( httpd -too l s).
-

• V E R S I O N i s t h e vers i o n n u m be r of t h e o r ig i n a l software (2.4.6).

• R E L E A S E is t h e re leas e n u m be r of t h e package based o n t h a t vers i o n , a n d is set by t h e


packager, w h o m i g ht n o t be t h e o r ig i n a l softwa re deve l o p e r (7.e l7).

• ARCH i s t h e p rocessor a rc h itectu re t h e packa g e wa s co m p i l ed to r u n on. " n o a rc h " i n d icates


-
that this package's contents a re not a rc h itect u re-specific (x86_64).

W h e n i nsta l l i n g packages from re positories, o n l y t h e p a c k a g e n a m e is req u i red. The p a c k a g e with


-
t h e higher vers i o n wi l l b e i n sta l l ed. I f t h e re are m u lt i p l e fi l es w i t h t h e s a m e vers i o n , t h e package
w i t h t h e higher re l ease n u m be r w i l l be i n sta l l e d .

E a c h R P M package is a s p ec i a l arch ive m a d e u p o f t h re e c o m p o n e nts: -

• The fi l es i n sta l l e d by the package.


-

• I nfo rmation a b o ut t h e package (metadata), s u c h as t h e n a me/ve rsion/re lease/arch; a s u m m a ry


a n d description of t h e package; w h e t h e r it req u i res other p a c kages to be i n sta l l ed ; l ic e n s i n g ; a
package c h a n g e l o g ; a n d other d eta i l s. -

• S c r i pts which may run when this package i s i n sta l l e d , u pd a t e d , or re moved, o r which a re
t r i g g e red w h e n ot h e r packages a re i nsta l l ed, u pdated, o r re m oved. -

-
320 RH124- R H E L 7-e n-1-20140606

-
-

T h e y u m package m a n a g e r
-

R P M p a c ka g es c a n be d i g i ta l l y s i g n e d b y t h e o rg a n ization t h a t pa c k a g e d t h e m . A l l packages from


a partic u l a r s o u rce a re n o r m a l l y s i g n e d by t h e s a m e G P G p ri vate key. I f the pa ckage is a ltered o r
-
corrupted, t h e s i g n at u re w i l l n o l o n g e r be va l i d . This a l l ows t h e syste m to verify p a c k a g e i n t e g r ity
before i n sta l l i ng them. A l l R P M packages re l ea s e d by Red Hat a re d i g i ta l l y s i g n e d .

-
U pd a t e s a n d Patc h e s
When t h e u pstream s o u rce code fo r a softwa re packa g e i s patched by Red Hat, a co m p l ete
RPM p a c k a g e i s g e n e rated. I f a p a c k a g e i s n e w l y added to a syste m , o n l y the l a test vers i o n of
-
t h a t p a c k a g e is n e e d e d , n ot every vers i o n of t h e package s i n ce the fi rst re l ease. Fo r syste m s
t h a t n e e d u p d a t i n g , t h e o l d vers i o n of t h e package is actua l l y re m oved a n d t h e new vers ion is
i n sta l l e d . Config u ra t i o n f i l es a re u s u a l l y reta i n e d d u r i n g a n u p g ra d e, b u t t h e exact behavior for a
-
partic u l a r package is defined w h e n t h e new vers i o n of t h e package i s created.

In most cases, o n l y o n e vers i o n o r re lease of a package m a y be i n sta l l e d at a t i m e. Typ i ca l l y, t h e


-
R PM i n sta l l a t i o n process w i l l n ot a l l ow fi l e s to be ove rwritte n . I f a p a c k a g e i s b u i l t so t h a t t h e re
a re n o conf l i c t i n g f i l e n a mes, t h e n m u l t i p l e vers i o n s may be i n sta l l e d . T h i s is t h e case for t h e
k e r n e l p a c k a g e . S i nce a new ke r n e l c a n o n l y b e tested by boot i n g to t h a t kern e l , t h e package i s
-
specifica l l y d e s i g n e d so that m u lt i p l e vers i o n s m a y be i n sta l l e d at o n ce. I f t h e new ke r n e l fa i l s t o
boot, t h e o l d ke r n e l is sti l l ava i l a b l e.

The yum package manager


O n ce a system is i n sta l l e d , a d d i t i o n a l softwa re packages a n d u pdates a re n o r m a l l y i n sta l led from
a netwo r k package repository, most f req u e n t l y t h ro u g h t h e Red Hat s u bscription m a n a g e m e n t
service d i s c u ssed i n t h e prev i o u s sect i o n . T h e rpm com m a n d may b e u s e d to i n sta l l , u pdate,
remove, and q u e ry RPM packages. H oweve r, it does not res o l ve d e p e n d e n c i es a u t o m a t i ca l l y a n d
-
a l l packages m u st be l isted. Too l s s u c h a s Pa c ka g e K it a n d y u m a re front-e n d a p p l ications f o r r pm
a n d c a n be used to i n sta l l i n d i v i d u a l packages o r package collections (so metimes ca l l ed package
groups) .
-

The yum c o m m a n d searches n u m e ro u s repositories for packages a n d t h e i r d e p e n d e n c ies so t h ey


may be i n sta l l ed toget h e r in a n effo rt to a l l eviate d e p e n d e n c y issues. T h e m a i n confi g u ration
-
f il e for yum i s / e t c /yum . conf w i t h a d d it i o n a l repository config u ra t i o n f i l es l ocated i n t h e
/et c/yum . repos . d d i rectory. Repos itory confi g u ration f i l es i n c l u d e , at a m i n i m u m , a r e p o id ( i n
s q u a re b ra c kets), a n a m e a n d t h e U R L l o c a t i o n of t h e package re posito ry. The U R L can point to
-
a l oca l d i rectory (fi l e) o r remote n etwork s h a re ( http, ftp, etc.). If the U R L i s pasted i n a b rowse r,
t h e contents s h o u l d d i s p l ay t h e R P M packa g e s , possi b l y i n o n e or m o re s u b d i rectories, a n d a
repod a t a d i rectory with i nfo r m a t i o n a bo u t a va i l a b l e packag es.
-

The yum co m m a n d i s used to l i st repositories, p a c kages, and package g ro u ps:

[ root@serverx -]# yum repolist


Loaded plugins : langpacks
-

repo id repo name status


! rhel_dvd Remote classroom copy of dvd 4, 529
repolist : 4, 529
-

[root@serverX -]# yum list yum*


Loaded plugins : langpacks
Installed Packages
yum . noarch 3 . 4 . 3-118 . 2 . el7 @anaconda/7 . 0
-

yum-langpacks . noarch 0 . 4 . 2-3 . el7 @rhel_dvd


yum-metadata- parser . x86_64 1 . 1 . 4-10 . el7 @anaconda/7 . 0
yum - rhn-plugin . noarch 2 . 0 . 1-4 . el7 @rhel_dvd
yum- utils . noarch 1 . 1 . 31- 24 . el7 @rhel_dvd
-

Available Packages
-

- R H1 24- R H E L7-en-1-20140606 321

-
-

C h a pte r 1 3. I n sta l l i n g a n d U pd a t i n g Softwa re Packages

yum- plugin-aliases . noarch 1 . 1 . 31-24 . el7 rhel_dvd


-

yum- plugin- changelog . noarch 1 . 1 . 31-24 . el7 rhel_dvd


yum- plugin - tmprepo . noarch 1 . 1 . 31-24 . el7 rhel_dvd
yum- plugin -verify . noarch 1 . 1 . 31- 24 . el7 rhel_dvd
yum-plugin-versionlock . noarch 1 . 1 . 31-24 . el7 rhel_dvd
-

[ root@serverx - ] # y u m l i s t installed
Loaded plugins : langpacks
Installed Packages
-

GConf2 . x86_64 3 . 2 . 6-8 . el7 @rhel_dvd


ModemManager . x86_64 1 . 1 . 0- 6 . git20130913 . el7 @rhel_dvd
ModemManager - glib . x86_64 1 . 1 . 0- 6 . git20130913 . el7 @rhel_dvd -

[ root@serverx - ] # yum grouplist


Installed groups :
Base

Desktop Debugging and Performance Tools


Dial- up Networking Support
Fonts
-

Input Methods
-

{ R References
�-
· -
yum(8), yum . conf(5), r pm(8), r pm2cpio(8), a n d rpmkeys(8) m a n pages

322 R H1 24- R H E L 7-en-1-20140606

-
-

Practice: R P M S oftwa re Packages


-

Pra ct i ce: R P M S oftwa re Pa c ka g es


-

-
Quiz
Match t h e fo l l ow i n g i t e m s to t h e i r cou nte rparts i n t h e t a b l e.

Arch itect u re
I I C h a n g e l og G P G s i g n a t u re
I Release

-
Repos itory
18
-

Desc r i p t i o n Te r m

T h e u pst rea m s o u rce code vers i o n


-

L i st of rea s o n s fo r ea c h p a c ka g e b u i l d
-

T h e ve rs i o n of t h e p a c k a g e b u i l d
-

T h e p rocessor ty p e req u i red fo r a s p e c i f i c


-
p a c ka g e

A co l l ect i o n of R P M p a c ka g e s a n d p a c k a g e
g r o u ps
-

-
U s e d to v e r i fy t h e s o u rce a n d i nteg r ity of a
package

- R H 1 24- R H E L 7 - en -1 -20140606 323

-
-

C h a pter 13. I n sta l l i ng a n d U pd a t i n g Softwa re Pa ckages


-

Solution
-

M a t c h t h e fo l l ow i n g items to t h e i r cou nterparts i n t h e ta b l e.

D e sc r i pt i o n Te r m
-

T h e u pst rea m s o u rce code ve rs i o n Ve rs i o n


-

L i st of rea s o n s fo r e a c h p a c k a g e b u i l d Change log


-

T h e ve rs i o n of t h e p a c k a g e b u i l d R e l ease
-

T h e p rocess o r ty p e req u i re d for a s p e c i f i c A rc h i tect u re -

p a c ka g e

A co l l ect i o n of R P M p a c ka g es a n d p a c ka g e R e p o s itory
g ro u ps -

U s e d to ve r i fy t h e s o u rce a n d i n teg r i ty of a G PG s i g n a t u re -

p a c ka g e
-

-
324 RH124- R H E L7 - e n -1-20140606

-
-

M a n a g i n g Software U pdates w i t h yum


-

M a n a g i n g Softwa re U pd ates wit h yum


-

-
Objectives
After c o m p l et i n g t h i s sect i o n , s t u d e n t s s h o u l d b e a b l e to f i n d , i nsta l l , a n d u pdate softwa re

Working with yum


packages u s i n g t h e yum com m a n d .
....

yum i s a powerf u l c o m m a n d - l i n e t o o l t h at c a n b e used t o m o re f l ex i b l y m a n a g e ( i nsta l l , u pd a te,


-
rem ove, and q u e ry) softwa re packages. Officia l Red Hat packages a re n o r ma l ly d ow n l oa d e d from
Red Hat's content distribution network. Registering a syst e m to t h e s u bscription m a n a g e m e n t
s e r v i c e a utomatica l l y confi g u res a c c e s s to software re positories b a s e d o n t h e atta c h e d
-
s u bs c r i pt i o n s.

F i n d i n g softwa re wit h yum


-
• y u m h e l p w i l l d i s p l ay u s a g e i nformat i o n .

• yum l i s t d i s p l ays i n sta l l ed a n d ava i l a b l e packages.

[ root@serverx - ] # yum l i s t ' ht t p * '


-

Loaded plugins : langpacks


Available Packages
httpcomponents-client . noarch 4 . 2 . 5-4 . el7 rhel_dvd
-

httpcomponents-core . noarch 4 . 2 . 4-6 . el7 rhel_dvd


httpd . x86_64 2 . 4 . 6-17 . el7 rhel_dvd
httpd -devel . x86_64 2 . 4 . 6-17 . el7 rhel_dvd
httpd -manual . noarch 2 . 4 . 6-17 . el7 rhel_dvd
-

httpd - tools . x86_64 2 . 4 . 6-17 . el7 rhel_dvd


-

• yum s e a r c h KEYWORD l i sts packages by keywords fou n d in t h e n a m e a n d s u m m a ry f i e l d s


-
o n l y.

To search for packages that have " w e b serve r " i n t h e i r n a m e, s u m m a ry, a n d description f i e l d s ,
use s e a r c h all:

[ root@serverx -]# yum search all ' web s e rve r '


-

Loaded plugins : langpacks


Matched : web server
freeradius . x86_64 : High-performance and highly configurable free RADIUS server
-

hsqldb . noarch : HyperSQL Database Engine


============================= ==============================

httpd . x86_64 : Apache HTTP Server


libcurl . i686 : A library for getting files from web servers
libcurl . x86_64 : A library for getting files from web servers
-

mod_revocator . x86_64 : CRL retrieval module for the Apache HTTP server
mod_security . x86_64 security module for the Apache HTTP Server
python-paste . noarch : Tools for using a Web Server Gateway Interface stack
-

-
• yum info PACKAGENAME g ives d eta i l e d i nformation a b o u t a p a c ka g e, i n c l u d i n g t h e d i s k
s p a c e n e e d e d f o r i n sta l l at i o n .

- To get i nfo rmation o n the A p a c h e H T T P S e rver:

I
i [ root@serverx -]# yum info h t t pd
-

- R H 1 24- R H E L 7-en-1-20140606 325

-
-

C h a pter 1 3. I n sta l l i n g a n d U pd a t i n g S oftwa re Packages

Loaded plugins : langpacks


-

Available Packages
Name httpd
Arch x86_64
-

Version 2.4.6
Release 17 . el7
Size 1.1 M
Re po rhel_dvd
-

Summary Apache HTTP Server


URL http : //httpd . apache . org/
License ASL 2 . 0
Description The Apache HTTP Server is a powerful, efficient , and extensible
-

web server .
--

• yum p r ovides PA THNAME d i s p l ays packages t h a t match t h e pat h n a m e specified (w h i c h


often i n c l u d e w i l d ca rd c h a ra cters).
-

To find packages that p rov i d e the /var /www / h t ml d i recto ry, use:

[ root@serverx - ] # yum provides /var/www/ html


-

Loaded plugins : langpacks


httpd - 2 . 4 . 6-17 . el7 . x86_64 : Apache HTTP Server
Re po rhel_dvd
Matched from :
-

Filename /var/www/html
-

1 : php- pear -1 . 9 . 4-21 . el7 . noarch PHP Extension and Application Repository
framework
Re po rhel_dvd
-

Matched from :
Filename /var/www/html -

I n sta l l i n g a n d re m ovi ng softwa re w i t h yum


-
• yum i n s t all PACKAGENAME o bta i n s a n d i n sta l l s a software package, i n c l u d i n g a ny
d e p e n d e n c ies.

[ root@serverX - ] # y u m install h t t pd
Loaded plugins : langpacks
-

Resolving Dependencies
- -> Running transaction check
- - -> Package httpd . x86_64 0 : 2 . 4 . 6-17 . el7 will be installed
-

- -> Processing Dependency : httpd- tools 2 . 4 . 6-17 . el7 for package :


httpd -2 . 4 . 6-17 . el7 . x86_64
=

- -> Processing Dependency : /etc/mime . types for package : httpd -2 . 4 . 6-17 . el7 . x86_64
- -> Processing Dependency : libapr-1 . so . 0( ) ( 64bit ) for package :
-

httpd -2 . 4 . 6-17 . el7 . x86_64


- -> Processing Dependency : libaprutil-1 . so . 0( ) ( 64bit ) for package :
httpd -2 . 4 . 6-17 . el7 . x86_64
- -> Running transaction check
-

- - -> Package apr . x86_64 0 : 1 . 4 . 8- 3 . el7 will be installed


- - -> Package apr- util . x86_64 0 : 1 . 5 . 2-6 . el7 will be installed
- - -> Package httpd- tools . x86_64 0 : 2 . 4 . 6-17 . el7 will be installed
-

- - -> Package mailcap . noarch 0 : 2 . 1 . 41-2 . el7 will be installed


- -> Finished Dependency Resolution
Dependencies Resolved
-

-
326 R H 1 24- R H E L7-en-1-20140606

-
-

Wo r k i n g with yum
-

Package Arch Version Repository Size


================================================================================

Installing :
httpd x86 64 2 . 4 . 6-17 . el7 rhel_dvd 1.1 M
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = == = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-

Installing for dependencies :


apr x86 64 1 . 4 . 8- 3 . el7 rhel dvd 180 k
apr -util x86_64 1 . 5 . 2-6 . el7 rhel_dvd 90 k
-

httpd- tools x86_64 2 . 4 . 6-17 . el7 rhel_dvd 76 k


mailcap noarch 2 . 1 . 41-2 . el7 rhel dvd 31 k
Transaction Summary
-

Install 1 Package ( +4 Dependent packages )


================================================================================

Total download size : 1 . 4 M


-

Installed size : 4 . 3 M
- Is this ok [y/d/N] :
• yum u p d a t e PACKAGENAME obta i n s a n d i n s ta l l s a newe r version of t h e softwa re p a c kage,
-
i n c l u d i n g a ny d e p e n d e n c ies. G e n e ra l l y the p rocess tries to p reserve confi g u ra t i o n files i n p l a ce,
but in s o m e cases, t h ey may be r e n a m e d if t h e p a c ka g e r t h i n ks the o l d one w i l l n ot work after

i [ root@serverX - ]#
t h e u pdate. W i t h n o PAC K AG E N A M E specified, it w i l l i n sta l l a l l rel eva nt u pdates.
-

������-��-------,
i
yum update
I
-

S i nce a new ke r n e l c a n o n l y be tested by boot i n g to t h a t ke r n e l , t h e package i s s pecifica l l y


d e s i g n e d s o t h a t m u l t i p l e vers i o n s m a y be i n sta l l ed a t o n ce. I f t h e n e w ke r n e l fa i l s to boot. t h e
-
o l d ke r n e l i s sti l l ava i l a b l e. U s i n g yum u pdat e k e r nel wi l l act u a l l y install t h e n e w ke r n e l . The
co nfi g u ra ti o n f i l e s hold a l ist of packages to " a l ways i n sta l l " eve n if t h e a d m i n ist rato r req u ests
a n u pdate.
-

Note
-
U s e yum list k e r n e l to l ist a l l i n st a l l e d a n d a va i l a b l e k e r n e l s . To view t h e
c u r re n t l y r u n n i n g ke r n e l , use t h e u name c o m m a n d . The - r o p t i o n w i l l s h ow o n l y
-
t h e k e r n e l v e rs i o n a n d rel ease, a n d t h e - a o pt i o n w i l l show t h e k e r n e l r e l e a s e a n d
additional information.

[ root@serverX -]# yum list ke rnel


Loaded plugins : langpacks
-

Installed Packages
kernel . x86_64 3 . 10 . 0-123 . 0 . 1 . el7 @anaconda/7 . 0
kernel . x86_64 3 . 10 . 0-84 . el7 @rhel-7- server - htb-
-

rpms
[ root@serverx -)# u n ame - r
3 . 10 . 0-123 . el7 . x86_64
[ root@serverX -]# u n ame - a
-

Linux demo . example . com 3 . 10 . 0-123 . el7 . x86_64 #1 SMP Tue Nov 26 16 : 51 : 22 EST
-
2013 x86_64 x86_64 x86 64 GNU/Linux

• y u m remove PACKAGENAME rem oves a n i n sta l l ed s oftwa re p a c k a g e , i n c l u d i n g a n y s u p po rted


packages.
-

- RH124- R H E L 7-en-1 -20140606 327

-
-

C h a pter 13. I n sta l l i n g a n d U pd a t i n g Softwa re Packages


-

[ root@serverx - ] # yum remove h t t pd


-

Warning
-
yum r emove w i l l re m ove t h e packag e(s) l isted and any package that requires the
package(s) being removed (a n d packa g e (s) w h i c h req u i re t h ose packages, a n d s o
on). T h i s can l e a d to u n ex pected remova l of packages, so c a refu l l y c h e c k t h e l ist o f -
packages to b e re m oved.

I n sta l l i n g a n d re m ov i n g g ro u ps of softwa re wit h yum


• yum a l so h a s t h e concept of groups, which a re co l l e c t i o n s of re lated softwa re i n sta l l e d toget h e r -

f o r a particu l a r p u r pose. I n R e d H a t E nterprise L i n u x 7, t h e re a re two k i n d s o f g ro u ps. Reg u l a r


g ro u ps a re co l l e ct i o n s o f packages. Environment groups a re co l l ections o f ot h e r g ro u ps w h i c h
i n c l ude t h e i r own p a c ka g es. The packages o r g ro u p s prov i d e d by a g ro u p m a y be mandatory -

( m u st be i nsta l l ed if t h e g ro u p is i n sta l l ed), default (a re n o r m a l l y i nsta l l ed if t h e g ro u p i s


i n sta l l e d ) , o r optional ( a r e n ot i n sta l l ed w h e n t h e g r o u p i s u n l ess a s k e d for s p e c i f i ca l l y) .
-

L i ke y u m lis t , t h e yum g roup list (o r yum g rouplis t ) c o m m a n d w i l l show t h e n a mes


of i n sta l l ed and ava i l a b l e g ro u ps. Some groups a re n o rm a l l y i n sta l l ed t h ro u g h e n v i ro n m e nt
g roups a n d a re h i d d e n by defa u lt. These h i d d e n g ro u p s ca n a l so be l i sted w i t h t h e yum g r o u p -

list h i d d e n com m a n d . I f t h e ids o p t i o n is a d d e d , t h e g r o u p I D wi l l a l so b e s h o w n . G ro u ps


c a n be i n sta l l e d , u pd a t e d , re moved, a n d ot h e rw i s e q u e r i e d by n a m e or I D.

[ root@serverx - ] # yum g roup list


-
.---· ·

Loaded plugins : langpacks


I

I
I
Available environment groups :
Minimal install
Infrastructure Server
File and Print Server
Web Server
-

Virtualization Host
'
-
I
Server with GUI
I
Installed groups :
I
I

Base
I Desktop Debugging and Performance Tools
-

Dial-up Networking Support


I FontsInput Methods
I
-

Internet Browser
PostgreSQL Database server
Printing client
I X Window System
-

Available Groups :
Additional Development
Backup Client
Backup Server
I -
I

!
I
I
L..,___ -

• I nform at i o n a bout a g ro u p i s d i s p l ayed with yum g ro u p info (o r yum g ro u pinfo). I t


i n c l udes a l i st o f m a n d atory, defa u lt, a n d o pt i o n a l p a c k a g e n a mes or g ro u p I Ds. T h e p a c ka g e -
n a mes o r g ro u p I Ds m a y h ave a m a rker i n f r o n t of t h e m .

328 RH124- R H E L 7-en-1-20140606 -

-
-

Wo r k i n g w i t h yum
-

M a rker M ea n i n g

-
= Pa c k a g e is i n sta l l e d , was i n sta l l ed as part of t h e group
+ Pa c k a g e i s n ' t i n sta l l e d , wi l l be if t h e g ro u p is i nsta l l ed o r u pdated

-
- Pa c k a g e i s n ' t i n sta l l e d , w i l l not be if t h e g r o u p is i nsta l l ed o r u pdated
no marker Pac k a g e is i n sta l l e d , b u t was n ot i n sta l l e d t h ro u g h t h e g ro u p .

[ root@serverX - ] # yum group info " Identity Management serve r "


-

Loaded plugins : langpacks


Group : Identity Management Server
Group - Id : identity-management - server
-

Description : centralized management of users, servers and authentication policies .


Default Packages :
+389-ds- base
-

+ipa-admintools
+ipa- server
+pki-ca
Optional Packages :
-

+ipa- server-trust -ad


+nuxwdog
+slapi-nis
-

___ I

- • The yum g r o u p i n s t all (or yum g ro u p i n s t all) co m m a n d w i l l i n sta l l a g ro u p w h i c h w i l l


i n sta l l its m a n d atory a n d defa u l t packages a n d t h e packages they d e p e n d on.

-
[ root@serverX - ] # y u m g r o u p i n s t all " I nfiniband Suppo r t "

Transaction Summary
Install 17 Packages (+7 Dependent packages )
= = = = = = = = = =============== = = = = = = = = = = = = = = = == ========== = = = = = = = = = = = = = = ==== = = = = = = = ====
-

Total download size : 9 . 8 M


Installed size : 33 M
Is this ok [y/d/N] :
-

'
-��- ------j
-

- R H124- R H E L 7-en-1-20140606 329

-
-

C h a pter 1 3. I n sta l l i n g a n d U pd a t i n g Softwa re Pa ckages


-

Important -

T h e b e h a v i o r of yum g ro u ps h a s c h a n g e d i n Red Hat Enterprise L i n u x 7 from Red


H a t E n t e r p rise L i n u x 6 and e a r l i e r. In R H E L 7, g roups a re t reated a s objects, and a re -
t ra c ked by t h e system. I f a n i nsta l l e d g r o u p is u pdated, a n d n ew m a n d atory o r defa u lt
packages have been added to t h e g ro u p by t h e yum re pository, t hose new packages w i l l
be i n sta l l e d o n u p d ate. -

R H E L 6 a n d ea r l i e r c o n s i d e r a g ro u p to be i n sta l l ed if a l l its m a n d atory packages have


b e e n i nsta l l ed; or if it h a d no m a n d atory p a c kages, if a n y defa u l t o r o p t i o n a l packages
i n the group a re i n sta l l e d . In R H E L 7, a g ro u p i s c o n s i d e re d to be i n sta l l ed only if yum
g r o u p i n s t all was used to i n sta l l it. A new com m a n d i n R H E L 7, yum group mark
ins t all GROUPNAME can b e u s e d t o mark a g ro u p a s i n st a l l e d , and a ny m i s s i n g -

p a c k a g e s a n d t h e i r d e p e n d e n c i e s w i l l be i n sta l l ed o n t h e n ext u p d a te.

Fi n a l l y, R H E L 6 a n d e a r l i e r d i d n ot h a ve the two-word form of the yum g ro u p


co m m a nds. I n ot h e r w o r d s , i n R H E L 6 t h e com m a n d yum g rouplist existed, but t h e
e q u iva l e n t R H E L 7 co m m a n d yum g ro u p list d i d n ot.
-

V i ew i n g t ra n sact i o n h i st o ry
• A l l i nsta l l a n d remove t ra n s a c t i o n s a re l og g e d i n /var /log/yum . log.

[ root@serverX - ] # t ail - 5 /var/log/yum . log


r---

Feb 16 14 : 10 : 41 Installed : libnes -1 . 1 . 3-5 . el7 . x86_64


!

Feb 16 14 : 10 : 42 Installed : libmthca-1 . 0 . 6-10 . el7 . x86 64


-

Feb 16 14 : 10 : 43 Installed : libmlx4-1 . 0 . 5- 7 . el7 . x86 64


Feb 16 14 : 10 : 43 Installed : libibcm-1 . 0 . 5- 8 . el7 . x86 64
-

Feb 16 14 : 10 : 45 Installed : rdma-7 . 0_3 . 13 rc8-3 . el7 . noarch


-

-
-

• A s u m m a ry of i n sta l l a n d re m ove t ra ns a c t i o n s c a n be viewed with yum h i s t ory. -

[ root@serverX - ] # yum history


Loaded plugins : langpacks
ID I Login user Date and time Action ( s ) Altered
-

I I I

6 I Student User <student> 2014-02-16 14 : 09 Install 25


5 I Student User <student> 2014-02-16 14 : 01 Install 1
4 I System <unset> 2014-02-08 22 : 33 Install 1112 EE
-

3 I System <unset> 2013-12-16 13 : 13 Erase 4


2 I System <unset> 2013-12-16 13 : 13 Erase 1
1 I System <unset> 2013-12-16 13 : 08 Install 266
history list
-

• A transaction can b e reve rsed w i t h the h i s t o r y undo options:

[ root@serverX - ] # yum history u n d o 6


Loaded plugins : langpacks
-

Undoing transaction 6, from Sun Feb 16 14 : 09 : 51 2014


Install dapl-2 . 0 . 39-2 . el7 . x86_64 @rhel-7- server-htb- rpms
Dep- Install graphviz-2 . 30 . 1-18 . el7 . x86_64 @rhel-7- server-htb- rpms
Dep- Install graphviz-tcl-2 . 30 . 1-18 . el7 . x86_64 @rhel-7- server-htb- rpms
-

Install ibacm-1 . 0 . 8-4 . el7 . x86_64 @rhel-7- server-htb- rpms


Install ibutils - 1 . 5 . 7 -9 . el7 . x86 64 @rhel-7-server-htb- rpms -

-
330 R H 1 24- R H E L7-en-1-20140606

-
-

S u m m a ry of yum com m a n d s

Dep- Install ibutils-libs -1 . 5 . 7 -9 . el7 . x86_64 @rhel-7-server-htb- rpms


-

-----

Su m mary of yum com mands


- i_

-
Pa ckages c a n be l o cated, i nsta l l e d , u pdated, and removed by n a m e o r by package g ro u ps.

Ta sk: Co m m a nd :
-
List i n sta l l ed a n d ava i l a b l e packages b y n a m e yum list [ NAME - PATTERN ]
List i n sta l l ed a n d a va i l a b l e g ro u p s y u m g r o u plist
-
Search for a package by keyword yum s e a r c h KEYWORD
S h ow deta i l s of a p a c k a g e y u m info PACKAGENAME
-
I nsta l l a package yum i n s t all PACKAGENAME
I nsta l l a package g ro u p yum g rou pinst all " GROUPNAM E "
- Update a l l packages yum update
Remove a package yum r emove PACKAGE NAME
- D i s p l ay t ra n sact i o n h i story yum h i s t o ry

- R References
yum(1 ) a n d yum . conf(5) m a n pages

-
A d d i t io n a l i nfo r m a t i o n o n yum may b e a va i l a b l e in the Red Hat Enterprise Linux System
Administrator's Guide fo r Red Hat E n t e r p r i s e L i n u x 7, w h i c h can be fo u n d a t
http://d o c s . r e d hat.com/
-

- R H1 24- R H E L 7-en-1-20140606 331

-
-

C h a pter 13. I n sta l l i n g a n d U pd a t i n g Software Pa c k a g e s


-

P ract i ce: I nsta l l i n g a n d U pd a t i n g Softwa re w i t h


yum
-

Guided exercise
-
I n t h i s l a b , you w i l l i n sta l l a n d remove packages a n d p a c ka g e g ro u p s .

O u t c o mes:
-
E x p l o re i n sta l l i n g and re m ov i n g packages with d e p e n d e n cies.

Before you begin ...


Reset yo u r serverX syst e m . -

D 1. Searc h f o r a s pecific package.


-
D 1 .1 . Attempt t o r u n t h e com m a n d g n u plo t . Yo u s h o u l d find t h a t it is n o t i n sta l l ed.

[ root@serverX - ] # gnuplot
bash : gnuplot : command not found . . .
-

D 1.2. S e a rc h for p l ott i n g packages. -

[ root@serverX - ] # y u m s e a r c h plot
Loaded plugins : langpacks
N/S matched : plot
-

emacs-gnuplot . noarch : Emacs bindings for the gnuplot main application


==== =================== ============= == ========

gnuplot . x86_64 : A program for plotting mathematical expressions and data


gnuplot -common . x86_64 : The common gnuplot parts
python-matplotlib . x86_64 : Python 20 plotting library
-

texlive-pst - plot . noarch : Plot data using PSTricks


Name and summary matches only, use "search all" for everything .
-

D 1.3. F i n d o u t m o re info r m a t i o n a bo u t t h e g n uplot package. -

[ root@serverx - ] # yum
Name gnuplot
info gnuplot

Arch x86_64
-

D 2. I n sta l l t h e g n u plot p a c ka g e.

[ root@serverX - ] # yum i n s t all - y gnuplot


-

Dependencies Resolved
Package Arch Version Repository Size
-
= = = = = = = = = = == = = = = = = = = = = = = = = = == = = = = = = = = = = = = = = = = = = = = = = = = = = = = = == = = = = = = = = = = = = = = = = =

Installing :
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = == = = = ==

gnuplot x86_64 4 . 6 . 2- 3 . el7 rhel_dvd 645 k


-

Installing for dependencies :


gnuplot -common x86_64 4 . 6 . 2-3 . el7 rhel_dvd 595 k -

332 R H1 24- R H EL 7-en-1-20140606 -

-
-

G u i d e d exercise
-

Transaction summary
Install 1 Package (+1 Dependent package )
=============================================================================
-

D 3. R e m ove packages.

-
D 3.1 . Attempt to re m ove t h e gnu plot packa g e, b u t s a y n o. H ow m a ny packages wou l d
be re moved?

[ root@serverx - ] # yum
l
remove gnuplot

Removing :
-

gnuplot x86_64 4 . 6 . 2-3 . el7 @rhel_dvd 1.5 M


Transaction Summary
-

=======================================================================

Remove 1 Package

Installed size : 1 . 5 M
-

Is this ok [y/N] : n
-

D 3.2. Atte m pt to re m ove t h e gnu plot - common package, but say no. How m a n y
-
p a c k a g e s wo u l d b e removed?

[root@serverx - ] # yum remove gnuplot - common

Removing :
gnuplot -common x86_64 4 . 6 . 2-3 . el7 @rhel_dvd 1.4 M
-

Removing for dependencies :


- gnuplot x86_64 4 . 6 . 2 -3 . el7 @rhel_dvd 1.5 M
Transaction Summary
========================================================================
-
Remove 1 Package (+1 Dependent package)

Installed size : 2 . 9 M
Is this ok [y/N] : n
-

- D 4. G a t h e r i nfo r m a t i o n a bo u t the " C o m p at i b i l ity L i b ra ri e s " c o m p o n e n t group and i n sta l l it on


s e rverX.

- D 4.1 . List a l l a va i l a b l e c o m p o n e n t g ro u ps.

I [ root@serverX - ] #
I
yum g rouplist
-

D 4.2. F i n d out more i n fo r m a t i o n a bout t h e Compatibility Libraries com p o n e n t g ro u p,


-
i n c l u d i n g a l ist of i n c l u d ed packages.

[ root@serverx - ] # yum g roupinfo

l
Loaded plugins : langpacks
" Compatibility Libraries "

Group : Compatibility Libraries


-

Group- Id : compat -libraries


-

- R H 1 24- R H E L7-en-1-20140606 333

-
-

C h a pter 1 3. I n sta l l i n g a n d U pd a t i n g Software Packages

Description : Compatibility libraries for applications built on previous


-

versions of Red Hat Enterprise Linux .


Mandatory Packages :
+compat -db47
-

+compat -glibc
+compat -libcap1
+compat -libf2c- 34
+compat -libgfortran-41
-.

+compat -libtiff3
+compat -openldap
+libpng12
+openssl098e
-

D 4.3. I n sta l l the Compatibility Libraries c o m p o n e n t g ro u p.

[root@serverX - ] # yum g roupin s t all " Compatibility Libraries "


Loaded plugins : langpacks
-

Resolving Dependencies
- -> Running transaction check
- - -> Package compat -db47 . x86_64 0 : 4 . 7 . 25-27 . el7 will be installed
- -> Processing Dependency : compat -db-headers 4 . 7 . 25-27 . el7 for package :
-

compat -db47-4 . 7 . 25-27 . el7 . x86_64


=

Dependencies Resolved -

Package Arch Version Repository -

Installing for group install "Compatibility Libraries" :


compat -db47 x86_64 4 . 7 . 25-27 . el7 rhel_dvd
libpng12 x86_64 1 . 2 . 50 - 6 . el7 rhel_dvd -

Installing for dependencies :


compat -db- headers noarch 4 . 7 . 25-27 . el7 rhel_dvd -

Transaction Summary
Install 9 Packages {+3 Dependent packages )
-

Total download size : 5 . 5 M


Installed size : 21 M
, Is this ok [y/d/N] : y
-

Installed :
compat -db47 . x86_64 0 : 4 . 7 . 25-27 . el7
compat - glibc . x86_64 1 : 2 . 12-4 . el7
-

Dependency Installed :
-

compat -db-headers . noarch 0 : 4 . 7 . 25-27 . el7


compat -glibc- headers . x86_64 1 : 2 . 12-4 . el7 -

Complete !
-

D 5. E x p l o re the h i story and u n d o o p t i o n s of yum.

-
D 5.1 . D i s p l ay recent y u m h i sto ry.

[ root@serverX - ] # yum history


-

334 R H 1 24- R H E L7-en-1-20140606 -

-
-

G u i d e d exerc ise

Loaded plugins : langpacks


-

ID I Login user I Date and time I Action ( s ) I Altered


3 root <root> 2014-06-05 09 : 33 Install 12
2 I root <root> 2014-06-05 09 : 30 Install 2
-

1 I System <unset> 2014-06-02 20 : 27 Install 1112 EE


- history list
D 5.2. Confirm t h a t t h e l a st t ra a n s a c t i o n i s t h e g ro u p insta l l a t i o n .
-

[ root@serverx - ] # yum hi st o r y info 3


Loaded plugins : langpacks
Transaction ID 3
Begin time Thu Jun 5 09 : 33 : 19 2014
-

Begin rpmdb 1210 : 7c6b529424621773d5fe147315a53d55Bf726814


End time 09 : 33 : 40 2014 ( 21 seconds )
End rpmdb 1222 : c283bc776b18b9578b87cdec68853f49b31ca0cc
User root <root>
-

Return-Code Success
Command Line groupinstall Compatibility Libraries
Transaction performed with :
-

Installed rpm-4 . 11 . 1-16 . el7 . x86_64 installed


Installed yum- 3 . 4 . 3-117 . el7 . noarch installed
Packages Altered :
Dep- Install compat -db- headers -4 . 7 . 25-27 . el7 . noarch @rhel_dvd
-

Install compat -db47-4 . 7 . 25-27 . el7 . x86_64 @rhel_dvd


history info
-

- D 5.3. Use u n d o opt i o n s to remove the l a st set of p a c kages i n sta l l ed.

[ root@serverx - ] # y u m hi st o r y u n d o 3
-

- R H 1 24- R H E L 7-en-1 -20140606 335

-
-

C h a pter 13. I n sta l l i n g a n d U pd a t i n g Softwa re Packages


-

E n a b l i n g yum Softwa re Re posito ries -

Objectives -

After com p l e t i n g t h i s section, stu dents s h o u l d be a b l e to e n a b l e a n d d i s a b l e t h e u s e of Red Hat


o r t h i rd-pa rty yum re posito r i es.
-

Enabling Red Hat software re positories


Regi steri n g a system to t h e s u bscription m a n a g e m e nt service automatica l l y confi g u res a ccess to -

softwa re re positories based o n the attached s u bs c r i p t i o n s. To view a l l ava i l a b l e re positories:

[ root@serverX - ] # yum repolist


Loaded plugins : langpacks
all

repo id repo name status


-

rhel-7- public-beta-debug- rpms Red Hat Enterprise Linux 7 Public disabled


rhel-7-public- beta- rpms Red Hat Enterprise Linux 7 Public enabled : 8, 520
rhel-7- public-beta- source- rpms Red Hat Enterprise Linux 7 Public disabled
I repolist : 8, 520
L__ _ _ _
-

E n a b l e and d i sa b l e repositories with yum - config - manag e r . This w i l l c h a n g e the enabled

-
I [ root @serverX - ] # yum - config - manager - - e�able rhel -� - pu b;ic - be t a - debu g - rpms
parameter i n the /et c /yum . repos . d / redhat . repo f i l e.
-

1 =� =� : � �=� : =: =� =::: � ��� o : rhel-7-public- beta-debug - rpms


- - -��---

a
I [ rhel-7-public- beta-debug- rpms]
= = ======================

j async True
,i·_ bandwidth 0
=

I base_persistdir /var/lib/yum/repos/x86_64/7Server
baseurl https : //cdn . redhat . com/content/beta/rhel/everything/7/x86_64/debug
=

= -

cache 0
=

cachedir /var/cache/yum/x86_64/7Server/rhel-7-public-beta-debug- rpms


=

cost 1000
=

deltarpm_percentage
-
=

enabled 1 =

Enabling third - party software re positories -

T h i rd-pa rty re positories a re d i rectories of softwa re package f i l e s p rov i d e d by a n o n - R e d H a t


sou rce, w h i c h c a n be a ccessed b y y u m f r o m a website, FTP s e rver, o r loca l fi l e syst e m . Yu m
re positories a re u sed by n o n - Red H a t d i st r i b utors of softwa re, or for s m a l l co l l ec t i o n s of l o ca l -

packages. ( Fo r exa m p l e, A d o b e prov ides some o f its free softwa re for L i n u x t h ro u g h a y u m


re pository.) T h e con t e n t . example . com c l a ssroom server actua l l y hosts y u m repositories for
t h i s c l ass. -

Put a file i n the / e t c /yum . repos . d / d i rectory to e n a b l e s u pport for a new t h i rd-pa rty
reposito ry. Repository confi g u ration f i l e s m u st end in . repo. The re pository d e f i n i t i o n conta i n s -

t h e U R L o f t h e re posito ry, a n a me, w h e t h e r to u s e G P G to c h e c k t h e p a c k a g e s i g n a t u res, a n d i f


s o , t h e U R L p o i n t i n g to t h e t r u sted G P G key.
-
Using yum - config - manag e r
I f t h e U R L f o r a y u m repository i s k n o w n , a confi g u ra t i o n fi l e c a n be created w i t h yum - config ­
manag e r . -

-
336 RH124- R H E L7-en-1-20140606

-
-

E n a b l i n g t h i rd-pa rty softwa re repos itories


-

[ root@serverX -]# yum - config - manager - - add - repo= " h t t p : //dl . fedoraproj ect . o r g/pub/epel/
Loaded plugins : langpacks
beta/7/x86_64/ "

adding repo from : http : //dl . fedoraproj ect . org/pub/epel/beta/7/x86_64/


-

[dl . fedoraproj ect . org_pub_epel_beta_7_x86_64_]


name=added from : http : //dl . fedoraproj ect . org/pub/epel/beta/7/x86_64/
baseurl=http : //dl . fedoraproj ect . org/pub/epel/beta/7/x86_64/
-

-
enabled=1
A f i l e was c reated i n t h e /et c /yu m . repos . d d i rectory w i t h t h e o u t p u t shown. T h i s f i l e c a n
-
n ow b e m o d ified to provide a c u s t o m i zed n a m e a n d t h e l o c a t i o n o f t h e GPG key. A d m i n ist rators
s h o u l d d ow n l oad the key to a loca l fi l e rat h e r than a l l ow i n g yum to ret rieve t h e key from a n
exte r n a l sou rce.

[EPEL]
-

name=EPEL 7 Beta
baseurl=http : //dl . fedoraproj ect . org/pub/epel/beta/7/x86_64/
enabled=1
gpgcheck=1
-

gpgkey=file : ///etc/pki/rpm-gpg/RPM-GPG- KEY-EPEL-7


-

R P M c o n fi g u ra t i o n p a c k a g e for t h e re pository
Some re pos itories p rov i d e t h is config u ra t i o n f i l e and GPG p u b l ic key a s pa rt of a n RPM pa c k a g e
-
t h a t c a n be down loaded a n d i n sta l l ed u s i n g yum local i n s t all. O n e exa m p l e of t h i s is t h e
vo l u nteer p roject E P E L ( E xtra Pa c k a g es f o r Enterprise L i n u x) , w h i c h p rovides softwa re not
s u ppo rted by Red H a t but co m pat i b l e with Red H a t Enterprise L i n u x .
-

I n sta l l i n g t h e R e d H a t Enterprise L i n u x 7 E P E L repo p a c k a g e :

[ root@serverX -]#
[ root@serverX - ] #
-
r p m - - impor t h t t p : //dl . fedoraproj e c t . o r g/pub/epel/RPM - GPG - KEY - EPEL - 7
yum install h t t p : //dl . fedoraproj ect . o r g/pu b/epel/beta/7/x86_64/epe l ­
release - 7 - 0 . 1 . noarch . rpm
-

Confi g u ra t i o n fi l es often l i st m u l t i p l e repository refere nces in a s i n g l e f i l e . Each re pository


refere nce b e g i n s with a s i n g l e-word n a m e i n s q u a re b ra c kets.
-

[ root@serverX -]# cat /etc/yum . repos . d/epel . repo


[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http : //download . fedoraproject . org/pub/epel/7/$basearch
-

mirrorlist=https : //mirrors . fedoraproject . org/metalink?repo=epel- 7&arch=$basearch


failovermethod=priority
enabled=1
gpgcheck=8
-

gpgkey=file : ///etc/pki/rpm- gpg/RPM-GPG-KEY- EPEL-7


[epel-debuginfo]
-

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug


#baseurl=http : //download . fedoraproj ect . org/pub/epel/7/$basearch/debug
mirrorlist=https : //mirrors . fedoraproj ect . org/metalink?repo=epel-debug -7&arch=$basearch
failovermethod=priority
-

enabled=8
gpgkey=file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
-

-
[epel- source]

- R H 1 24- R H E L 7-en-1 -20140606 337

-
-

C h a pte r 1 3. I n sta l l i ng a n d U pd a t i n g Softwa re Pa ckages

name=Extra Packages for Enterprise Linux 7 - $basearch - Source


-

#baseurl=http : //download . fedoraproj ect . org/pub/epel/7/SRPMS


mirrorlist=https : //mirrors . fedoraproj ect . org/metalink?repo=epel- source-7&arch=$basearch
failovermethod=priority
-

enabled=0
gpgkey=file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL- 7
gpgcheck=l -

T h e enabled=a para m eter c a n be i n c l u d e d so t h a t a repository i s d e f i n e d b u t not searc h e d by


-
defa u lt. Repositories can be e n a b l e d a n d d i s a b l e d persiste n t l y w i t h yum - config - manag e r or
t e m p o ra r i l y w i t h - - e nabl e r epo=PA TTERN and - - disable r e p o=PA TTERN options o n yum.
-

Warning
I nsta l l t h e R P M G P G key before i n st a l l i n g s i g n ed packages. T h i s w i l l verify t h a t t h e -
packages b e l o n g to a k e y w h i c h h a s been i m ported. O t h e rw i se, y u m w i l l com p l a i n
a bo u t t h e m i s s i n g key. ( T h e - - no g p g c h e c k option c a n b e u s e d to i g n o re m i s s i n g G P G
keys, b u t t h i s cou l d c a u s e forg e d o r i n se c u re packages to b e i n sta l l ed o n t h e system , -

potent ia l l y com p ro m i s i n g i t s secu r ity. )

R References
A d d it i o n a l i nfo r m a t i o n may b e a va i l a b l e i n t h e section o n config u ri n g y u m a n d y u m -

repositories i n t h e Red Hat Enterprise Linux System Administrator's Guide f o r R e d H a t


Enterprise L i n u x 7, w h i c h can b e fo u n d a t
http://docs.re d h at.com/ -

yum(1 ) , yum . conf(5), and yum - config - manag e r (1 ) man pages


-

338 R H1 24-R H E L 7-en-1-20140606 -

-
-

Practice: E n a b l i n g Softwa re Repositories


-

P ra ct i ce: E n a b l i n g S oftwa re Repos ito r i es


-

-
Guide d exercise
I n t h i s l a b, yo u w i l l config u re yo u r se rver to u s e a sepa rate yum re pository to o bta i n u pdates, a n d
-
u pdate yo u r m a c h i n e.

Outcomes:

-
The syst e m w i l l b e confi g u red to obta i n softwa re u p dates from a c l a ssroom server and t h e
system w i l l b e r u n n i n g t h e l a test L i n u x ke r n e l .

Before you begin ...


-
Reset yo u r s e rverX syste m .

D 1. Conf i g u re t h e system t o o bta i n softwa re from two c l a ss room repositories:


-

• C l a ss roo m p a c kages provided a t http://conte nt.exa m p l e.com/r h e l7.0/x8 6_64/rht

- • U pdates p rovided at http://content.ex a m p l e.com/r h e l7.0/x 86_64/e r rata

D 1 .1 . U s e yum - config - manag e r to a d d t h e c l a ss room packages reposito ry.

[ root@serverx -]#
-

yum - config - manager - - add - repo= " ht t p : //

Loaded plugins : langpacks


content . example . com/rhel7 . G/x86_64/ rht "

adding repo from : http : //content . example . com/rhel7 . 0/x86_64/rht


[content . example . com_rhel7 . 0_x86_64_rht]
name=added from : http : //content . example . com/rhel7 . 0/x86_64/rht
baseurl=http : //content . example . com/rhel7 . 0/x86_64/rht
enabled=l
-

D 1 . 2 . C reate t h e f i l e / e t c /yum . repos . d / e r r a t a . repo to e n a b l e t h e " U pdates"


re pository with t h e fo l l owi n g content:

[updates]
-

name=Red Hat Updates


baseurl = http : //content . example . com/rhel7 . 0/x86_64/errata
enabled=l
gpgcheck=0
-

D 2. U s e yum - config - manag e r to d i sa b l e t h e c l a s s room packages reposito ry.

- [ root@serverX -]# yum - config - manager - - disable


Loaded plugins : langpacks
content . example . com_rhel7 . G_x86_64_rht

================= repo : content . example . com_rhel7 . 0_x86_64_rht =================


-
[content . example . com_rhel7 . 0_x86_64_rht]
enabled = 0
-

D 3. U pdate a l l rel eva nt softwa re p rovi d e d u s i n g yum u pdate.


-

- R H1 24- R H E L 7-e n-1-20140606 339

-
-

C h a pt e r 1 3 . I n sta l l i n g a n d U pd a t i n g Softwa re Pa c k a g e s

[ root@serverX
-

- ] # yum update - y

D 4. Ve rify t h a t t h e re a re two vers i o n s of the ke r n e l i nsta l l e d . W h i c h vers i o n is c u r re n t l y i n


use?

[ root@serverx
-

- ] # yum list kernel

[ root@serverX - ] # uname - r

D 5. Reboot your serverX, then repeat the p rev i o u s step. W h i c h vers i o n i s c u rrent l y in use?

[ root@serverX
-

- ] # yum list kernel

[ root@serverX - ] # u name - r -

D 6. L i st, t h e n i n sta l l , the r h t - sys tem package.

[ root@serverX - ] # yum list rht *


Loaded plugins : langpacks
Available Packages
rht - system . noarch 1 . 0 . 0- 2 . el7 updates
-

[ root@serverX - ] # yum - y i n s t all


Loaded plugins : langpacks
r h t - system

Resolving Dependencies
-

340 R H1 24- R H E L 7 - e n -1-20140606 -

-
-

E xa m i n i n g R P M Pac k a g e F i l es
-

Exa m i n i n g R P M Pa c ka g e F i l es
-

Objectives
After c o m p l et i n g t h i s sectio n , s t u d e nts s h o u l d be a b l e to exa m i n e a n d i n sta l l down l oa d e d
p a c ka g e f i l es.
-

E xamining downloaded packages wit h r p m


The r p m u t i l ity i s a l ow - l evel t o o l t h a t can get i nfo r m a t i o n a bout t h e contents o f p a c ka g e
-
f i l e s a n d i n sta l l ed packages. I t g ets its info r m a t i o n f r o m a l o c a l data b a se o r t h e p a c k a g e f i l e s
t h e m s e l ves.

The g e n e ra l form of a q u e ry is:

• rpm - q [ selec t - o p t io n s ] [ q u e ry - opt ions ]


-
• rpm - - q u e ry [ selec t - o p t io n s ] [ q u e r y - opt ion s ]

R P M q u e ries: S e l ect o p t i o n s
-
• - q - a: a l l i n sta l l e d packages

• -q PACKA GENAME: c u r re n t l y i n sta l l ed PAC K AG E N A M E


-

[ root@serverx - ] # rpm -q
yum-3 . 4 . 3-118 . el7 . noarch
yum
-

• -q - p PACKAGEFILE . rpm: p a c k a g e f i l e n a med PAC K A G E F I L E . r p m

( root@serverx -q
-

- ] # rpm - p h t t p : //content . example . com/rhel7 . 0/x86_64/dvd/Packages/

yum-utils-1 . 1 . 31-24 . el? . noarch . rpm


yum - u tils - 1 . 1 . 31 - 24 . el7 . noarc h . rpm
-

• -q -f FIL ENAME: w h a t p a c k a g e p rovides F I L E N A M E

[ root@serverX - ] # rpm -q
-

yum-3 . 4 . 3-118 . el? . noarch


- f / e t c /yum/repos . d

-
R P M q u e ries: I nfo r m a t i o n a bo u t content of p a c ka g es
• - q: l i sts t h e package's n a m e a n d vers i o n ; c o m p a re to yum list

• -q - i: package i nfor m a t i o n ; c o m p a re to yum info


-

• -q - 1: l ist of f i l es i n sta l l ed by the specified package

( root@serverx - ] # r p m -q yum - rh n - plugin


/etc/yum/pluginconf . d/rhnplugin . conf
-
-1

/usr/share/doc/yum- rhn -plugin - 2 . 0 . 1


/usr/share/doc/yum- rhn- plugin - 2 . 0 . 1/LICENSE
/usr/share/locale/aln/LC_MESSAGES/yum- rhn-plugin . mo
-

- R H124- R H E L 7-en-1 -20140606 341

-
-

C h a pte r 1 3. I n sta l l i n g a n d U pd a t i n g S oftware Packages


-

· - q - c: l i st j u st t h e confi g u ra t i o n fi l es

[ root@serverx -]# rpm -q - c yum - r h n - plugin


/etc/yum/pluginconf . d/rhnplugin . conf
-

· - q - d: l ist j u st the docu m e n t a t i o n f i l e s

[ root@serverX -]# r p m -q - d yum - rh n - plugin


/usr/share/doc/yum- rhn-plugin -2 . 8 . 1/LICENSE
/usr/share/man/man5/rhnplugin . conf . 5 . gz
/usr/share/man/man8/rhnplugin . 8 . gz
/usr/share/man/man8/yum- rhn- plugin . 8 . gz -

· - q - - sc r i p t s : l ist s h e l l scripts t h a t may r u n before or after t h e package is i n sta l l e d o r -

re m oved

[ root@serverX -]# rpm -q - - s c r i p t s open s s h - server


preinstall scriptlet (using /bin/sh ) :
getent group sshd >/dev/null I I groupadd -g 74 - r sshd I I
getent passwd sshd >/dev/null I I \
useradd -c "Privilege- separated SSH" -u 74 -g sshd \
-s /sbin/nologin - r -d /var/empty/sshd sshd 2> /dev/null I I
postinstall scriptlet ( using /bin/sh ) :
if [ $1 -eq 1 ] ; then
# Initial installation
/usr/bin/systemctl preset sshd . service sshd . socket >/dev/null 2>&1 I I
fi
preuninstall scriptlet ( using /bin/sh ) :
-

if [ $1 -eq 8 ] ; then
# Package removal, not upgrade
/usr/bin/systemctl - - no- reload disable sshd . service sshd . socket > /dev/null
-

2>&1 1 1 :
/usr/bin/systemctl stop sshd . service sshd . socket > /dev/null 2>&1 I I :
fi
postuninstall scriptlet ( using /bin/sh ) :
-

/usr/bin/systemctl daemon - reload >/dev/null 2>&1 I I


if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
/usr/bin/systemctl try- restart sshd . service >/dev/null 2>&1 I I
fi -

· - q - - c hangelog: l ist c h a n g e information for t h e package -

[ root@serverX -]# r p m -q - - c hangelog audit


Thu Oct 83 2813 Steve Grubb <sgrubb@redhat . com> 2 . 3 . 2-3
resolves : #828495 - semanage port should generate an audit event
*

* Thu Aug 29 2813 Steve Grubb <sgrubb@redhat . com> 2 . 3 . 2-2


resolves : #991856 - ausearch ignores USER events with - ua option -

I [ root@serverX -]#
Querying a nd i nsta l l i n g package f i l es :

wget h t t p : //class room/pub/mate r ials/wonde rwidge t s - 1 . 0 - 4 . x86_64 . rpm

-
342 R H 1 24- R H E L7-en-1-20140606
-

U s i n g yum to i n sta l l loca l package f i l es

[ root@serverX - ] # rpm -q - p wonde rwidget s - 1 . 0 - 4 . x86_64 . rpm


-

/etc/wonderwidgets . conf
-1

/usr/bin/wonderwidgets
/usr/share/doc/wonderwidgets-1 . 0
/usr/share/doc/wonderwidgets - 1 . 0/README . txt
-

Note
- T h e repoq u e ry c o m m a n d c a n a l so be u s e d to get i nformat i o n a bo u t packages a n d
t h e i r contents. I t d i ffers from r p m by l o o k i n g u p t h a t i nfo r m a t i o n i n y u m ' s re positories
i n stead of t h e loca l database of i n sta l l e d p a c kages.
-

-
Using yum to install local package files
yum local i n s t all PACKAGEFIL E . rpm c a n b e used to i n sta l l p a c ka g e f i l es d i rect l y.
I t au t o m a ti ca l l y d ow n l oa d s a n y d e p e n d e n c i e s t h e package has from a ny confi g u red yum
- repos itories. Packages a re no r m a l l y d i g ita l l y s i g n e d to e n s u re they a re l e g i t i m a te ; i f the package
is not s i g n ed by a key t r u sted by yo u r syst e m , it w i l l be rejected. T h e - - nogpg c h e c k o pt i o n c a n
d i sa b l e t h e s i g n a t u re c h e c k if you a re certa i n t h e p a c k a g e i s l e g it i m ate if a pa c k a g e is i n sta l l ed
- with yum i n s t all In Red H a t Enterprise L i n u x 7 the - - nogpgcheck option is not req u i red if a
package is i n sta l l e d w i t h yum localins t all

-
[ root@serverX - ] # yum localinst all wonde rwidget s - 1 . 0 - 4 . x86_64 . r pm
[ root@serverX - ] # rpm -q wonde rwidgets
- , wonderwidgets- 1 . 0-4 . x86_64
L

-
Note
r pm - ivh PA CKAGEFIL E . rpm can a l s o be used to i nsta l l package f i l es. H oweve r,
u s i n g yum h e l ps m a i n ta i n a t ra ns a ct i o n h istory kept by yum (see yum his t o ry).

- Warning
Be ca ref u l w h e n i n sta l l i n g packages from t h i rd pa rties, not j u st beca u se of t h e softwa re
t h a t t h ey may i n sta l l , but beca u s e t h e R P M may r u n a r b i t ra ry s c r i pts a s root as pa rt of
-
t h e i n sta l la t i o n p rocess.

E xtracting files from R PM packages


F i l e s i n t h e R P M package can be extracted w i t h o u t i n sta l l i n g t h e package u s i n g c pio, a n
-
a rch i v i n g tool l i ke z i p o r t a r . P i p e t h e o u t p u t o f rpm2cpio PACKAG E F I L E . r pm i nto cpio -
id, a n d it w i l l extract a l l t h e f i l es stored i n t h e R P M package. S u b d i rectory t rees w i l l be c reated
a s needed, re l a t ive to the cu rrent w o r k i n g d i recto ry.

S e l ect f i l es c a n a l so be extracted by specify i n g t h e path of t h e f i l e :

[ root@serverx
11 blocks
-
- ] # rpm2cpio wonderwidget s - 1 . 0 - 4 . x8 6_64 . r pm I c pio - id " * tx t "

[ root@serverx - ] # ls -1 u s r/share/doc/wonde rwidge t s - 1 . 0/


-

- R H 1 24- R H E L 7 -en -1-20140606 343

-
-

C h a pt e r 1 3 . I n sta l l i ng a n d U pd a t i n g Softwa re Packages

total 4
- rw- r- - r - - . 1 root root 76 Feb 13 19 : 27 README . txt

Summary of r pm query commands


_J
__

I nsta l l ed packages c a n b e q u e ried d i rect l y with r p m c o m m a n d . A d d a - p o p t i o n t o q u e ry a


package f i l e before i n sta l l a t i o n .

Ta sk: Command:
D i s p l a y i nfo r m a t i o n a bo u t a package r pm - q - i NAME
L i st a l l f i l e s i n c l u d e d i n a package r pm - q -1 NAME
L i st confi g u ra t i o n f i l es i n c l uded in a package r pm - q - c NAME
List doc u m e ntation f i l e s i n c l uded i n a package r p m - q - d NAME
S h ow a s h o r t s u m m a ry of t h e reason for a r pm - q - - changelog NAME
new package re l e a s e
D i s p l a y t h e s h e l l s c r i pts i n c l uded i n a package r pm - q - - s c r i p t s NAME

R References
yum(8), r pm(8), repoque ry(1 ) , r pm2cpio(8), a n d c pio(1 ) m a n pages
-

344 R H 1 24- R H E L 7 - e n-1 -20140606


-

Pract i ce: Wo r k i n g with R P M Package F i l e s


-

P ra ct i ce: Wo rk i n g wit h R P M Pa c ka g e F i l es

Guided exercise

I n t h i s l a b, you w i l l g a t h e r i n fo r m a t i o n a bout a t h i rd-pa rty p a c ka g e, extract fi l es from it, a n d


- i n sta l l it o n y o u r serverX syst e m .

O ut c o m e s :
A package not prov i d e d by a yum repository is i n sta l l e d o n t h e syste m .

Before you begin ...


- Reset yo u r s e rverX syste m .

D 1. Down l oa d wonderwidgets-1. 0-4.x86_64. rpm from http://classroom/publmaterials.

[ root@serverX -]# wget h t t p : //clas s r oom/pub/mate rials/

- -2014-02-11 15 : 58 : 02 - - http : //classroom/pub/materials/


wonderwidge t s - 1 . 0 - 4 . x86_64 . rpm

wonderwidgets-1 . 0- 4 . x86_64 . rpm


Resolving classroom ( classroom) . . . 172 . 25 . 0 . 254
-

Connecting to classroom ( classroom ) l 172 . 25 . 0 . 254 I : 80 . . . connected .


HTTP request sent, awaiting response . . . 200 OK
Length : 5000 ( 4 . 9K) [application/x- rpm]
- I

Saving to : ' wonderwidgets - 1 . 0-4 . x86_64 . rpm '


100%[======================================>] 5, 000 - - . -K/s in 0s
2014-02-11 15 : 58 : 02 ( 381 MB/s ) - 'wonderwidgets-1 . 0- 4 . x86_64 . rpm ' saved
[5000/5000]
I
-

D 2. W h a t f i l e s does it conta i n?

[ root@serverX -]# rpm -q -p wonderwidget s - 1 . 0 - 4 . x86_64 . r pm


/etc/wonderwidgets . conf
-1

/usr/bin/wonderwidgets
/usr/share/doc/wonderwidgets-1 . 0
/usr/share/doc/wonderwidgets- 1 . 0/README . txt
-
D 3. W h at scripts d o e s it conta i n?

- I [ root@serverX -]# rpm -q - p wonde rwidget s - 1 . 0 - 4 . x86_64 . r pm - - sc ri p t s

D 4. How much d i s k s pace w i l l it u s e when i n sta l l ed?

[ root@serverX -]# r p m -q - p wonde rwidget s - 1 . 0 - 4 . x86_64 . r pm


Name wonderwidgets
-i

Version 1.0
Release 4
-

Architecture : x86 64
Install Date : ( not installed )
-
Group GLS/Applications
License GPL
Size : 4849

- -
R H 1 24 - R H E L 7 e n 1 -201 4 0606 345

-
-

C h a pt e r 1 3 . I n sta l l i n g a n d U pd a t i n g Software Packages

Signature ( none )
-

Source RPM wonderwidgets-1. 0-4. src . rpm


Build Date Fri 03 Dec 2010 05 : 42 : 55 AM EST
Build Host station166 . rosemont . lan
Relocations ( not relocatable )
-

Vendor Red Hat, Inc .


summary Demonstration package for use in GLS training .
Description
A demonst ration package that installs an executable, and a config file .
-

D 5. Use yum localin s t all to i n sta l l the package.

[ root@serverx -]# yum locali n s t all wonde rwidget s - 1 . 0 - 4 . x86_64 . r pm


Loaded plugins : langpacks
-

Examining wonderwidgets-1 . 0- 4 . x86_64 . rpm : wonderwidgets-1 . 0-4 . x86_64


Marking wonderwidgets- 1 . 0 - 4 . x86_64 . rpm to be installed
Resolving Dependencies
- -> Running transaction check
-

- - -> Package wonderwidgets . x86_64 0 : 1 . 0-4 will be installed


- -> Finished Dependency Resolution
Dependencies Resolved
-

Package Arch Version Repository Size


========================================= = ====================================== -

Installing :
================================================================================

wonderwidgets x86_64 1 . 0-4 /wonderwidgets - 1 . 0-4 . x86_64 4.7 k -

Transaction Summary
Install 1 Package
================================================================================ -

Total size : 4 . 7 k
Installed size : 4 . 7 k
Is this ok [y/d/N] : y
-

Downloading packages :
Running transaction check
Running transaction test
Transaction test succeeded
-

Running transaction
Installing wonderwidgets - 1 . 0- 4 . x86_64 1/1
Verifying : wonderwidgets - 1 . 0 -4 . x86_64 111
Installed :
wonderwidgets . x86_64 0 : 1 . 0-4 -

Complete !
-

346 R H 1 24- R H E L 7-en-1-20140606 -

-
-

L a b : I n sta l l i n g a n d U pd a t i n g S oftware Packages


-

La b: I nsta l l i n g a n d U pd a t i n g Softwa re
-

Pa c ka g es

Perfor mance checklist


-
I n t h i s l a b, you w i l l i n sta l l a n d u pdate s e l ect softwa re packages.

Outcomes:
-
N ew and u p d ated packages a re i n sta l l ed o n t h e syste m .

Before you begin ...


-
Reset your s e rverX syste m.

1. C reate t h e f i l e / e t c /yum . repos . d/e r r a t a . r e p o , to e n a b l e t h e " U pdates" repository


-
fo u n d o n t h e content m a c h i ne. I t s h o u l d access content fo u n d at the fo l l o w i n g U R L:
h t t p : / / c o n t e n t . e x a m p l e . c o m / r h e l 7 . 0 / x 8 6_6 4 / e r r a t a. D o not c h e c k G P G
s i g n a t u res.
-

2. Config u re serverX to a d h e re to very s p e c ific softwa re req u i re m e nts. I t m u st have t h e l atest


vers i o n of the fo l l ow i n g packages i n sta l l e d . Do not i n sta l l a l l u p d ates. O n l y i n sta l l u pdates for
-
the packages l isted if t h ey a re a va i l a b l e.

2.1 . k e r nel (ex i st i n g pa cka ge w/ a n u pd a te)

2.2. xsane - gimp ( n ew p a c ka g e)

2.3. r h t - sys t em ( n ew package)

3. Fo r secu rity rea sons, it s h o u l d not have the wvd ial package i n sta l l e d .
-
4. W h e n you a re rea d y to c h e c k yo u r work, r u n lab software g rade on s e rverX.

R H 1 24- R H E L 7-e n-1-20140606 347

-
-

C h a pte r 1 3. I n sta l l i n g a n d U pd a t i n g Software Pac ka g e s

Solution
-

I n t h i s l a b, you w i l l i n sta l l a n d u pdate s e l ect softwa re packages.

Outcomes: -

N ew a n d u pdated packages a re i n sta l l e d o n t h e syst e m .

Before you begin. . .


Reset you r serverX syste m .

1. C reate t h e f i l e / e t c /yum . repos . d / e r r a t a . r e po, to e n a b l e t h e " U pd ates" repository -

fo u n d o n the content m a c h i ne. I t s h o u l d a ccess content fo u n d a t the fo l l o w i n g U R L:


h t t p : / / c o n t e n t . e x a m p l e . c o m / r h e l 7 . 0 / x 8 6_64 / e r r a t a. D o not c h e c k G P G
s i g n a t u res.

C reate t h e file / e t c /yum . repos . d / e r r a t a . repo with t h e fo l l o w i n g content:

[updates]
name=Red Hat Updates
-

baseurl=http : //content . example . com/rhel7 . 0/x86_64/errata


enabled=1
gpgcheck=0
-

-
2. Confi g u re serverX to a d h e re t o very specific softwa re req u i re m e nts. I t m u st h a ve t h e l atest
vers i o n of t h e fo l l o w i n g packages i n sta l l e d . D o not i n sta l l a l l u pdates. O n l y i nsta l l u p d ates for
the packages l isted i f they a re ava i l a b l e.
-

2.1 . k e r nel (ex i st i n g package w/ a n u pd ate)

yum u p d a t e k e r nel

2.2. xsane - gimp (new package)


-
yum i n s t all xsane - gimp

2.3. r h t - sys t em (new package)

yum i n s t all r h t - sys t em

3. Fo r secu rity rea sons, it s h o u l d not have the wvdial package i n sta l l e d .

y u m r emove wvd ial


-

4. W h e n you a re read y to check yo u r work, run lab softwa r e g r ade on serverX.

I [student@serverx - ] $ lab software grade

-
348 R H 1 24- R H E L7-en-1-20140606

-
Sol ution
-

S u m m a ry
-

Atta c h i n g Syste m s to S u bscriptions for Softwa re U pd ates


Reg iste r i n g system s a l l ows access to softwa re u pd ates for i n st a l l ed prod u cts.
-

R P M Softwa re Pa ckages and Yu m


R P M packages, g ro u ped i nto y u m repositories, prov i d e a u n ifo r m method of t ra c k i n g
softwa re i n sta l l a t i o n a n d u pdates.

M a n a g i n g Softwa re U pdates with yum


yum is used to i n sta l l a n d u pdate softwa re p a c k a g es.

E n a b l i n g yum Softwa re Repositories


- Repositories fo r yum a re config u red i n the I e t c/yum . repos . d d i recto ry.

E xa m i n i n g R P M Pa ckage F i l es
- Pa ckages down l oa d e d o u t s i d e of y u m repos itories c a n be q u e r ied a n d i n sta l l e d w i t h
rpm.

- R H 1 24- R H E L 7-en-1 -20140606 349

-
-

350
red h at ®

®
TRAINING

C H A PT E R 14

ACCESSING LI N UX FILE
SYSTEMS

Overview

Goal To a ccess a n d i nspect existing f i l e systems on a Red Hat


E nterprise L i n u x system.

Objectives • I dent i fy t h e f i l e system h i e ra rc hy.

• Access t h e contents of f i l e systems.

• U s e h a rd l i n ks a n d s y m l i n k s to m a ke m u lt i p l e na mes.

• Searc h for fi les o n m o u nted file systems.

Sections • I dentify i n g F i l e Systems a n d Devices (and Practice)

• M o u n t i n g and U n mo u n t i n g File System s (a n d Practice)

• M a k i n g L i n ks Between F i l e s (a n d P ract ice)

• Locat i n g F i l e s on the System (and Practice)

Lab • Acces s i n g L i n u x F i l e Syste ms

R H1 24- R H E L7-e n-1-20140606 351


-

C h a pter 14. Access i n g L i n u x F i l e Systems


-

I d e nt ifyi ng F i l e Syst e m s a n d Devices -

Objectives
After com p l e t i n g t h i s sect i o n , students s h o u l d be a b l e to i d e ntify a d i rectory i n t h e f i l e system
h i e ra rchy a n d w h a t stora g e device it i s sto red o n .
-

Storage management conce pts


A f i l e system is an o rg a n i zed st ructure of data-h o l d i n g f i l e s a n d d i rectories res i d i n g on a
-
storage device, s u c h as a phys i c a l d i s k o r p a rt i t i o n . T h e fi l e system h i e ra rc h y d i scussed e a r l i e r
a s s e m b l e s a l l t h e f i l e systems i nto o n e t ree o f d i rectories with a s i n g l e root, t h e I d i recto ry. T h e
advantage h e re i s t h a t t h e exist i n g h i e ra rchy c a n b e exte n d e d at a n y t i m e by a d d i n g a new d i s k -
o r p a r t i t i o n conta i n i n g a s u p po rted f i l e syste m to a d d d i s k s pace a ny w h e re i n t h e f i l e system
t ree. The p rocess of a d d i n g a new file system to t h e ex isti n g d i recto ry t ree i s c a l l e d mounting.
The d i rectory w h e re t h e new f i l e syst e m is m o u nted is referred to as a mount point. T h i s is a -
f u n d a m enta l l y d i ffere n t c o n cept t h a n t h a t used o n a M icrosoft W i n d ows syst e m , w h e re a new f i l e
system is re presented by a separate d rive l ette r.
-
H a rd d i s ks a n d storage devices a re n o rm a l l y d i v i d e d u p into s m a l l e r c h u n ks ca l l ed partitions. A
partition is a way to c o m p a rtm en ta l i ze a d i s k . D i fferent parts of it can be form atted w i t h d i ffere n t
fi l e syste m s o r used for d iffe rent pu rposes. Fo r exa m p l e, o n e partition cou l d conta i n u s e r h o m e
-
d i rectories w h i l e a n o t h e r c o u l d conta i n system data a n d l ogs. I f a user fi l l s u p t h e h o m e d i rectory
partition with d a t a , the system pa rtit i o n may st i l l have space ava i l a b l e. P l a c i n g data in two
sepa rate f i l e syste ms on two sepa rate p a r t i t i o n s h e l ps in p l a n n i n g data stora g e.
-

Storage devices a re re p resented by a s p e c i a l f i l e type ca l l ed block device. T h e b l o c k device is


stored i n t h e / d ev d i recto ry. In Red H a t Enterprise L i n u x , t h e fi rst SCS I , PATA/SATA, o r U S B
-
h a rd d rive detected i s /dev/sda, t h e seco n d i s / d ev/ sdb, a n d so o n . T h i s n a m e represents
t h e w h o l e d rive. T h e fi rst p r i m a ry p a r t i t i o n o n /dev/sda i s /dev/sda1, the second partition i s
/dev/sda2, a n d so o n .
-

A l o n g l i s t i n g of t h e /d ev/vda device f i l e o n serverX reve a l s i t s spec i a l fi l e t y p e a s b, w h i c h


sta n d s f o r b l o c k d evice:

[student@serverx -]$ ls - 1 /dev/vda


-

brw- rw- - - - . 1 root disk 253, 0 Mar 13 08 : 00 /dev/vda


-

Note
Except i o n s a re h a rd d rives i n v i r t u a l m a c h i n e s , w h i c h ty p i ca l l y s h ow u p a s
/dev/vd<l e t ter> o r /dev/xvd<l e t ter>.

Another way of o rg a n i z i n g d isks and p a r t i t i o n s i s w i t h logical volume management ( LV M ). With


LV M , o n e o r m o re block d evices c a n b e a g g regated i nto a stora g e p o o l ca l l ed a volume group.
D i s k space i s m a d e ava i l a b l e with o n e or m o re logical volumes. A l o g i c a l vo l u m e is t h e e q u iva l e nt
of a partit i o n res i d i n g o n a physica l d i s k. Both t h e vo l u me g ro u p a n d t h e l o g i c a l vo l u m e have
n a m e s a s s i g n e d upon c reat i o n . Fo r the vo l u m e g ro u p, a d i rectory with the s a m e n a m e a s t h e
-
vo l u m e g r o u p e x i sts i n t h e /dev d i recto ry. Be l ow t h a t d i recto ry, a sym b o l i c l i n k w i t h t h e s a m e
n a m e as t h e l o g ica l vo l u m e h a s been c reated. Fo r exa m p l e, t h e device f i l e represe n t i n g t h e mylv
l o g i c a l vo l u m e in t h e myvg vo l um e g r o u p is /dev/myvg/mylv.
-

352 R H 1 24- R H E L 7 - e n -1-20140606 -

-
-

Exa m i n i n g f i l e syste m s
-

I t s h o u l d b e noted t h a t LV M re l ies o n t h e Device Mapper ( D M ) k e r n e l d river. T h e a bove sym b o l i c


l i n k / dev/myvg/mylv p o i n t s to t h e /dev/dm - number b l o c k device n od e. T h e a ss i g n m e nt of
-
the n umb e r i s seq u e n t i a l beg i n n i n g with zero (0). T h e re i s a a n ot h e r sym bol i c l i n k for eve ry
l o g ica l vo l u m e i n the / d ev/mappe r d i rectory w i t h the n a m e /dev/mapper /myvg - mylv. Access
to the l o g i ca l vo l u m e c a n g e n e ra l l y use e i t h e r of t h e c o n s istent and re l i a b l e sy m b o l i c l i n k n a mes,
-
since t h e /dev/d m - number n a m e c a n va ry w i t h e a c h boot.

- Examining file syste ms


To g et an overview about t h e file system mount points and the a m o u nt of free space a va i l a b l e,
r u n t h e df com m a n d . W h e n t h e d f co m m a n d i s r u n w i t h o u t a rg u m e nts, it wi l l report tota l d i s k
-
spa ce, u s e d d i s k spa ce, a n d free d i s k space o n a l l m o u n te d reg u l a r f i l e systems. I t w i l l report o n
both l oca l a n d re mote systems a n d t h e p e rcentage o f t h e tota l d i s k space that i s b e i n g used.

- D i s p l ay t h e f i l e syste m s a n d m o u n t points o n t h e serverX m a c h i n e.

[student@serverx ] $ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 6240256 4003760 2236496 65% I
-

devtmpfs 950536 0 950536 0% /dev


tmpfs 959268 80 959188 1% /dev/shm
tmpf s 959268 2156 957112 1% /run
tmpfs 959268 0 959268 0% /sys/fs/cgroup
-

-
The partit i o n i n g o n t h e serve r X m a c h i n e sh ows o n e rea l f i l e system, w h i c h is m o u nted o n /.
T h i s i s c o m m o n for v i rt u a l m a c h i n es. The tmpfs and devtmpfs devices a re f i l e syst e m s i n system
-
m e m o ry. A l l fi les written i nto t m pfs o r devtm pfs d i s a p p e a r after syste m reboot.

G i B (2 ) , w h i l e t h e - H o p t i o n w i l l report i n S I u n its: K B (1 0 \ M B (1 0 ), G B (1 0 ) , etc. H a rd d rive


To i m p rove rea d a b i l ity of t h e o u t p u t s izes, t h e re a re two d i fferent human-readable o p t i o n s : - h
0 20
o r - H. The d i ffere nce between t h e s e two options i s t h a t - h w i l l re port i n K i B c i ) , M i B (2 ) , o r
- 30 6 9
m a n ufactu rers u s u a l ly u s e S I u n its when advert i s i n g t h e i r p ro d u cts.

S h ow a re port on t h e fi l e syste m s o n the serverX m a c h i n e with a l l u n its converted to h u m a n ­


rea d a b l e format:

[student@serverx -]$
Filesystem Size Used Avail Use% Mounted on
-
df - h

/dev/vda1 6 . 0G 3 . 9G 2 . 2G 65% I
devtmpfs 929M 0 929M 0% /dev
tmpfs 937M 80 K 937M 1% /dev/shm
-

tmpfs 937M 2 . 2M 935M 1% /run


-
tmpfs 937M 0 937M 0% /sys/fs/cgroup
Fo r m o re d eta i l ed i nfo r m a t i o n a bo u t t h e s pace used by a ce rta i n d i rectory t ree, t h e re i s t h e d u
- com m a n d . The d u co m m a n d h a s - h a n d - H o p t i o n s to convert t h e o u t p u t to h u m a n - rea d a b l e
fo rmat. T h e d u co m m a n d s h ows t h e s i z e o f a l l f i l e s i n t h e c u rrent d i rectory tree rec u rs i v e l y.

-
S h ow a d i s k usage re p o rt for t h e / root d i rectory on s e rverX:

[ root@serverX -]# du /root


4 /root/ . ssh
4 /root/ . cache/dconf
4 /root/ . cache
-

4 /root/ . dbus/session- bus


-

- R H 1 24- R H E L 7-en-1-20140606 353

-
-

C h a pter 14. Acces s i n g L i n u x F i l e Syste m s

4 /root/ . dbus
0 /root/ . config/ibus/bus
0 /root/ . config/ibus
0 /root/ . config
14024 /root
-

-
S h ow a disk usage re port in h u m a n - re a d a b l e fo rmat for the /var /log d i rectory o n serverX:

[ root@serverX - ] # du - h /var/log

4 . 9M /var/log/sa
-

68K /var/log/prelink
0 /var/log/qemu-ga
14M /var/log
-

R References
df(1 ) a n d d u (1 ) m a n pages
-

354 R H 1 24- R H E L 7-en-1-20140606

-
-

Practice: I d e nt i fy i n g F i l e Syste m s a n d Devices

P ra ct i ce: I d e n t i fyi n g F i l e Syste m s a n d Devi ces


-

Quiz
Match t h e fo l l owi n g items to t h e i r c o u n te r p a rt s i n t h e ta b l e.

I I I I
-

/d ev/s d a 2 /d ev/sd b3 /d ev/s d c /d ev/vd b /d ev/vd b3


-

/d ev/vg_i n sta l I/Iv _h o m e

Desc ription Device f i l e

T h e d ev i c e f i l e of a SATA h a rd d ri ve res i d i n g
-
i n /dev.

- The d ev i c e fi l e of the seco n d p a rt i t i o n on


the f i rst S ATA h a rd d r i ve in / d ev.
-

T h e d ev i ce fi l e of a l og i ca l vo l u m e i n / d ev.
-

The d ev i c e f i l e of t h e seco n d d i s k in a v i rt u a l
-
m a c h i n e i n / d ev.

-
T h e d ev i c e f i l e of t h e t h i rd p a rt i t i o n on t h e
seco n d S ATA h a rd d rive i n / d ev.
-

The d ev i ce fi l e of the t h i rd p a r t i t i o n on t h e
-
seco n d d i s k i n a v i rt u a l m a c h i n e i n / d ev.

- R H 1 24- R H EL 7 - en -1-20140606 355

-
-

C h a pte r 1 4. Access i n g L i n u x F i l e Syste m s

Solution
-

Match t h e fo l l o w i n g items to t h e i r c o u n t e r p a rts i n t h e t a b l e.

Desc r i p t i o n Device f i l e
-

T h e d e v i ce fi l e of a SATA h a rd d r ive res i d i n g /d ev/s d c


i n / d ev. -

T h e d e v i c e f i l e of t h e seco n d p a r t i t i o n o n /d ev/s d a 2 -

t h e fi rst S ATA h a rd d rive i n / d ev.


-

T h e d e v i ce f i l e of a l og i ca l vo l u m e i n / d ev. /d ev/vg_i n sta I I/Iv _h o m e


-

T h e d e v i c e f i l e of t h e seco n d d i s k i n a v i r t u a l /d ev/vd b
-
m a c h i n e i n / d ev.

T h e d e v i c e fi l e of t h e t h i rd p a r t i t i o n o n t h e /d ev/s d b 3
seco n d S ATA h a rd d rive i n / d ev.
-

T h e d e v i c e f i l e of t h e t h i rd pa rt i t i o n o n t h e /d ev/vdb3
-
s e c o n d d i s k i n a v i rt u a l ma c h i n e i n / d ev.

356 R H 1 24- R H E L7-e n-1-20140606

-
-

M o u nt i n g a n d U n mo u n t i n g F i l e Systems
-

M o u nt i n g a n d U n m o u n t i n g F i l e Systems
-

-
Objectives
After c o m p l et i n g t h i s section, students s h o u l d be a b l e to a ccess t h e contents of f i l e systems by
a d d i n g a n d re mov i n g f i l e syste m s from t h e f i l e system h i e ra rc h y.
-

Mounting file systems manually


-
A f i l e system res i d i n g o n a SATA/PATA or SCS I d evice n e e d s to be m o u nted m a n u a l l y to access
it. The mount com m a n d a l l ows the root user to m a n u a l l y m o u n t a file system. T h e fi rst a rg u m e n t
of t h e mou n t com m a n d s p e c i f i e s t h e f i l e syst e m to m o u nt. T h e secon d a rg u me n t s p e c ifies t h e
- ta rget d i rectory w h e re t h e f i l e syste m i s m a d e ava i l a b l e a f t e r m o u n t i n g i t . The ta rget d i rectory is
refe rred to a s a m o u nt p o i nt.

-
T h e mou n t com m a n d ex pects the fi l e system a rg u m e n t in one of two d iffe rent ways:

• The d evice file of the p a r t i t i o n h o l d i n g t h e f i l e syste m , res i d i n g i n / d ev.


-
• The UU/D, a u n i ve rs a l u n iq u e i d e ntifier of the f i l e syste m .

- Note
As l o n g as a f i l e system is not recreated, t h e U U I D stays the s a m e. T h e device f i l e c a n
c h a n g e ; f o r exa m p l e, if t h e order of t h e d ev i ces i s c h a n g e d o r if a d d i t i o n a l d e v i c e s a re
-
a d d e d to t h e syste m .

-
T h e blkid co m m a n d g i ves a n overview o f exist i n g partit i o n s w i t h a f i l e system o n t h e m a n d t h e
U U I D o f t h e f i l e syst e m , a s we l l a s t h e f i l e syst e m used to format t h e partition.


[ root@serverX -]# blkid
/dev/vdal : UUID="46f543fd- 78c9-4526-a857 -244811be2d88" TYPE="xfs"
-

Note
- A f i l e system ca n b e m o u nted o n a n exist i n g d i recto ry. T h e /mnt d i rectory e x i st s
by defa u l t a n d provides a n e n t ry point for m o u n t p o i nts. I t i s used for m a n u a l l y
m o u n t i n g d isks. I t i s reco m m e n d e d to create a s u b d i rectory u n d e r /mnt a n d u s e t h a t
-
s u b d i rectory a s a m o u n t p o i n t u n l ess t h e re i s a reas o n to m o u n t t h e f i l e syst e m i n
a no t h e r s p e c i f i c l oc a t i o n i n t h e f i l e syste m h i e ra rc hy.

I [ root@serverX -]#
M o u nt by device f i l e of t h e p a r t i t i o n that h o l d s t h e fi l e syste m .

-
mou n t /dev/vdb1 /mnt/mydata

-
M o u nt the fi l e syst e m by u n ive rsa l u n iq u e id, or the U U I D, of t h e f i l e system.

[ root@serverX -]# mou n t U U I D = " 46f543fd - 7Bc9 - 4526 - a857 · 244811be2dB B " /mnt /mydata
-

- R H 1 24- R H E L 7-en-1-20140606 357

-
-

C h a pter 14. Accessi n g L i n u x F i l e Syste m s


-

Note -

I f t h e d i rectory a ct i n g a s m o u n t p o i n t is n ot e m pty, t h e f i l es t h a t exists i n t h a t d i rectory


a re not a ccess i b l e a s long a s a file syste m i s m o u nted t h e re. A l l f i l e s written to the
-
m o u n t point d i rectory end u p o n t h e f i l e syste m m o u nted t h e re.

Unmounting file systems


To u n mo u n t a f i l e syst e m , t h e umo u n t com m a n d expects t h e m o u n t point as a n a rg u m e n t .
-

C h a n g e to t h e /mnt /myd a t a d i recto ry. Try t o u m o u n t t h e d evice m o u nted o n t h e /mnt /myda t a


m o u n t p o i n t . I t w i l l fa i l .

[ root@serverX -]# cd /mnt/mydata


-

[ root@serverX mydata]# umount /mnt /mydata


umount : /mnt/mydata : target is busy .
( In some cases useful info about processes that use
-

the device is found by lsof ( B ) or fuser ( 1 ) )


U n m o u n t i n g is not poss i b l e if t h e m o u nt point is a ccessed by a p rocess. Fo r umou n t to be
s u ccessf u l , t h e p rocess needs to stop accessing t h e mount p o i n t .
-

T h e l s o f co m m a n d l ists a l l o p e n f i l e s a n d the p rocess access i n g t h e m i n t h e p rovi d e d d i recto ry.


It is usef u l to i d e n t ify w h i c h p rocesses c u r re n t l y p reve nt t h e f i l e system from s u ccessfu l
unmounting. -

O n c e t h e p rocesses a re i d e ntified, a n a c t i o n ca n b e t a k e n , s u c h a s wa i t i n g f o r t h e p rocess to


c o m p l ete o r s e n d i n g a S I GT E R M o r S I G K I L L s i g n a l to t h e p rocess. In this case, it is s u ffi c i e n t to -
c h a n g e the c u r rent w o r k i n g d i rectory to a d i rectory o u t s i d e the m o u n t point.

[ root@serverx mydata]# cd
�---- --

[ root@serverX -]# umo u n t /mnt /mydata


'

I
!

�- =--, -

Note
A c o m m o n cause for t h e f i l e system on t h e m o u nt p o i n t to b e b u sy i s if t h e c u r re n t
wor k i n g d i rectory of a s h e l l p ro m pt i s b e l ow t h e a ctive m o u nt point. T h e p rocess
a ccess i n g the m o u n t point is bash. C h a n g i n g to a d i rectory outside the mount p o i n t
a l l ows t h e device to b e u n mo u nted.
-

Accessing removable storage devices


R e m ova b l e m e d i a , s u c h as U S B f l a s h d ev ices a n d d rives, g et a utomatica l l y m o u nted by t h e
g r a p h ica l d e s ktop e n v i ro n m e nt w h e n p l u g g e d i n . T h e m o u n t p o i n t f o r t h e remova b l e m ed i u m i s -

358 R H 1 24- R H E L7 - e n -1-20140606 -

-
-

Access i n g remova b l e storage devices


-

/ r u n/media/ < u s e r >/<label>. T h e <user> is t h e u s e r l o g g ed i nto the g ra p h ica l e n v i ro n m e nt.


The < l a b e l > i s t h e name g iven to the file syst e m when i t was c reated.
-

Warn ing
-
To s a fe l y re m ove U S B m e d i a from t h e syst e m , it is req u i red to u n mo u nt it before
p hysica l l y re m o v i n g it from t h e U S B s l ot to sy n c h ro n i z e t h e f i l e system. Removing a
U S B stora g e device without u n m o u n t i n g t h e f i l e syst e m on it c a n res u lt i n data l oss.
-

-
R References
�J_ _

mou n t (8), umo u n t (8), a n d lsof(8) m a n p a g es


-

- R H 1 24- R H E L 7 -en -1-20140606 359

S-ar putea să vă placă și