Linux Common Command Collation 20150823

Source: Internet
Author: User
Tags parent directory

Project Command Command explanation Example description
Text View commands Cat View the file as text, from the first line to the last line Command format: Cat [OPTION] ... [FILE] ...
-N option with line number
-E: Display line terminator
-V: Display nonprinting characters
Example
Cat-n-e/etc/fstab with line number Shenzhen fstab content, and display line terminator
Cat/etc/shells Direct display of shell types
Text View commands Tac Features similar to Cat, from the last line to the first line Command format: tac[option] ... [FILE] ...
Example: Cat/etc/shells
Text View commands More Show files: More rear end does not support forward flipping
-D: Display page with Exit prompt
Quick:
Space: one screen back
Enter: one line backward
B: one screen ahead

Command format: More [options] file [...]

Example: MORE/ETC/PASSWD

MORE–D/ETC/PASSWD Show passwd file with quick tips

Text View commands Less Display file, support search, less tail support forward rollover
/search keywords? search keywords
N: Next with the same direction as the command
N: The previous one in the opposite direction of the command
Quick:
E or return line after row y previous line
F Forward one screen B back to one screen
D Forward half screen u back half screen
Command format: Less [OPTION] ... FILE ...
Example: LESS/ETC/PASSWD
Text View commands Tail Outputs the display from the specified location (can specify rows, bytes, etc.)
If the file is displayed by default after 10 lines
Command format: tail [options] file [...]
-C--byte=k Output last byte position output file
Example:
Tail–c 20/etc/passwd output from the last 20 characters of the file
Example:
TAIL–F/ETC/PASSWD the same as the TAIL/ETC/PASSWD output, 10 lines after the default file
Tail–f–n 11/etc/passwd display after 11 lines
Tail–f file name is used to display the added content
Text View commands Head Outputs the file from the specified location, starting at the beginning of the file header. The default is the first 10 rows Command format: Head [options] file [...]
Example:
Head-n 11/etc/passwd show passwd top 11 rows of files
Head-c 11/ETC/PASSWD Display the first 11 characters of the passwd file
File content View File File content Type view commands, file types include UTF-8, binary, ASCII, etc. Command format: File [OPTION ...] [FILE ...]
Example: File/etc/shells input as "ASCII text"
Command History view History View history commands to invoke execution Command format: Reference help History
-C Empty command history-D #: Deletes the specified command #号编号
Example HISTORY–D42 Delete 42 rows of records
History 20, displaying the last 20 rows directly, starting with the final record
!! Executes the last command executed
!39; command to display line 39th in the history record
Command aliases Alias Device Command aliases command Format Alias:alias [-P] [Name[=value] ...]
Example: Alias output an existing configuration alias
Alias printwd=pwd configuration pwd is aliased to PRINTWD
Command aliases Unalias Canceling command aliases command Format Unalias [-a] name [name ...]
-A refers to all
Example: Unalias printwd cancel PRINTWD's life
Directory Management Classes Mkdir Create a Directory Command format: mkdir [OPTION] ... DIRECTORY ...
-P Create parent Directory
-V Show creation process
Example:
Mkdir-pv/tmp/51cto/{x,y}_{m,n} creates a 51cto directory under the TMP directory, and
X_m, X_n, Y_m, Y_n directory
Directory Management Classes RmDir Delete directory, valid only for empty directory Command format: rmdir [OPTION] ... DIRECTORY ...
Example:
RmDir 51cto directly delete the 51cto empty directory
RMDIR-PV./{x,y}_{m,n}, delete empty directories under Tmp/51cto directory for X_m, X_n, Y_m, Y_n
Directory Management Classes DirName If it is a file: Remove the file name (part of the non-directory) from the given file name that contains the absolute path, and then return the remaining path (part of the directory)
If the directory will output the top level
Command format: dirname [OPTION] NAME ...
Example:
Dirname/tmp/51cto/x_m display the top level directory of the current directory

The dirname/etc/yum.conf output is "/etc

Directory Management Classes BaseName If the directory is later displayed, the current directory is not displayed before the absolute path portion of the current directory
If it is a file, only the file is displayed
Command format:

BaseName NAME [SUFFIX]
BaseName OPTION ... NAME ...
Example:

The basename/tmp/51cto/x_m output is: x_m

basename/etc/yum.conf output to Yum.conf

touch Time access times, Modify time and change times, also included in version 7, birth the
change  the system automatically manages
Command format:
Touch [ OPTION] ... FILE ...
-a means that only modified access time
-M represents the Modify time update
Example:
Touch tailfile tailfile file Atime, mtime, CTime update to current time
Touch-a-T 20140 8241304.20 tailfile Modify Tailfile file Atime is August 24, 2014
Touch-m-T 201408241304.20 tailfile Modify the Mtime for the Tailfile file to August 24, 2014
touch/tmp/testing Create testing empty file
CP Copy files and directories, copy source to target, or multiple sources to the target
source is a file:
   1: If the target does not exist, create a new directory and copy the source file to the catalog file
  2: If the target is present, overwrite if the target is a file, if the target has the same name in the directory, Copy the source content to the destination file
command format:
CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE ... Directory
CP [OPTION] ...-t DIRECTORY SOURCE ...
-r-r Recursive replication  -D do not track symbolic links   -A All permissions  -I interactive  -F Force   -V Display procedure
Example:
cp-r./51cto. /51ctobak  Copy all files in the 51cto directory to the 51ctobak directory
        If you do this again, create a new 51cto catalog in the 51ctobak directory
Cp–r-v./51cto storage.log./51ctobak Copy the files and Storage.log in the 51cto directory to the 51ctobak directory (requires the 51ctobak directory to be created first) and display the copy process
File Manager Mv Move or rename a file or directory
Command format:
MV [OPTION] ... [-T] SOURCE DEST
MV [OPTION] ... SOURCE ... DIRECTORY
MV [OPTION] ...-t DIRECTORY SOURCE ...
-F Mandatory, silent-I interaction
Example:
MV 51ctobak 51cto Change directory 51ctobakg to 51cto
Mv-v/tmp/51cto/51cto/tailfile/tmp/51ctobak Copying files to the 51ctobak directory
MV Tailfile tailfile2015 Change tailfile file in the same directory to tailfile2015
File Manager Rm Delete files or directories, remove directories By default, add-R or-R options Command format:

RM [OPTION] ... FILE ...

-F Force Delete-I interactive mode-r–r remove directories and subdirectories
Example:

Rm-v-F 1.txt Delete the current directory? 1.txt file
Rm-r-f-v 51cto Delete 51cto directory with all of the following files

Text Processing Tr deleted, converted characters from standard output Command format:

TR [OPTION] ... SET1 [SET2]

-D Delete all characters in the specified character set

Example:

Cat trfile|tr "abc" "MNO" >newfile replace "abc" in A.txt file with an MnO "and save in A.txt

Cat trfile|tr [: Lower:] [: upper:]>upper.txt convert trfile all lowercase to uppercase saved in upper

Tr-d ' a-c ' <upper.txt removes a-c characters from the Upper.txt file, and the output displays

Ifconfig|tr ' A-Z ' A-z ' output ifconfig content is uppercase

IFCONFIG|TR [: Lower:] [: Upper:] The result is the same as above

Multi-directional Tee Read-write from standard input file to output file, used with pipeline, multiple output redirection Command format:

Tee [OPTION] ... [FILE] ...

Example:

Cat upper.txt|tee file1.txt file2.txt upper.txt file output file1.txt and File2.txt

Ls/tmp/51cto|tee tmp51ctofile.txt Copy the contents of the Tmp/51cto directory to the Temp51cto

Text Processing Tools Wc File Word Count Statistics Command format:

Synopsis
WC [OPTION] ... [FILE] ...
WC [OPTION] ...--files0-from=f

-L line number –m character-C byte-l maximum Length-W word number
Example:
Wc-l file1.txt Output file file1.txt number of rows
Wc–l file1.txt length of the longest line
Wc-w file1.txt file file1 number of words
Text Processing Tools Cut Remove information from a line in a file that does not need to be displayed Command format:

Cut OPTION ... [FILE] ...

-D: Indicates the delimiter default space

-F: Indicates the field to be displayed m: column per m m,n n column per m, M-n, m-n column

Example:

Cut-d:-f1,6/etc/passwd display passwd file with: As delimiter, show 1–2 and every 6 fields

sort text file content sort Command format:
sort [OPTION] ... [FILE] ...
            -r: Reverse
            -F: Ignore character case
            -u: Sort after
           -t CHAR: Specify delimiter
           -K #: Field
            -N: Indicates a numeric size
Example:

Sort-t:-k3/etc/passwd  Displays the passwd file under the ETC directory, The third field is sorted by a colon delimiter (ASCII code in characters)

Sort–n-t:-k3/etc/passwd ibid., by value size

Text Processing Tools Uniq Omit duplicate rows for continuous repetition only. If the display is unique, you can use the sort file |uniq to display Command format:
Uniq [OPTION] ... [FILE] ...
-C Times
-D displays only duplicate rows
-U print only rows that are not duplicated
Example:
Uniq uniq.txt Show content in Uniq, repeat only once

Linux Common Command Collation 20150823

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.