which: command search
# which ls //Equivalent to # whereis vim // alias creates an alias for the command, for example alias ls ='ls -- color=auto' # which pwd
find: file search, for file names
find [path...path] [options] [expression] [action] find /etc -name "hosts" //Quotation mark: escape character
Find by file size
# find /etc -size +5M # find /etc -size 5M # find /etc -size -5M
Specify the path depth to search directories
# find / -maxdepth 3 -a -name "ifcfg-en*"
Search by file owner and group
# find /home -user jack //File whose owner is jack # find /home -group hr //File whose owner is group hr
by file type
# find /tmp -type f // f ordinary file b block device file l link file
By file permissions
# find . -perm 644 -ls// -ls long look (action)
Processing actions ACTIONS after finding
# find . -perm 714 -print # find . -perm 714 -delete //Delete //Copy # find /etc - name ifcfg* - ok cp - rvf {} /tmp \; //Copy the file ifcfg* to tmp
locate: file search, dependent on database
File packaging and compression
Pack, compress
Syntax: tar option compressed package name source file
-czf -cjf -cJf
# tar - cf etc.tar /etc //Packaging only # tar - czf etc-gzip.tar.gz /etc //z is gzip packaging and compression
Unzip, unpack
# tar -tf etc.tar //t View f file name # tar -xf file name // resolve to current location # tar -xf file name -C target path // redirect to / target path