跨平臺壓縮 zip
壓縮
zip 壓縮包名 被壓縮的文件
-r 可打包目錄
unzip則解壓
unzip -d 目標文件夾 zip壓縮包
壓縮或解壓原文件保留
gzip bzip2
gzip -9 文件名
bzip2 -9 文件名
gzip -d .gz格式壓縮
bzip2 -d .bz2格式壓縮
-9提高壓縮比率
-d執行解壓 相當於gunzip或bunzip2
壓縮或解壓原文件不保留
歸檔工具
tar
tar 選項 歸檔文件 原文件或目錄
釋放歸檔
tar 選項 歸檔文件 -C 目標目錄
組合使用一般常用
tar -zcf .tar.gz 製作包
tar -zxf .tar.gz 釋放包
tar -jcf .tar.bz2 製作包
tar -jxf .tar.bz2 釋放包
rpm包 Package Manager
紅帽公司提出 Redhat等
建立集中數據庫,記錄軟件包安裝/卸載等變化信息,分析軟件包信賴關係
RPM包文件名特徵
軟件名-版本信息.操作系統.硬件架構.rpm
[root@localhost test]# rpm -qa vsftpd
vsftpd-2.2.2-11.el6_3.1.x86_64
RPM包安裝位置
一般常用
rpm -q vsftpd 查看包是否安裝
rpm -qa vsftpd 列出所有包
rpm -ql vsftpd 列出安裝清單
rpm -qi vsftpd 查看軟件說明
rpm -qf 文件路徑
根據文件查詢是哪個包
[root@localhost test]# rpm -qf /etc/inittab
initscripts-9.03.38-1.el6.centos.x86_64
使用前加個q
pi 查看指定軟件的詳細信息
pl 查看指定軟件的文件安裝清單
pc pd 列出清單中的配置/文檔文件
安裝rpm包
rpm -ivh rpm包名
如果當前RPM包文件丟失可重新安裝
rpm -ivh --force rpm包名
卸載rpm軟件
rpm -e 軟件名
忽略信賴關係 --nodeps
驗證已安裝的軟件
rpm -V 軟件名
rpm -Vf 文件路徑
rpm -Va
無輸入表示正常
驗證待安裝的.rpm包
rpm --import 軟件官方公鑰
rpm -K RPM包文件
[root@localhost Packages]# rpm --import /mnt/RPM-GPG-KEY-CentOS-6
[root@localhost Packages]# rpm -K vsftpd-2.2.2-11.el6_3.1.x86_64.rpm vsftpd-2.2.2-11.el6_3.1.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
若不是 則不通過
查找
查找可執行程序
默認搜索路徑
[root@localhost Packages]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
which 搜索工具
which -a 程序名
[root@localhost test]# which -a tar
/bin/tar
locate模糊查找
local 選項 關鍵字
[root@localhost test]# updatedb
[root@localhost test]# ll /var/lib/mlocate/
總用量 2116
-rw-r----- 1 root slocate 2166423 8月 14 00:59 mlocate.db
[root@localhost test]# locate 1.mbr
/a/1.mbr
/test/1.mbr
find 精確查找
find
type類型
類型
查找/dev下面的塊設備
find /dev -type b
名稱 可使用通配符
[root@localhost test]# find /etc/init.d/ -name ss*d
/etc/init.d/sssd
/etc/init.d/sshd
條件
-a是同時滿足
find /etc/init.d/ -name ss*d -a -type f
-o是滿足任意一個
find /etc/init.d/ -name ss*d -o -type f
文件大小
-size [+|-]大小
大於2M的文件
[root@localhost test]# ll $(find /root -size +2M)
-rw-r--r--. 1 root root 10485760 8月 11 06:50 /root/.mozilla/firefox/b3kwu94u.default/places.sqlite
-rw-r--r--. 1 root root 5242880 8月 11 06:50 /root/.mozilla/firefox/b3kwu94u.default/urlclassifier3.sqlite
文件修改時間查找
-mtime [+|-]天數
[root@localhost test]# find /root -mtime +12
/root/.tcshrc
/root/.bash_logout
/root/.bashrc
/root/.cshrc
/root/.bash_profile
find 範圍 條件 -exec 處理命令{} \; 這裏的\是轉義符 {}代表查找結果 \;處理結果結束
ll $(find /root -size +2M)或
find /root -size +2M -exec ls -l {} \;