Search and compress commands in linux

Source: Internet
Author: User


Linux search and compression command 1. which search for commands, such as: jerry @ why:/$ which ls/bin/lsjerry @ why: /$ www.2cto.com 2. whereis is similar to which, a little more than which. It will show where the command help is: jerry @ why:/$ whereis lsls: /bin/ls/usr/share/man/man1/ls.1.gzjerry @ why:/$3. Find all the files in the folder in locate, which is particularly efficient for the scheduled tasks in updatedb linux: /etc/cron. daily/4. find/-name a.txt find/-name "* newfile *" corresponding to locate: locate-r ". * newfile. * "The regular expression is used ,. * represents any number of arbitrary characters. Low Efficiency and most powerful functions. Example: jerry @ why:/$ find/etc-name "* network *" find: '/etc/cups/ssl ': insufficient permissions/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 ': insufficient permissions/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:/$ after searching, run the following command: root @ why :~ # Find/home "* txt *"-OK rm file {}/; but why do I prompt "find: the"-OK "parameter is missing in unbuntu? (I know why, look at it: jerry @ why :~ /Linux-jerryz $ find/home/jerry/-name history.txt-exec cat {}\; an error occurs in slush;) Another example: www.2cto.com root @ why :~ # Find/home/jerry/download/-user jerry-a-group jerry-ls1177359 4 drwxr-xr-x 2 jerry 4096 July 26 01:53/home/jerry/\ 344 \ 270 \ 213 \ 350 \ 275 \ 275/root @ why: ~ # Where-a is and (-o is or);-user is to find that the owner is jerry, and-group is to find that the owner group is jerry; find/-perm-777-type d-ls -------------------------------------------- 5. Search for files containing the specified content in grep! (This is the command I have been looking !) E.g.: grep-R jerry/etc (search for all directories in/etc with files containing jerry (parameter-R indicates all files) If you only want to list file names: www.2cto.com grep-R-l jerry/etc (-l only lists file names) 01root @ why :~ # Grep-R-l jerry/etc02/etc/passwd03/etc/shadow-04grep:/etc/alternatives/ghostscript-current/Resource/CMap/Hojo-EUC-H: there is no file or directory 05 grep:/etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF16-H: There is no file or directory 06 grep: /etc/alternatives/ghostscript-current/Resource/CMap/Hojo-H: No that file or directory 07 grep:/etc/alternatives/ghostscript-current/Resource/CMap/Adobe-Japan2-0: there is no such file or directory 08 grep:/etc/alternati Ves/ghostscript-current/Resource/CMap/UniHojo-UTF8-V: There is no file or directory 09 grep:/etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UCS2-V: there is no file or directory 10 grep:/etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UCS2-H: There is no file or directory 11 grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF32-V: No that file or directory 12 grep:/etc/alternatives/ghostscript-current/Resource/CMap/Hojo-V: no file or directory 13gr Ep:/etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF32-H: No that file or directory 14 www.2cto.com grep: /etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF16-V: No that file or directory 15 grep:/etc/alternatives/ghostscript-current/Resource/CMap/UniHojo-UTF8-H: there is no file or directory 16 grep:/etc/alternatives/ghostscript-current/Resource/CMap/Hojo-EUC-V: no such file or directory 17/etc/alternatives/ghostscript-current/lib/ps2ascii. Ps18/etc/gshadow-19/etc/group20/etc/shadow21/etc/mtab22grep:/etc/blkid. tab: No file or directory 23/etc/passwd-24/etc/group-25/etc/gshadow26root @ why :~ #27_____________________________________________________________________________________28 ###################################### ######################################## ############## 29 ######################### ######################################## ########################## 30 www.2cto.com let's look at the packaging and compression commands: 31 packaging and compression are different operations. do not consider windows ideas. 32 1. Package 33 tar cvf/tmp/root.tar/home/jerry/etc/passwd/etc/shadow34 (the c parameter indicates packaging, and v indicates the process is visible, f is the file that follows) 35 tar rvf/tmp/root.tar/home/jerry/a.txt36(rfolder is the file to be added, a.txtto the root.tar package) 37 tar xvf/tmp/root.tar-C. 38 (the x parameter is used to uncompress the package. The-C parameter is the specified decompression location.) 39 tar tvf/tmp/root.rar 40 (The t parameter is used to view the content in the package. You can understand it before unzipping it) 41 II. Package and compress 42 tar cvfz/tmp/root.tar.gz/etc/passwd43 (z indicates gzip compression mode) 44 tar cvfj/tmp/root.tar.bz2/etc/passwd45 (j indicates the compression method of bzip2, the compression ratio is higher than that of gzip) 46 www.2cto.com 3. Compression 47 (1) gzip compression tool 48 gunzip decompression 49 (2) bzip2 compression tool 50 bunzip2 decompression (compression ratio higher than gzip) by Jerryz

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.