You are on page 1of 5

1

H IU HNH LINUX
(Lu tr v cc lnh khc)
Phm Nguyn Khang, Thanh Ngh
Email: pnkhang,dtnghi@cit.ctu.edu.vn

Ni dung
2

find
tar

find
3

Mc ch
Tm kim file v th mc

C php:
find <th mc> <iu kin> <lnh>

iu kin
-name tn
-type x
-user login-name
-size n
-mtime n

c
c
c
c
c

tn l tn
kiu l x
ch s hu l login-name
kch thc l n khi
thi gian thay i n ngy tr v trc

Lnh
-print
exec cmd {}\;

in kt qu ra mn hnh
thc thi lnh cmd

find
4

V d:
find /home/pnkhang name a.out mtime +7 exec rm {}\;
Tm file c tn a.out trong th mc /home/pnkhang hn mt tun ri
khng c sa i v xa n i.

C th s dng ! (ph nh), -a (and), hoc -o (or) kt hp


cc iu kin
Cc iu kin khc
-perm mode
-maxdepth levels
-mindepth levels

quyn truy cp = mode


su ti a
su ti thiu

C th kt hp find vi grep
find . | grep toto

tar
5

Tape archive
ng gi file dng lu tr
ng gi to file lu tr
tar cvf luu_tru.tgz danh sch file/th mc

M gi
tar xvf luu_tru.tgz

C th b qua v trong cvf hoc xvf


Thm mt tp tin vo gi
tar rvf luu_tru.tgz toto.txt

Lit k danh sch cc file trong gi


tar tvf luu_tru.tgz

Thm mi hoc thay th mt file trong gi


tar uvf luu_tru.tgz toto.txt

C th nn/bung nn gi vi gzip/gunzip
tar zcvf luu_tru.tgz danh sch file/th mc
tar zxvf luu_tru.tgz

You might also like