Developer's Linux Command learning list

Source: Internet
Author: User

As a developer, especially a server application developer, It is very helpful to know a proper amount of common Linux commands. Many daily tasks, such as viewing server logs, Data File Processing, and batch modification, do not need to be implemented using the main development language. Instead, you only need to master and use some commands and tools. However, as developers and system administrators, the degree of learning Linux Command tools is also obviously different.

As a developer, you should master the following frequently used Linux Command tools:

1. file directory: ls, CP, RM, MV, Cat, Head, tail, CD, PWD, mkdir, touch, rename, less, find, Which, locate, chmod, chown, less, LN, tar, umask

2. Text Processing: grep, sed, awk, TR, uniq, sort, join, cut, Tee, WC, Echo

3. View processes: PS, top, kill, who,

4. Network Tools: netstat, SCP, ssh, ping, wget, ifconfig, ARP

5. Environment Settings and server software: Apache, set, alias,., source, sudo, Su, date, read

6. Help: -- help, man,

7. Others: xargs

There are about 50 commands in total.

Use man's character name | WC-L to check the number of lines in the Command description. Shift + G can go directly to the end of man's document. Num + Shift + G can go directly to row num. Try:

Man ls | WC-L 243

Man find | WC-l 1572

Task: calculate the number of lines in the man document of the preceding command.

Step 1: place the preceding command in a text file. The command is cmds. List.

ls, cp, rm , mv,  cat , head, tail ,  cd ,  pwd, mkdir ,  touch,  rename,  less,  find, which, locate,  chmod, chown, less, ln,  tar,  umask grep, sed, awk, tr,  uniq,  sort,  join,  cut,  tee,  wc, ps,  top,  fg,  kill,   who,  netstat ,  scp ,   ssh,  ping,   wgetset,  alias, . ,  source, sudo ,  su,  date,  man ,xargs 

Step 2: Use the tr command to convert the line feed and remove spaces and empty lines;

$ Tr ', ''\ n' <cmds. List | tr-d' | grep-V' ^ $ '> result. Mid

Step 3: Use a simple while & read loop to output the number of man document lines for each command

$ While ifs = ''read partition _name; do echo-ne $ partition _name" \ t "; man $ partition _name | WC-L; done <result. Mid

Step 4: Integration: pipelines can be used for redirection. The following is a complete command

$ Cat cmds. list | tr', ''\ n' | tr-d' | grep-V '^ $' | while ifs = ''read partition _name; do echo-ne $ sort _name "\ t"; man $ sort _name | WC-L; done | sort-NRK 2

less 1583less 1583wget 1579find 1572ps 1166top 1158awk 902ssh 901man 710grep 636sudo 520tar 492netstat 356ping 340sed 280xargs 275ls 243date 204locate 189cp 172sort 160scp 156chmod 146tr 137chown 125ln 120rm 108mv 105kill 104tail 103join 103who 99touch 93uniq 89cut 88cat 82wc 70head 68umask 67su 66mkdir 63rename 57pwd 57tee 53which 31source 0set 0fg 0cd 0alias 0. 0

Note that the number of lines (including blank lines) in the Command man document is generally between 100 and 400, and the heavyweight command has a detailed description, about 500-2000 lines, such as find more than 1500 lines! Small commands can be tried one by one. skills are required to master large commands. First, you need to understand what your daily work requires.

General options:
1.-Q silent mode. Do not print any information related to the operation.-V "loose" mode: print operation information.

Common commands:
. Ls lists the contents of a directory (including the object metadata)
-A all-H size human readable-l details-I index node number-m separated by commas-1 each row one-r reverse display-r recursive display sub-directory content-T by modification time sort
. Rm delete a file or directory (1)-I,-I [once] whether the user is prompted (2)-R,-R used to delete a directory; (3)-f force Delete
. MV to move or rename the file. Remember the syntax format.
(1) mV srcname destname (2) mV src1 src2... destdirectory (3) mV-T destdirectory src1 src2...
. CP copy the file or create a link. The syntax format is the same as that of MV.
-I prompts the user-R to copy the Directory and recursively copy-s to create a soft link-L to create a hard link
. Mkdir if the directory does not exist, create a directory based on the specified directory name; otherwise, an error is returned.
-P: If the directory in the specified directory path does not exist, the corresponding directory is created without an error. For example, mkdir-p a/B. If directory A does not exist, create directory A and directory B.
.
. Which positioning command full path-A displays all paths Matching Parameters
. Head: displays the specified part at the beginning of the file, or removes all the parts at the end of the specified file. You can specify the number of-C bytes and the number of-N rows in two ways;
Eg. Head-N 5 data.txt displays the first five rows of data.txt; head-n-5 data.txt displays data.txt removes all rows of the last five rows
. Pwd shows the full path of the current directory; Switch CD to the specified directory
. Cat connects the content of multiple files and prints them to the standard output. -E: show $ at the end of the row;-N: show the row number at the beginning of the row.
. WC statistics specified file. -C bytes-M characters-l lines-w words-L maximum line length
. Tee reads content from the standard input and writes it to the standard output and specified files. It is used to copy the same content to multiple files in batches.
If yes, it overwrites the content. If no, it creates the-A Append content instead of overwrites the content.
. Uniq reports or deletes duplicate rows, often used with sort. -D: only print rows with duplicates;-u: only print rows with no duplicates;-C: Count rows and the number of repeated occurrences
-S n comparison skips the first n characters;-f n comparison skips the first n fields;-W n only compares the first n characters
. Cut prints the selected part of each row of the file to the standard output. The unit of action is the file row. Used to cut the specified content.
-B [range] bytes in the specified range-C [range] characters in the specified range-f [range] fields in the specified range-D specified field delimiter
Range specified: N nth; n-from nth to nth;-N from nth to nth; M-N from nth to Nth (Boundary included)
Eg. Cut-C 1-4 cmds. List print the first 4 characters of each line in the cmds. list file; cut-F 2 cmds. List print the Second Field
. Who view logon users and Operation overview-u user list-system B startup time-r running level-Number of Logon Q users

Grep: searches for matched rows in the specified file and prints the rows. If not specified, the content is read from the standard input.

-A num: Print matching rows and subsequent num rows-B num: Print matching rows and previous num rows
-C: only print the number of matched rows. -- color: highlight the matching part.
-E use the extended regular expression-e pattern use pattern as the pattern-P use the Perl expression
-F uses a fixed string to match.-F inputfile: Read mode from the specified file. Each row has one
-N: the row number displayed when the matching row is printed.
-H: When searching multiple files, print the file name-H: do not print the file name
-I case-insensitive
-L: only print files with matching names.-L: print files without any matching names.
-R recursive search-V search for unmatched rows-x selects rows that completely match the entire row

Sed: stream Editor, used to filter and process the specified Editing Command text
-E script: Use the script editing command to process files
-F script-file: Use the command set provided by script-file to edit the file. Each line contains an editing command.
-I local editing, directly changing the edited File
-R: use the extended regular expression in the editing command

Edit command a append text I insert text Q exit sed S/Regexp/Replacement

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.