Link of the little books - remember some basic linux command

View shell

  • cat / etc / shells view supported by the system shell
  • echo $ SHELL view the shell currently in use

hot key

  • Ctrl + a jump to the beginning of the line
  • Jump to end of line Ctrl + e
  • Ctrl + u delete the contents of the cursor to the beginning of the line
  • Ctrl + k delete the contents of the cursor to the end of the line
  • Ctrl + <- cursor jumps from one word before their recent
  • Ctrl + l clear screen

Command substitution

The sub-command of a command to replace its results

  • $ ( The COMMAND ) (recommended)
  • 'COMMAND'

Command Line Expand

  • ~ Expands to the user's home directory
  • ~ USERNAME expand the user's home directory for USERNAME
  • {} May carry a comma-separated list, and expand it into a plurality of directories, e.g.
    • /tmp/{a,b} = /tmp/a, /tmp/b
    • /tmp/{tom,jerry}/hi = /tmp/tom/hi, /tmp/jerry/hi

File name wildcard

  • * Any character of any length match
  • ? Matches any single character
  • [] Single character matches any range
  • Any single character [^] matches any outside range
    • [abc] [a-m] [0-9]
    • [[: Space:]] blank character
    • [[: Punct:]] punctuation
    • [[: Lower:]] lowercase
    • [[: Upper:]] uppercase letters
    • [[: Alpha:]] uppercase and lowercase letters
    • [[: Digit:]] numbers
    • [[: Alnum:]] lowercase letters and numbers

Environment Variables

  • PATH Command search path (the system will search command from the File this path, if this changed, is likely to lead to unusable part of the command)
  • HISTSIZE command history buffer size
  • SHELL current shell

Command aliases

Only within the life cycle of the current shell

  • alias CMDALIAS='COMMAND [options] [arguments]'

Command Type

  • linux is divided into two commands
    • Internal command, shell built
    • External command, a command name corresponding to the executable file in the file system
  • type display command type

Directory Management

  • ls List directory contents
  • Options:
    • -l long format
      file types:
        • Trivial File (f)
      • d directory file
      • b block device file (block)
      • c character device files (character)
      • l symbolic link (symbolic link file)
      • p command duct (pipe)
      • s file socket (Socket)
    • -h user-friendly unit conversion
    • -a show hidden files (files beginning of)
    • -d display their own property directory
    • inode -i display files
    • -r reverse display
    • -R (recursive)
  • cd Change directory
  • psw view the current directory path
  • Create a directory msdir
  • Options:
    • -p create a directory that does not exist if the parent directory is created
    • -v displays the directory creation process
  • View directory tree tree
  • Options:
    • -d display only directory
    • the -l the LEVEL layers designated display
    • -P PATTERN display only the specified PATTERN matched path

Document Management

  • touch creates an empty file, or modification timestamps
  • stat view the file or file system status
  • rm delete files
  • Options:
    • -r recursive delete
    • -f Forces deletion
    • Rm before adding that \ rm may also play a role to force the removal of
    • Do not hand cheap to delete / bin /, / usr / etc directory systems, "Linux deleted from the library to the foot '
  • cp copy files
  • Options:
    • -r recursive copy, catalog copy must bring
    • -a archive copy, commonly used in backup
    • -p with permission to copy
  • mv move files
  • install copy files and set the properties, often used to install or upgrade software or backup data
    options:
    • -m mode mode, set permissions on their own
    • -o owner mode, set their own owner
    • -g group mode is a group set their own

Compression, decompression command

Compression format: gz, bz2, xz, zip, Z

  • After compress the compressed file named FILENAME .Z
    • uncompress decompress
  • After gzip compressed file named FILENAME .gz, deletes the original file
  • Options:
    • -d decompression, will delete the original file
    • -c output
    • - # [ 1-9 ] specify the compression ratio, the default 6
  • gunzip decompression, will delete the original file
  • To see what text is not the case zcat decompression
  • The bzip2 compressed file named FILENAME .bz2, more than gzip compression ratio, similar format
  • Options:
    • -d decompression, will delete the original file
    • -k keep the original file compression
    • - # [ 1-9 ] specify the compression ratio, the default 6
  • bunzip2 it will delete the original file
  • After the xz compressed file named FILENAME .xz
  • Options:
    • -d decompression, will delete the original file
    • -k keep the original file compression
    • - # [ 1-9 ] specify the compression ratio, the default 6
  • unxz decompression, will delete the original file
  • View text without extracting case xzcat
  • both zip archive and compression, you can compress the directory, do not delete the original file
    • zip filename.zip file1 file2
    • zip filename.zip DIR/*
  • unzip it, do not delete the original file
  • archive archive without compression
  • tar archive without compression (common)
  • Options:
    • -c to create an archive
    • -f file.tar specified archive file operations
    • -x Restore Archive
    • -cf archive, f option must be before the file name in the archive
    • -xf extracting archive, f option must be before the archive before the file name
    • -v Show Details
    • -P rights reserved usage rights information, only administrators have this option
    • Save -C archive will be expanded to the specified directory
    • --delete delete files from the archive
    • Reserved extended attribute information --xattrs archive
    • -tf not expand the archive, the archive to see which files directly
    • -tvf not expand the archive, the archive to see which files directly, you can view detailed information about the archive
    • -zcf archive and call gzip compression
    • -zxf call gzip unzip and expand the archive
    • -jcf archive and call bzip2 compression
    • -jxf call bzip2 decompression and expand the archive
    • -Jcf archive and call xz archive
    • -Jxf call xz decompress and expand the archive

View Text

  • cat stitching contents of the file and output to standard output, use cat to see all the contents of the file will file loaded into memory, so you should avoid using cat to open huge files
    • -n Display line numbers
    • CAT A b >> c stitching contents of the file
  • tac-linked files and print content flashback to standard output, and is similar to cat. However, this command does not use any eggs
  • more full-screen view text files. Only from front to back, the display automatically exit finish
  • less full-screen view text files. You can also forward back, more than high enough to not know where to go. Recommended Use
  • Options:
    • -N display line numbers for each line
  • hot key:
    • / String: Down "character string" feature
    • ? String: up search for "string" feature
    • n: a search before repeating (and / or related?)
    • N: a search (and / or related?) Before the inverted repeat
    • b back down one page
    • d Half-page Backward
    • h Display help screen
    • Q to exit the less command
    • u Scroll half a page forward
    • y Scroll forward one row
    • Spacebar to scroll one
    • Enter to scroll one line
    • [Pagedown]: Scroll down a
    • [Pageup]: flipping up a
  • head view text file header content, the default print 10 lines
    • Options:
    • -n Specifies the number of lines to be printed, can be -n [ NUM ], may be - [ NUM ]
  • tail end of the file to view the text content
    • Options:
    • -n Specifies the number of lines to be printed, can be -n [ NUM ], may be - [ NUM ]

Text Processing

  • cut intercept text
    • Options:
    • -d specified field separator, the default is a space
    • -f field area to be displayed, in conjunction with -d
      • 1 and 3 show -f 1,3
      • 1 to 4 show -f 1-4
    • -b divided in bytes, to be displayed can be specified byte range
  • sed filter based on the converted text editor flow line, can be substituted for the field
    • Options:
    • -e [ script ] to specify the script options to process the input text file
    • -f [ script file ] option to specify a script file to handle the input text file
    • command:
    • a text inserted below the current line.
    • i is inserted in the current line of text above.
    • c The selected line to the new text.
    • d delete, delete the selected row.
    • The first line D delete the template block.
    • s replace the specified character
    • = Print the current line number.
  • awk column of text-based reporting tool

Sort Text

  • default ascending sort, not sorted by the numerical size
    • Options:
    • Sort the numerical size -n
    • -r reverse order
    • -t field delimiter
    • -k to which field to sort the keyword
    • -u deduplication, sorting and displaying the same line after one line only
    • -f ignore case when sorting
  • uniq report duplicate rows
    • Options:
    • -c displays the file number of repetitions of the Bank of China
    • -d display only duplicate rows
    • -u only appear as duplicate rows

Text Statistics

  • wc Statistics
    • Options:
    • shows the number of bytes -c
    • -l number of display lines
    • -w displays the number of words

System Statistics

  • du view files or directories take up disk space
    • Options:
    • -h user-friendly unit conversion
    • -s Displays the total occupancy
  • df report file system disk space usage
    • Options:
    • -h user-friendly unit conversion
    • -i display inode information

Hostname Management

  • To view or modify temporary hostname hostname, survival before shutdown
  • hostnamectl view or permanently change the host name, to the permanent survival

other

  • time it takes to execute a command display time
  • clear clear the screen, more recommended shortcuts
  • whoami view the current logged-on user, can also be written who am i
  • w Displays the current online users and displays the program in its run
  • who view the current online users
  • which displays the absolute path is specified command
  • date display or set the date and time
    • Options:
    • -s disposed string time
    • Formatted output time +
      • % Y Year
      • % M month
      • % D day
      • When the H%
      • % M points
      • % S seconds
  • cal Calendar Print
  • bc math decimals (not used) during operation
  • ldd viewer dependent
    • Binaries
    • Library file
    • Help Files
    • Settings file

Guess you like

Origin www.cnblogs.com/lynk/p/12061692.html