100 Common Linux Command Daquan

Source: Internet
Author: User
Tags clear screen create directory define function diff file copy cpu usage disk usage

1.ls [Options] [Directory name | list all directories and files in the relevant directory

  -a lists all files that contain a hidden file that starts with a. A-a  , but does not list "." and ".."  -L list File details-c sort by  CTime show-t  sort by file modification time---color[=when] use color to identify file types when can be ' never ', ' always ' or ' auto ' one of them    White: Indicates normal file    blue: Indicates directory    green: Indicates executable file    red: Indicates compressed file    light blue: Link file    flashing red: There is a problem with the linked file.    Yellow: Indicates the device file    Gray: Indicates other files

2.MV [Options] source file or directory directory or multiple source files | Move or rename a file

  -B Overwrite before do backup  -F If there is no query and force overwrite-i  if present ask whether overwrite-U is  newer than overwrite-T to  move multiple source files to the unified directory, directory parameters before, file parameters in the after eg:    MV a/tmp/moves file A to the/tmp directory    mv A B is named a b    Mv/home/zenghao test1.txt test2.txt test3.txt

3.CP [Options] source file or directory directory or multiple source files | Copy the source file to the destination file, or copy multiple source files to the destination directory.

-r-r recursively copy the directory and its subdirectory contents-P together  with the file attributes to copy past  -F does not ask and force copy  -S to generate shortcut  -a copies all attributes of the archive together

4.SCP [parameter] [original path] [Target path] | Copying files and directories between Linux servers

  -v Verbose shows the specifics of the output-R  recursively replicating the entire directory (1) Copying files:  command format:  SCP local_file [email protected]_ip:remote_folder  or  SCP local_file [email protected]_ip:remote_file  or  SCP local_file remote_ip:remote_folder  or  SCP local_file remote_ip:remote_file  1th, 2 specifies the user name, the command executes after the user password is entered, the 1th only specifies the remote directory, the file name is unchanged, 2nd specified the file name  3rd, 4 does not specify a user name, the command executes after entering the user name and password, the 3rd only specifies the remote directory, the file name is not changed, and the 4th specifies the file name   (2) to copy the directory:  command format:  scp-r local_folder [email Protected]_ip:remote_folder  or  scp-r local_folder remote_ip:remote_folder  1th Specifies the user name, the command will need to enter a user password after execution  the 2nd does not specify a user name, the command executes after the user name and password are entered; eg:    copy locally to remote    scp/home/daisy/full.tar.gz [email protected]:/home/root     from remote replication to local    SCP [email protected]/172.19.2.75:/home/root/full.tar.gz/home/daisy/full.tar.gz

5.rm [Options] file | deleting files

-R  Delete folder-F  Delete do not prompt-I  delete prompt-V  verbose display steps

6.touch [Options] file | Create an empty file or update the file time

  -A only modifies the access time-m  value to modify the change time-R  Eg:touch-r a B, making B time and a same-t  specify a specific time eg:touch-t 201211142234.50 Log.log-     t time [[cc]yy]mmddhhmm[. Ss],c: Two years ago

7.PWD View current Path

8.CD changing the current directory

-: Returns the upper-level directory. : Return to Upper directory  : Return to main directory   /: root directory

9.mkdir [options] directory ... | Create a new directory

-p  Recursively create directory, create-m custom Create directory If parent directory does not exist  eg:mkdir-m 777 Hehe-v  Show details of creating a directory

10.rmdir Delete Empty Directory

  -V Shows the execution procedure  -P If the stepfather directory is empty from the parent delete

11.rm [options] File ... | One or more files or directories

-F  ignores nonexistent files, does not give prompt-I  interactive Delete  -R will list directories and their subdirectories recursively delete-V  listing details

12.echo: Display Content

  -N Output does not wrap-e  encounters escape character special handling      eg:        echo "He\nhe"   display he\nhe        ehco-e "He\nhe"    shows he (newline) he

13.cat [Options] [File]..| Display the entire file at once or create a file from the keyboard or merge several files into one file

-N  Number file contents again output-e  in end line prompt $

14.tac | Reverse Display

15.more | View article content by page, read the file backwards from the front, so load the entire file at startup

+n  start from the nth row-n  each time you view n rows    of data +/string search string string position, starting from its first two lines to view-C  Clear screen and then display-P  page Break screen

16.less | You can view the content of the article by screen, and not load the entire file before viewing it.

  -M shows a percentage like the more command-n  displays line number/   string: Search down the function of "string"?   String: Search up the function of "string" N   repeat the previous search (with/or? about) n   reverse Repeat the previous search (with/or? related) b   turn back one page D   back half page

17.nl [Options] ... [File] ... | Automatically add line numbers to output content
-B
-B A line number (similar to cat-n) is listed regardless of whether there is a blank line
-B t empty line is not column lines (default)
-N has ln rn RZ three parameters, respectively, the most left display, the right side of the display does not add 0, the right side of the display plus 0

18.head [Parameter] ... [File] ... | Displays the beginning of the file, starting with 10 lines by default

-V  display filename-c number Displays the first number of   characters, if number is negative, displays all content except the last number character-number/n (+) Number     Displays the first number line content,-n Number   If number is negative, all content except the last number row data is displayed

19.tail [Required parameters] [select parameters] [file] | Show end of File

  -V Displays verbose processing information-Q  does not display processing information-num/-n (-) Num      displays the last num line Content-n +num from Num line to display the last data-C  display the final C character-F  Loop read

20.VI Editing files

: W filename Saves the article with the specified file name: Wq Save and exit: q! Do not save and Force Exit command line mode function key 1) insert mode Press "i" switch into insert mode "insert mode", press "I" to enter the insertion mode is the beginning of the cursor from the current position of the input file, press "a" into the insertion mode, the current cursor from the location of the next position to start typing; When "o" enters insert mode, it inserts a new line and enters text from the beginning of the beginning. 2) switch from insert mode to command line mode by pressing the "esc" key.  3) Move the cursor VI can be directly with the cursor on the keyboard to move up and down, but the normal VI is a lowercase English letter "h", "j", "k", "l", respectively, control the cursor left, bottom, upper and right one grid.  Press "ctrl"+"b": The screen moves one page to the back.  Press "ctrl"+"f": The screen moves one page to the front.  Press "ctrl"+"u": The screen moves the half page toward the back.  Press "ctrl"+"d": The screen moves the half page toward the front.  "0" by number: Moves to the beginning of the article.  Press "g": Move to the end of the article.  Press "$": Moves to the end of the line where the cursor is located. Press "^": Move to the beginning of the line where the cursor is located press "w": The cursor jumps to the beginning of the next word by pressing "e": The cursor jumps to the end of the next word by "b": The cursor goes back to the beginning of the previous word by pressing "#l": the cursor moves to the first # position of the line, such as: 5l,56l.  4) Delete text "x": Each time you press, delete the "back" character at the cursor location.  #x: For example, "6x" represents the "after" 6 characters of the location where the cursor was deleted.  "x": Uppercase X, each time it is pressed, deletes the "front" character at the location of the cursor.  "#X": for example, "20x" represents the "front" 20 characters of the location where the cursor was deleted.  "dd": Delete the line where the cursor is located.  "#dd": Delete # line 5 from the line where the cursor is located) copy "yw": Copies the character at the end of the cursor to the buffer.  "#yw": Copy the # Word to buffer "yy": Copy the row of the cursor to the buffer.  "#yy": for example, "6yy" represents a copy of 6 lines of text from the line where the cursor is located. "p": Paste the characters in the buffer to the cursor location. Note: All copy commands related to "Y" must be mated with "P" to complete the copy and paste function.  6) Replace "r": replaces the character at which the cursor is located. "r": Replaces the character where the cursor is located until the "esc" key is pressed. 7) Reply to the last action "u": If you mistakenly execute a command, you can press "u" immediately to go back to the previous action. Multiple replies can be performed by pressing "U" multiple times. 8Change "cw": Change the word at the end of the cursor to "c#w": For example, "c3w" means change 3 characters 9) jumps to the specified row "ctrl"+"g" lists the line number of the line where the cursor is located. "#G": for example, "15g", which means moving the cursor to the beginning of the 15th line of the article.

21.which Executable file name | View the location of the executable file, and see if the system command exists and its location in the path specified by the PATH variable

22.whereis [-BMSU] [BMS directory name-f] File name | Locating executables, source code files, Help files in file system locations

   -B locates the executable file.   -M Locate the help file.   -S Locate the source code file.   -U searches the default path for files other than executables, source code files, and Help files.   -b Specifies the path to the search executable file.   -m specifies the path to the search Help file.   -s Specifies the path of the search source code file.

23.locate | Quickly search for files by searching the database

-R  Use normal arithmetic to find the condition

24.find Find [PATH] [option] [action] | Find files in the file tree and make corresponding processing

Options and Parameters: 1. Time-related options: A total of-atime,-ctime and-mtime, and-amin,-cmin and-mmin, with-mtime stating-mtime N: = number, meaning "within one day" prior to n days the contents of the file were altered;-mtim    E +n: Lists the file name of the content that was changed before n days (excluding n days itself);-mtime-n: Lists the file names that have been changed within n days (including the N-day itself). -newer File:file as an existing file, listing a new file name of 2 than file. Parameters related to the user or group name:-uid n = = number, this number is the customer's account ID, that is, uid-gid N: = number, this number is the ID of the group name, that is, Gid-user name:name user account name!    For example, Dmtsai-group Name:name is a group name, such as users;-nouser: The owner of the file does not exist/etc/passwd person! -nogroup: The owning group looking for the file does not exist in the/etc/group file! 3. Parameters related to file permissions and names:-name filename: Search for files named filename (wildcard)-size [+-]size: Search for files larger than size (+) or small (-). This size has the following specifications: C: Represents the byte K: 1024bytes. So, to find a larger file than 50KB, that is "-size +50k"-type type: Search for the types of files, types mainly include: General regular archives (f) Device archives (b, c) catalogue (d ) Nexus (L) socket (s) FIFO (p)-perm mode: Search file Permissions "just equals" mode's file, this mode is a property value similar to chmod, for example,-rwsr-xr-x    The property is 4755! -perm-mode: Search for file Permissions "must all include Mode's permission" file, for example, we want to search-rwxr--r--that is 0744 of the files, using-perm-0744, when the permissions of a file-rwsr-xr-x, that is, 4755, will also be listed, because-rwsr-xr-x attributes have been included in the-rwxr--r--properties. -perm +mode: Search file permission "contains any mode permission" of the file, for example, we search for-rwxr-xr-x, that is-perm +755, but a file property is-RW-------will be listed, because he has-rw .... The attribute exists!    4. Additional action:-exec Command:command For other instructions, the-exec can be followed by additional instructions to process the search results.    -print: Print the results to the screen, this action is a preset action! Eg:find/-perm +7000-exec ls-l {} \; , the extra instruction starts with-exec, with \; end {} instead of what was found earlier | Xargs-i the default front output with {} instead of Eg:find. -name "*.log" | Xargs-i MV {} test4

25.grep ' Regular expression ' file name | Search for text with regular expressions and print matching lines

  -C outputs only the count of matching rows. -  I is case-insensitive (only for single-character).  -L displays only the file name  -V displays all lines that do not contain matching text. -N  displays matching row data and its line number

25.file | Determine file type

26.gzip [-cdtv#] File name | Compressed, uncompressed, source files no longer exist

-D to  unzip  -C output compressed data to the screen-V  : Shows the original file/compressed file compression ratio and other information-#  : Compression level, 1 the fastest, but the worst compression, = 9 slowest, but the best compression

27.gunzip | Unzip

28.BZIP2 | Compression, decompression

  -D: Unzip  -Z: Compress  -K: Keep source file-C: Output the data generated by the compression process to the screen! -V: Can show the original file/compressed file compression ratio and other information;-#: Same as gzip, all in the calculation of compression ratio parameters, 9 best,-1 fastest!

29.BZCAT read data without decompression

30.tar [main options + Secondary options] File or directory | Multiple catalogs or archives packed and compressed into one big file

Main option:-    C  set up a package file, can be paired with-V to see the process of the file name (filename)-    t look at the  contents of the package file contains what file name, focus on the "file name" is;-    x  Unpack or unzip the feature with-C (uppercase) to unlock the secondary option in a specific directory:    -j  compression/decompression via BZIP2 support: The file name is best for *.tar.bz2-    z  compression via gzip support Unzip: This file name is preferably *.tar.gz-    v during the  compression/decompression process, the file name being processed is displayed!    -F filename-f to be processed immediately after the file name! -    C Directory This option is used for decompression   , which you can use to decompress in a specific directory.    --exclude file: Ignoring a document during compression packaging Eg:tar--EXCLUDE/HOME/ZENGHAO-ZCVF myfile.tar.gz/home/*/etc-    p  Retain the original permissions and properties of the backup data, commonly used for backup (-c) Important configuration files--    ------------------------------to  allow the backup data to contain the root directory    filename.tar.bz2 file or directory name to be compressed    query: TAR-JTVF filename.tar.bz2    extract: TAR-JXVF filename.tar.bz2-c directory to extract

31.exit exiting the current shell

32.logout Exit Login Shell

33.shutdown-h now

34.users Displays the user currently logged on to the system

35.who login in native user with source

-H or--heading displays the header information column for each field.

36.W users who log on to the computer and the programs they run

-S uses a concise format list, which does not show the CPU time consumed by user login times, terminal stage jobs, and programs. -H does not display the header information column for each field.

37.write sending messages to users who are currently online

38.wall send messages to all users who log on to the machine

39.last View User Login log

40.lastlog View last login time for each user

41.finger [Options] [users] [user @ host] | View user Information

-s display the user's registration name, actual name, terminal name, write status, time of stasis, logon time and other information-L in addition to the information displayed with the-S option, the user home directory, login shell, message status and other information, as well as the user home directory of the. Plan,. The contents of project and. Forward files. -P The same as the-l option except that the. plan file and the. project file are not displayed

42.hostname Viewing host names

43.alias II = "Ls-l" | Add Alias

44.unalias II | Clear aliases

45.useradd [-U UID] [-G initial Group] [-G secondary Group] [-C description Bar] [-D Home directory Absolute Path] [-s shell] User account name | New user

-M  does not build user home directory! (System account Default)-M  build user home directory! (General account default)-R to  establish a system account, the UID of this account will be limited to-e  account expiration date, in the format "YYYY-MM-DD"  -D view Useradd's default values

46.passwd | Change Password

-L  Disable password-u  and-l relative, the user unlocks  -s lists the relevant parameters within the login user passwd file-n followed by the number of  days, shadow the 4th field, how long cannot change the password days-x  after the number of days, shadow The 5th field, how long must be changed password-W followed by the  number of days, shadow the 6th field, the warning days before password expires-I  followed by "date", Shadow's 7th field, password expiration date using pipeline Liu Set Password: echo "Zeng" | pas SWD--stdin Zenghao

47.userdel Delete User

-R  user files are deleted together

48.chage [-LDEIMMW] Account name | Modify the related properties of a user's password

  -L lists the detailed password parameters for this account;-d  followed by date, modified Shadow third field (last Change password date), format yyyy-mm-dd-e  followed by date, modify shadow eighth field (account expiration date), format Yyyy-mm-dd-i  after the number of days, modify the Shadow seventh field (password expiration date)  -M after the number of days, modify the Shadow fourth field (password minimum retention days)  -M after the number of days, modify the Shadow fifth field ( How long does the password need to be changed?  -W followed by Days, modified shadow sixth field (password Expiration warning date)

49.usermod [-cdegglsulu] username | Modify a user's related properties

-C  After the account description, that is/etc/passwd Fifth column of the description bar, you can add some account description. -D  back to the home directory of the account, that is, modify the sixth column of/etc/passwd, the  date is followed by-E, the format is Yyyy-mm-dd is the eighth field data in the/etc/shadow! The-f  followed by the number of days is the seventh field of shadow. -G  followed by the initial group, modify the/etc/passwd fourth field, that is, the GID field! -G  followed by the secondary group, modify the user can support the group-L followed by the  account name. That is, modify the account name,/etc/passwd the first column! -S  followed by the Shell's actual files, such as/bin/bash or/bin/csh and so on. -U followed by the  UID number! That is, the information in the third column of/etc/passwd;-l  Freeze Password-u  unfreeze Password

50.id [Username] | View user-related ID information and can also be used to determine whether a user exists

51.groups View Login user-supported groups, the first output group is a valid group

52.NEWGRP Toggle Active Group

53.groupadd [-G GID] Group name | Add Group

  -G sets the specific group ID of the Add Group

54.groupmod [-G GID] [-n group_name] Group name | Modify group Information

  -G Modify an existing GID number-n  to modify an existing group name

55.groupdel [GroupName] | Delete a group

56.gpasswd | Group Administrator Features

Root admin action:    -gpasswd groupname set password    -gpasswd [-A user1,...] [-M User3,...] GroupName        -A  will GroupName's master control to the latter user management (the group's administrator)-        m  to add some accounts to the group    -GPASSWD [-R] GroupName  -R removes the GroupName password from the Group Administrator action:    -gpasswd [-ad] user GroupName-A to add  a user to the GroupName group  -D Remove a user from the GroupName group

57.CHFN Modify Personal Information

58.mount [-t vfstype] [-O options] Device dir

-ro use read-only hook device-RW read-write connection device eg:mount/home/mydisk.iso/tmp/mnt access content within Mydisk via MNT

59.umount un-mount

60.cut

-B: Split in bytes. These byte locations will ignore multibyte character boundaries unless the-n flag is also specified. -C: Split in characters. -D: Custom delimiter, default is tab.  -F: Used with-D to specify which area to display.

61.sort

   -N Sorts by the size of the numbers. -o< the output file > The   sorted result into the specified file. -R   is sorted in reverse order. -t< Delimited character >   specifies the field separator character to use when sorting.  -K selects which interval to sort.

62.WC statistics Specify the number of bytes, words, and lines in the file, and display the results of the statistics output

-l filename Report number of rows-C filename report bytes-m filename Report character number-W filename report word number

63.uniq Remove adjacent duplicate rows in a file

Empty/new file, redirect content into &> correct, error redirect past append

64.set Display environment variables and normal variables

65.ENV Display Environment variables

66.export changing the normal variable into an environment variable

67.unset Delete an environment variable

AAA () {} define function

68.read

  -P prompt character  -t number of seconds to wait

69.declare, typeset

-I is declared as an integer-a declaration for an array-F declaration as a function-R declaration as read-only

70.ulimit restricting some system resources for users

-F  This shell can establish the maximum file capacity (which may be set to 2GB) unit for Kbytes eg:ulimit-f 1024 limit the user can only establish a capacity of 1MBytes or less files

71.DF [Options] [file] | Displays the free space for the specified disk file, and if no file name is specified, the free space for all currently mounted file systems will be displayed

-a  Show all file System-H  File size friendly display-l  only show local file system-I  display inode information-T  display file system type

72.DU [Options] [file] | Displays disk usage space for each file and directory

  -H easy-to-read mode-s  shows only the sum size

73.LN [parameters] [source file or directory] [destination file or directory] | One file to create a synchronized link in another location

  -S establish soft   connect  -V Show detailed process

74.diff [Parameter] [file 1 or directory 1] [file 2 or directory 2] | Compare individual files or directory contents

-B does not check for differences in whitespace characters. -B does not check for blank lines. -  I does not check case  -Q only shows differences without details Eg:diff a b > Parch.log compare two files and generate patches

75.date [Parameter] ... [+ format] | Displays or sets the date and time of the system

%H hours (expressed in 00-23). %M minutes (expressed in 00-59). %P am or PM. %d Date (inclusive)%u the number of weeks in the year. Date-s "2015-10-17 01:01:01″//time Set Date +%y%m%d         //Display day before date +%y%m%d--date=" +1 day/month/year "  //Show the previous day/month/ Date of the year +%y%m%d--date= "-1 Day/month/year"  //Display date after day/month/year date-d ' 2 weeks ' 2 weeks after

76.cal [parameter] month] [year] | View Calendar

-1 Display Month calendar-3 shows the first day of the month  before, when, and after one months of the calendar-M  display Monday for a one week of a-s  (default) Sunday for the first day-j shows the calendar of the day of the  year in the month-y  Display the calendar for the current year

77.ps | List snapshots of the current process

A   show all processes-a  show All programs under the same terminal e   display environment variable F show   relationship between Processes-H  display tree structure r   shows the current terminal program T   shows all programs of the current terminal-au Show more detailed information-aux all    processes that contain other user-U-  specified users

78.top [parametric] | Displays information about the processes currently being executed by the system, including process IDs, memory usage, CPU utilization, etc.

79.kill [parameter] [process number] | Kill process

80.free [parametric] | Displays the free, used physical memory and swap memory in the Linux system, and the buffer used by the kernel

81.vmstat | Monitor virtual memory, process, and CPU activity of the operating system

82.iostat [parameter] [time t] [number of times N] (refresh once every t time, up to n times) | Monitor the disk operation activity of the system, report disk activity statistics, and report CPU usage

-p[disk] Displays disk and partition conditions

83.watch [parameters] [command] | Repeat a command to see the change

-N interval  How many seconds to refresh-D  highlight dynamic changes

84.at [parameter] [TIME] | Executes a specified task at a specified time, only once

HH:MM[AM|PM] + number [Minutes|hours|days|weeks] forces the task to be performed at some point in the day of the month ATQ view the task that the system does not perform ATRM n Delete the task with number n at-c n Displays the contents of the task with number n

85.crontab | Timed Task Scheduling

File    load crontab-e  Edit a user's crontab file content-L  display a user's crontab file contents-r  Delete a user's crontab file

86.ifconfig [network device] [parameter] | View and configure network devices

87.route | Displaying and manipulating IP routing tables

88.ping [parameters] [host name or IP address] | Testing connectivity to the target host

  -Q shows only the final result

89.netstat | Displays statistics related to IP, TCP, UDP, and ICMP protocols

90.telnet [parameters] [host] | For remote login, using plaintext to transmit messages, security is not good

91.RCP [parameters] [source file] [target file] | Remote file copy

  -R recursive copy  -P retains the source file's properties Usage:rcp–r Remote_hostname:remote_dir Local_dir

92.wget [parameters] [url address] | Download files directly from the network

-O file writes the record to file    eg:wget-o a.txt urlwget--limit-rate=300k URL  speed limit Download

93.awk

-F delimiter  separates contents {}  to execute script content eg:cat/etc/passwd |awk-  F ': '  {print $ \ t ' $7} '

94.sed Replace, delete, add, select, and so on data rows

A   added, the new next line appears C   Replace, replace n1,n2 between the line eg:sed ' 1,2c Hi ' abd   Delete I   insert, appear on the new line

95.paste merging files to ensure the same number of rows in the merged two file

-D  Specifies a field delimiter that differs from the Space or TAB key-S  merge by row, one file at a single line

96.su [parameter] user | Switch Login

  -l switch with environment variables, working directory change-C command  executes the command back to the original consumer

97.sudo | To execute a specific command with the privileges of a specific user

  -L lists commands that the current user can execute-u username#uid to specify user execution commands

100 Common Linux Command Daquan

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.