Archiving
Unpack a archive
gzip -cd filename.tar.gz | tar -xvf -
tar xvzf filename.tar.gz
tar xvzf filename.tgz
bzip2 -cd file.tar.bz2 | tar xvf -
tar xjvf filename.tar.bz2
Create a archive file
tar -zcvf backup.tar.gz /usr/local/path
tar -cjvpf ../LEP-host1-20100421.tar.bz2 ./
tar -cjvpf ../LEP-host1-20100421.tar.bz2 ./ --exclude="./usr/local/vmware/*"
patching
rsync
rsync --progress -avxzlD --stats -EH /var/www/ /mnt/cdrom/
rsync -avlDx -EHp -e ssh root@203.27.127.xxx:/path /targetpath/
cp
cp -xvpav /mnt/src/* /mnt/dst/
parts="home opt usr var tmp video vmware"
for part in $parts
do
mount /dev/vx/$part /mnt/src
mount /dev/vg/$part /mnt/dst
sleep 5
cp -xvpav /mnt/src/* /mnt/dst/
sync
sync
sleep 5
umount /mnt/src
umount /mnt/dst
done
copy a partition
dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=notrunc,noerror
Unrar a series
list=$(ls -d -1 /thepath/*)
for line in $list; do thefile="$line/*.rar"; echo "$thefile\n";unrar e $thefile; done