linux下尋找及壓縮命令

來源:互聯網
上載者:User


linux下尋找及壓縮命令 一、which        尋找的是命令,比如: jerry@why :/$ which ls/bin/lsjerry@why :/$www.2cto.com  二、whereis        跟which差不多,比which多一點,會顯示命令協助在哪裡:jerry@why :/$ whereis lsls: /bin/ls /usr/share/man/man1/ls.1.gzjerry@why :/$ 三、locate        尋找所有的檔案夾的檔案,效率特別高        updatedb        linux下的計劃任務:/etc/cron.daily/四、find        find / -name a.txt        find / -name "*newfile*"        對應locate:locate -r ".*newfile.*"用的是Regex,.*代表任意多個任一字元。         效率低,功能最強,一個例子: jerry@why:/$ find /etc -name "*network*"find: `/etc/cups/ssl': 許可權不夠/etc/init.d/network-interface-security/etc/init.d/network-interface-container/etc/init.d/network-interface/etc/init.d/network-manager/etc/init.d/networking/etc/rc0.d/S35networking/etc/rc6.d/S35networking/etc/apparmor/init/network-interface-securityfind: `/etc/ssl/private': 許可權不夠/etc/network  www.2cto.com  /etc/bluetooth/network.conf/etc/networks/etc/init/network-manager.conf/etc/init/networking.conf/etc/init/network-interface.conf/etc/init/network-interface-container.conf/etc/init/network-interface-security.conf/etc/modprobe.d/blacklist-rare-network.conf/etc/sysctl.d/10-network-security.confjerry@why:/$  尋找完後面還可以跟命令: root@why:~# find /home "*txt*" -ok rm file {} /;可是我在unbuntu下為什麼提示:find: 缺少“-ok”參數(知道什麼原因了,看著裡:jerry@why:~/linux-jerryz$ find /home/jerry/ -name history.txt -exec cat {} \; 打錯了slush;) 另一個例子:  www.2cto.com  root@why:~# find /home/jerry/下載/ -user jerry -a -group jerry -ls1177359    4 drwxr-xr-x   2 jerry    jerry        4096  7月 26 01:53 /home/jerry/\344\270\213\350\275\275/root@why:~#  其中-a為and(-o為or);-user是尋找擁有者為jerry,-group是尋找擁有組為jerry;find / -perm -777 -type d -ls ————————————————————————————————————————————五、grep         搜尋包含指定內容的檔案! (這是我一直想找的命令!)e.g.:grep -R jerry /etc(在/etc下所有目錄尋找,內容含有jerry的檔案(參數-R代表所有檔案)) 如果只想列出檔案名稱:  www.2cto.com  grep -R -l jerry /etc(-l只列出檔案名稱) 01root@why:~# grep -R -l jerry /etc02/etc/passwd03/etc/shadow-04grep: /etc/alternatives/ghostscript-current/Resource/CMap/Hojo-EUC-H: 沒有那個檔案或目錄05grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF16-H: 沒有那個檔案或目錄06grep: /etc/alternatives/ghostscript-current/Resource/CMap/Hojo-H: 沒有那個檔案或目錄07grep: /etc/alternatives/ghostscript-current/Resource/CMap/Adobe-Japan2-0: 沒有那個檔案或目錄08grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF8-V: 沒有那個檔案或目錄09grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UCS2-V: 沒有那個檔案或目錄10grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UCS2-H: 沒有那個檔案或目錄11grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF32-V: 沒有那個檔案或目錄12grep: /etc/alternatives/ghostscript-current/Resource/CMap/Hojo-V: 沒有那個檔案或目錄13grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF32-H: 沒有那個檔案或目錄14  www.2cto.com  grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF16-V: 沒有那個檔案或目錄15grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF8-H: 沒有那個檔案或目錄16grep: /etc/alternatives/ghostscript-current/Resource/CMap/Hojo-EUC-V: 沒有那個檔案或目錄17/etc/alternatives/ghostscript-current/lib/ps2ascii.ps18/etc/gshadow-19/etc/group20/etc/shadow21/etc/mtab22grep: /etc/blkid.tab: 沒有那個檔案或目錄23/etc/passwd-24/etc/group-25/etc/gshadow26root@why:~#27_________________________________________________________________________________________________28############################################################################################29############################################################################################30  www.2cto.com  下面我們看打包與壓縮命令:31    打包與壓縮是不同的操作,不要收windows思想的左右。32一、打包33    tar cvf /tmp/root.tar /home/jerry/ /etc/passwd /etc/shadow34(c參數表示打包,v是過程可見,f是後面跟的檔案)35    tar rvf /tmp/root.tar /home/jerry/a.txt36(r參數是追加檔案,吧a.txt追加到root.tar包裡)37    tar xvf /tmp/root.tar -C .38(x參數是解開打包 -C參數是指定解壓的位置)39    tar tvf /tmp/root.rar40(t參數是查看包裡的內容,解開之前有所瞭解)41二、打包並壓縮42    tar cvfz /tmp/root.tar.gz /etc/passwd43(z表示gzip壓縮方式)44    tar cvfj /tmp/root.tar.bz2 /etc/passwd45(j表示bzip2的壓縮方式,壓縮率比gzip要高)46  www.2cto.com  三、壓縮47    (1)gzip壓縮公用程式48        gunzip解壓49    (2)bzip2壓縮公用程式50        bunzip2解壓(壓縮率高於gzip)  作者 Jerryz

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.