1. ls
Displaying folder folders and files
How to use: ls-lt
-A display folder under All files and folders included. And.. -A display folder where all files and folders are not included. And.. -L Show All files and folders under folder specific information-T sort by change time (reverse)-F such as folder after Add/If you can run the file after adding *-r by file name alphabetical order (reverse)-R display folder all folders and files (including subfolders)
2.
Cat
Output after concatenating the contents of a file
How to use:
cat file1 file2 filen
-N number of rows with all outputs plus ordinal-b non-blank lines for all outputs plus ordinal-s such as two consecutive lines or more blank lines, instead of one line
3.
chmod
Update folder or file permissions
How to use:
chmod a+x * *
Ugoa +-= Rwx-c If the changes after the permissions and different, display change message-V display change message-F hidden Error-R traversal set permissions (subfolders)
4.
Chown
Update folder owners and groups
How to use:
chown-r root:root *
-R Traversal Settings (sub-folders)
5. CP
Local copy folder and file
How to use: cp-a source Dest
-a preserves the permissions of the source file and other messages-R traversal copy (subfolder)-F when the target file and the original file name, delete the target file, and then copy
6.
Cut
Display the contents of the File Contents n-m column
How to use:
cut-c1-6 file
-C Displays the NUM1 to num2 text from the beginning of each line
7. RM
deleting files
How to use: rm-rf file or folder
-I delete the first query to confirm-F even if the file is forced to delete only read, do not need to confirm the-R traversal Delete (subfolder)
8.
rmdir
Delete a folder
How to use:
rmdir folder
-P assumes that the subfolder is empty after it is deleted.Note: The parent folder is deleted until the parent folder is not empty.
9.
Unzip
Decrypt
How to use:
unzip-p 123456-d path o.zip
-P <password> zip archive password-f overwrite the original file-D < path > Specify decompression path-n decompression without overwriting the original file-o without asking, directly overwrite the original file-u overwrite the original file, and extract other files in the compressed file into the folder-L display files included in the compressed file-t check that the compressed file is correct-Z unzip-z equals run zipinfo instruction-j do not process the original folder path in the compressed file-C Compressed file file name is differentiated between uppercase and lowercase-Z Show compressed Package stare-L change all the file names in the compressed file to lowercase-s to convert the space in the file name to an underscore-X extract when the original UID/GID-Q runtime does not display no matter what information-v run is displayed specific information-C displays the extracted results to the screen, and the appropriate conversion of the characters-P and-C are similar, will be decompressed results displayed on the screen, but will not run no matter what the conversion-a text file to do the necessary character conversion-B do not convert the text file character-x < expression > exclude the specified file in the compression package-M Send output to more program processing
Ten. zip
Encryption
Mode of Use: zip-q-R d.zip Folder/file
-A adjusts the active unzip files that can be run. -B < Working folders > specifies the folder where files are temporarily stored.-C adds a gaze to each compressed file. -d deletes the specified file from within the compressed file. The folder name is not established within the-D compressed file. -F The effect is similar to specifying "-u", but not only updates the existing files, assuming that some files do not originally exist in the compressed file, using this parameter will add them to the compressed file. -F attempt to repair a corrupted compressed file. -G compresses the file after it is appended to the existing compressed file. Instead of creating new compressed files. -H online Help. -I < Template style > only files that match the criteria are compressed. -j simply saves the name of the file and its contents, regardless of the folder name.
-J Delete unnecessary data before compressing the file.
-K uses a file name called MS-DOS compatible format.
-L When compressing a file, replace the LF character with the LF+CR character. -ll the LF+CR character into the LF character when compressing the file.
-L displays copyright information.
-M compress the file and add the compressed file, delete the original file, the file is moved to the compressed file. -N < Tail string > does not compress a file with a specific trailing string. -O to compress files that have the most recent change time in the file, set the time to change the compressed file to the same as the file. -Q does not show instructions to run the process.
-R recursive processing. All files and subfolders under the specified folder are processed together. -S includes system and hidden files. -T < date time > set the date of the compressed file to the specified date. -T checks that each file within the backup file is correct. -U replace the newer file into the compressed file. -V Displays the instruction run process or displays the version number information. -V Saves the file properties of the VMS operating system.
-W in the name of the file if the version number is numbered, this reference is only valid under the VMS operating system.
-X < Template style > exclude eligible files when compressing. -X does not save additional file attributes.
-Y saves the symbolic connection directly, not the file that the connection points to, and this parameter is only valid under systems such as UNIX. -Z for compressing files plus gaze.
-$ the name of the disk on which the first compressed file is stored. -< compression Efficiency > Compression efficiency is a value between 1-9.
One. Find
Find files and folders
How to use:
find Path-mtime 3-type f-exec ls-lt {} \;
-atime N Last access time n days ago-mtime n Last update time n days ago-name name includes-user user username including-newer otherfile than a file new-type type F: File D: Folder! Not-a and-o or-print Print file name-mount do not search other problematic system folders-maxdepth n Maximum number of layers to search for folders-mindepth n search for the contents of the folder before viewing the folder itself-depth The file or folder is empty-exec command {} \; Run-ok command {} \; Run command, user confirmation required for each run
.
grep
The
How to use:
grep-c "string" file1 file2
-C displays only the number of rows that match-I does not distinguish between uppercase and lowercase-l only show file name-H does not display prefix file name-v display unmatched number of rows-E extended mode (using regular)-n displays the number of rows matching rows in the file-X just prints the row of rows matched-ax displays the line after row-by Show match line before Y line-cz display match line before and after Z line
SCP
Remote Copy folder and file
How to use:
SCP LocalFile [Email Protected]:remotefolder
SCP [Email Protected]:remotefile localfolder
Scp-r Localfolder [Email protected]:remotefolder
scp-r [email protected]:remotefolder localfolder
-r Copy folder and all sub-file Clip files (traversal)
DF du
DF View File system capacity
Du viewing folders and file sizes
How to use:
Du-h--max-depth=1 Folder
Df-h
-h displays dimensions in a more readable way (e.g. 1K 234M 2G)--max-depth=n N Query Depth
.
Ln
Create a file or folder link
How to use:
Ln-s source file/source folder destination file
Ln-s/home/fdipzone/demo Link creates a folder link in the current folder links to/home/fdipzone/demo
Description: In the Linux/unix file system, there is the so-called link (link). We can think of it as the alias of the file, and the link can be divided into two kinds: hard link and soft link (symbolic link), hard link means that a file can have multiple names, and the soft link is the way to produce a special file, The contents of the file refer to the location of a file. Hard links exist in the same file system, while soft links can span different file systems.
LN Source Dist is the generation of a link (dist) to the source, as for the use of a hard link or a soft link is determined by the parameters.
Either a hard link or a soft link does not copy the original file, only takes up a very small amount of disk space.
-F: The link will be the same file with dist Delete-D: Consent to the System Manager hard link to their own folder-I: In the deletion of files with the dist file with the first query-N: In the soft link, the dist as a generic file-s: Soft link (symbolic li NK)-V: Displays its file name before the link-B: Files that will be overwritten or deleted at the end of the link are backed up by the-s SUFFIX: The backed up files are prefixed with SUFFIX-V method: Specify how the Backup--help: Show Auxiliary description--version: Display Version number
16.
Locate
The locate allows the user to search the file system for the specified file in a very high speed. The method is to set up a database that includes all the file names and paths within the system, and then only need to query the database when looking for it, without actually going into the file system.
In the general distribution, the establishment of the database is placed in the Contab to run their own initiative.
How to use:
Locate filename
Locate [-Q] [-d] [--database=]
Locate [-R] [--regexp=]
Locate [-QV] [-O] [--output=]
Locate [-E] [-f] <[-l] [-c] <[-u] [-u]>
Locate [-VH] [--version] [--help]
Locate Chdrv: Looking for all the files called Chdrv
Locate-n a.out: Look for all the files called a.out, but show only a maximum of 100
Locate-u: Building a Database
-u-u The database is created,-U is started by the root folder, and-u can specify where to start.-E will be excluded from the scope of the search. The-l hypothesis is 1. The security mode is started. In safe mode, the user does not see files that the permissions cannot see. This slows down as the locate must obtain access to the file in the actual file system. -F excludes specific file systems, for example, we have no reason to put the files in the proc file system in the database. -Q Quiet mode, no error messages are displayed. -N displays at most x outputs. -R uses the normal arithmetic to do the searching condition. -o Specifies the name of the data inventory. -d Specifies the path of the repository-H displays the secondary message-V displays many other messages-V displays the version number of the program message
.
WC
How to use:
WC [option] file1 file2
Wc-l file
Ability to combine WC-LCW file1 file2
-C Count Bytes-l count Rows-W count words
wget .
How to use:
wget [Options] [URL]
Wget-o Test.zip Http://www.fdipzone.com/test.zip
Start:-V,--version displays the wget version number after exiting-H,--help print syntax help-B,--background to the background run-E,--execute=command run '. Wgetrc ' Format command, WGETRC format See/ETC/WGETRC or ~/.wgetrcwget The default is to use the-e Robots=off parameter to bypass the restriction record and input file according to the robots.txt of the site:-O,--output-file=file Write the record into the file-A,--append-output=file append the record to the file-D,--debug print debug output-Q,--quiet quiet mode (no output)-V,--verbose verbose mode (this is the default setting)- NV,--non-verbose turn off verbose mode, but not quiet mode-I,--input-file=file download the urls-f that appears in the file files,--force-html treats the input file as an HTML file for-B,--base= The URL takes the URL as a prefix to the relative link that appears in the file specified by the-f-i parameter--sslcertfile=file optional client certificate--sslcertkey=keyfile optional client certificate keyfile--egd-file= File name for EGD socket Download:--bind-address=address Specifies the local use address (hostname or IP, used when there are multiple IPs or names locally)-T,--tries=number sets the maximum number of attempts to link (0 means no Limit ).-O--output-document=file write the document to file-nc,--no-clobber do not overwrite the existing file or use. #前缀-C,--continue then download the files that are not downloaded--progress=type Set the process bar flag-N,--timestamping do not download the file again unless it is newer than the local file-S, the--server-response print server response--spider not load whatever thing-T,--timeout=seconds Set the number of seconds for response timeout------wait=seconds interval between two attempts SECONDS seconds--waitretry=seconds wait between links again 1 ... SECOnds seconds--random-wait between downloads wait 0 ... 2*wait sec-Y,--proxy=on/off turn Agent-Q on or off,--quota=number set the download capacity limit--limit-rate=rate limit download Transmission folder:-nd--no-directories Do not create folder-X,--force-directories Force Create folder-nh,--no-host-directories do not create host folder-P,--directory-prefix=prefix save file to Folder Prefix/...--cut-dirs=number Ignore Number Layer Remote folder HTTP option:--http-user=user set HTTP user name to User.--http-passwd=pass Set Httppassword to Pass.-c,--cache=on/off Agree/disagree with the server-side data cache (generally agreed).-E,--html-extension will all text/ HTML documents are saved with an. html extension--ignore-length ignore ' content-length ' header fields--header=string insert strings in headers String--proxy-user=user Set the agent's user name to User--proxy-passwd=pass set proxy password for pass--referer=url include ' Referer:url ' head-S in the HTTP request,--save-headers Save HTTP header to file-U,--user-agent=agent set proxy name to Agent instead of Wget/version.--no-http-keep-alive close HTTP active link (forever link).--cookies=off Do not use Cookies.--load-cookies=file to load cookie--save-cookies=file files from file before starting session FTP option to save cookies to file files after the session is over:-NR,-- Dont-remove-listing do not remove the '. Listing ' file-G,--glob=on/off the globbing mechanism to open or close the file name--passive-ftp use passiveTransfer mode (default).--ACTIVE-FTP uses the active transfer mode--retr-symlinks at the time of recursion. Link links to files (not folders) recursively download:-R,--recursive recursive download--use!-l carefully,--level=number maximum recursion depth (INF or 0 for Infinity).--delete-after locally Delete the file after today's finish-K,-- Convert-links converts a non-relative link to a relative link-K,--backup-converted before the file X is converted. Back it up as x.orig-m,--mirror equivalent to-r-n-l inf-nr.-p,--page-requisites download shows all images of HTML files in the recursive download include and not included (Accept/reject):-A,--acce Pt=list semicolon-delimited list of accepted extensions-R,--reject=list semicolon-delimited list of unacceptable extensions-D,--domains=list semicolon-delimited list of accepted domains--exclude-domains=list Semicolon-delimited list of non-accepted domains--follow-ftp trace HTML documents in the FTP link--follow-tags=list semicolon-delimited list of tracked HTML tags-G,--ignore-tags=list Semicolon-delimited list of ignored HTML tags-h,--span-hosts when recursion goes to external host-L,--relative only tracks relative link-I,--include-directories=list consents to the list of folders-X,-- Exclude-directories=list is not included in the list of folders-np,--no-parent do not go back to the parent folder
.
Tar
How to use:
tar [-cxtzjvfppn] files and folders
TAR-XZVF test.tar.gz
-C: Set up the parameter of a compressed file (the meaning of Create);-x: Unlock the parameters of a compressed file! -T: View the files inside the Tarfile!Pay special attention to the release of the number of references. C/X/T can only exist one. Do not exist at the same time! Because it is not possible to compress and decompress at the same time.
-Z: Is there a property with gzip at the same time? Is gzip compression required? -j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2? -V: Files are displayed during compression!
This is often used, but it is not recommended to run the process in the background! -F: Use the file name. Please note that after F, you need to pick up the name immediately. Do not add the number of references. For example, the use of "TAR-ZCVFP tfile sfile" is the wrong way to write "TAR-ZCVPF tfile sfile" to-P: Using the original file's original properties (properties will not change according to the user)-P: can use absolute path to compress. -N: Newer than next date (YYYY/MM/DD) will be packaged into the new file! --exclude FILE: In the process of compression. Don't pack the FILE!
tail .
How to use:tail [-FQVCN] File
Tail-f Test.log
Note that-F is the abbreviation for--follow[=how] and can read the characters at the end of the file and print them.
[=how] has two notation, =descriptor and =name default to use descriptor, assuming that you track the file is moved or renamed, but also want to continue tail, to use this option.
But suppose that when tail a log file, this file is very likely to be deleted or overwritten, after the file is overwritten, the tail-f command will be invalidated, such a situation requires the use of the TAIL-F command
-F is an abbreviation for--follow=name-retry, and--follow=name is a file-by-file name. Be able to go again and again to open the file check whether the file is deleted by other programs and set up again,-retry this parameter, to ensure that the file once again established, can continue to be tracked.
--follow=descriptor Sample Example
1.sh
#!/bin/bash while:d o echo $ (date +%y-%m-%d '%h:%m:%s) >> ' 1.log ' sleep 1done exit 0
2.sh
#!/bin/bash while:d o echo $ (date +%y-%m-%d '%h:%m:%s) >> ' 2.log ' sleep 1done exit 0
1. Run in Form 1./1.sh
2. Run tail- f 1.log in Form 2. You will see an output
3. Abort 1.sh
4. Run MV 1.log 2.log renaming
5. Run./2.sh you will see that the tail of form 2 will output 2.log of content.
--follow=name Sample Example
1. Run in Form 1./1.sh
2. Run tail- f 1.log in Form 2 and you will see an output
3. Run RM 1.log, when tail no longer outputs whatever content
Instead, use tail- f 1.log. after you run RM 1.log, when 1.log is created. The tail will continue to output 1.log content. since./1.sh is a loop run, it is created when 1.log does not exist
Shuf .
Function: Outputs the input lines to the standard output in a random order.
How to use:
Shuf [Options] ... [File]shuf-e [options] ... [Parameters]...shuf-i Lo-hi [options] ...
Main Number of references:
-E,--echo each of the parameters as the input line-I,--input-range=lo-hi treats each number of LO to HI as the input row-N,--head-count= the maximum number of rows to output the specified row-O, The output= file outputs the result to the specified file instead of the standard output --random-source= file to obtain a random bit-Z from the specified file,--zero-terminated ends the line with 0 instead of the new line- - Help displays this helpful information and exits --version Displays the version number information and exits
Examples:
1. Output test.txt in random order to standard output
Shuf test.txt
2. Randomly fetching a line from the Test.txt
Shuf-n 1 Test.txt
3. Output test.txt in random order to Test1.txt
Shuf Test.txt-o Test1.txt
22.command-v
Enter Command path location
$ command-v Ls/bin/ls
Whereis ls
$ Whereis Ls/bin/ls
Linux_ often use commands