tar
[root@linux ~]# tar [-cxtzjvfpPN] ....
:
-c : (create );
-x : !
-t : tarfile !
, , c/x/t ! !
。
-z : gzip ? gzip ?
-j : bzip2 ? bzip2 ?
-v : ! , !
-f : , , f ! !
『 tar -zcvfP tfile sfile』 ,
『 tar -zcvPf tfile sfile』 !
-p : ( )
-P : !
-N : (yyyy/mm/dd) !
--exclude FILE: , FILE !
:
: /etc /tmp/etc.tar
[root@linux ~]# tar -cvf /tmp/etc.tar /etc <== , !
[root@linux ~]# tar -zcvf /tmp/etc.tar.gz /etc <== , gzip
[root@linux ~]# tar -jcvf /tmp/etc.tar.bz2 /etc <== , bzip2
# , f , .tar 。
# z , .tar.gz .tgz gzip tar file ~
# j , .tar.bz2 ~
# , :
# 『tar: Removing leading `/' from member names』 。
: /tmp/etc.tar.gz ?
[root@linux ~]# tar -ztvf /tmp/etc.tar.gz
# gzip , tar file ,
# z ! !
: /tmp/etc.tar.gz /usr/local/src
[root@linux ~]# cd /usr/local/src
[root@linux src]# tar -zxvf /tmp/etc.tar.gz
# , ! ,
# /usr/local/src , /tmp/etc.tar.gz ,
# /usr/local/src/etc ! , /usr/local/src/etc
# , /etc/ !
: /tmp , /tmp/etc.tar.gz etc/passwd
[root@linux ~]# cd /tmp
[root@linux tmp]# tar -zxvf /tmp/etc.tar.gz etc/passwd
# tar -ztvf tarfile , ,
# ! ! etc.tar.gz / !
: /etc/ , !
[root@linux ~]# tar -zxvpf /tmp/etc.tar.gz /etc
# -p , !
: /home , 2005/06/01
[root@linux ~]# tar -N '2005/06/01' -zcvf home.tar.gz /home
: /home, /etc , /home/dmtsai
[root@linux ~]# tar --exclude /home/dmtsai -zcvf myfile.tar.gz /home/* /etc
: /etc/ /tmp , !
[root@linux ~]# cd /tmp
[root@linux tmp]# tar -cvf - /etc | tar -xvf -
# cp -r /etc /tmp ~ !
# - - , | ~
# standard output, standard input !
# Bash shell , !
gzip, zcat
[root@linux ~]# gzip [-cdt#]
[root@linux ~]# zcat .gz
:
-c : , ;
-d : ;
-t : ~ ;
-# : ,-1 , 、-9 , ! -6 ~
:
: /etc/man.config /tmp , gzip
[root@linux ~]# cd /tmp
[root@linux tmp]# cp /etc/man.config .
[root@linux tmp]# gzip man.config
# man.config man.config.gz !
: !
[root@linux tmp]# zcat man.config.gz
# man.config.gz !!
:
[root@linux tmp]# gzip -d man.config.gz
: man.config ,
[root@linux tmp]# gzip -9 -c man.config > man.config.gz
bzip2, bzcat
[root@linux ~]# bzip2 [-cdz]
[root@linux ~]# bzcat .bz2
:
-c : !
-d :
-z :
-# : gzip , , -9 , -1 !
:
: /tmp/man.config bzip2
[root@linux tmp]# bzip2 -z man.config
# man.config man.config.bz2 !
: !
[root@linux tmp]# bzcat man.config.bz2
# man.config.bz2 !!
:
[root@linux tmp]# bzip2 -d man.config.bz2
: man.config ,
[root@linux tmp]# bzip2 -9 -c man.config > man.config.bz2
compress
[root@linux ~]# compress [-dcr]
:
-d :
-r : !
-c : standard output ( )
:
: /etc/man.config /tmp ,
[root@linux ~]# cd /tmp
[root@linux tmp]# cp /etc/man.config .
[root@linux tmp]# compress man.config
[root@linux tmp]# ls -l
-rw-r--r-- 1 root root 2605 Jul 27 11:43 man.config.Z
:
[root@linux tmp]# compress -d man.config.Z
: man.config
[root@linux tmp]# compress -c man.config > man.config.back.Z
[root@linux tmp]# ll man.config*
-rw-r--r-- 1 root root 4506 Jul 27 11:43 man.config
-rw-r--r-- 1 root root 2605 Jul 27 11:46 man.config.back.Z
# -c ! ,
# file.Z 。 , 。
# , bash shell !
dd
[root@linux ~]# dd if="input_file" of="outptu_file" bs="block_size" \
count="number"
:
if : input file ~ !
of : output file ~ ;
bs : block , , 512 bytes
count: bs 。
:
: /etc/passwd /tmp/passwd.back
[root@linux ~]# dd if=/etc/passwd of=/tmp/passwd.back
3+1 records in
3+1 records out
[root@linux ~]# ll /etc/passwd /tmp/passwd.back
-rw-r--r-- 1 root root 1746 Aug 25 14:16 /etc/passwd
-rw-r--r-- 1 root root 1746 Aug 29 16:57 /tmp/passwd.back
# , /etc/passwd 1746 bytes, bs ,
# 512 bytes , , 3+1 3
# 512 bytes, 512 bytes block !
# , cp ~
: /dev/hda MBR
[root@linux ~]# dd if=/dev/hda of=/tmp/mbr.back bs=512 count=1
1+0 records in
1+0 records out
# ~ MBR 512 bytes,
# sector , ,
# MBR , ! ^_^
: /dev/hda1 partition 。
[root@linux ~]# dd if=/dev/hda1 of=/some/path/filenaem
# ! partition ~
# of /dev/hda1 ~ , ~
# , partition ,
# dd if=/some/file of=/dev/hda1 。
# , Norton ghost ,
# disk disk , ~ dd ~ !
cpio
[root@linux ~]# cpio -covB > [file|device] <==
[root@linux ~]# cpio -icduv < [file|device] <==
:
-o : copy
-i : copy
-t : cpio
-c : portable format
-v :
-B : Blocks 5120 bytes , 512 bytes !
( i-nodes )
-d : ! cpio ,
! -d ,
!
-u : !
:
: !
[root@linux ~]# find / -print | cpio -covB > /dev/st0
# , SCSI , /dev/st0 !
: ?
[root@linux ~]# cpio -icdvt < /dev/st0
[root@linux ~]# cpio -icdvt < /dev/st0 > /tmp/content
# , , ,
# /tmp/content !
: ~
[root@linux ~]# cpio -icduv < /dev/st0
# , SCSI , /dev/st0 !
: /etc 『 』 /root/etc.cpio !
[root@linux ~]# find /etc -type f | cpio -o > /root/etc.cpio
# ~ cpio -i < /root/etc.cpio
# !!!!