linux常用命令

:-}

LINUX下查看大文件

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        54G   34G   17G  68% /
tmpfs            63G     0   63G   0% /dev/shm
/dev/sda1       923M   78M  798M   9% /boot
/dev/sdb1       2.2T  688G  1.6T  31% /home
/dev/sda4       112G   44M  112G   1% /tmp
/dev/sda5       105G  1.8G  103G   2% /var/log

排查大文件

du -s -h *|sort -nr
* 1
856M    log
188K    scratchdir
5.4G    resources
4.0K    server2

清空文件

cat /dev/null > filename
echo “” > filename

压缩和解压

tar

解包:tar zxvf filename.tar
打包:tar czvf filename.tar dirname

zip

解压:unzip filename.zip
压缩:zip filename.zip dirname