Notes on some common Linux commands

Source: Internet
Author: User

Notes on some common Linux commands

For Linux, I am a cainiao, and I started to get started at work. I will feel awkward when I use Linux, now, we will record some commonly used Linux commands for future study and reference.

Cd

This may be the simplest Linux Command, because the windows operating system also applies this command. it is mainly used for directory switching, followed by absolute paths or relative paths, such:

1
2
3
Cd d:/wjl_hexo # To the wjl_hexo directory of the d Disk
Cd .. # Go to the top directory of the current directory. If the current directory is D:/wjl_hexo, the current directory is the root directory of drive D after execution.
Cd ~ # To the root directory

 

Ls

This command is mainly used to display the file and Folder Information in the directory. You can only display the most basic information without parameters. there are many parameters that can be included, such:

1
2
3
4
-A ## all files, together with hidden files (Files starting)
-L ## list data files and directories in the current directory in the form of long data strings
-LR ## list all files in the current directory in the form of a long data string (think twice)
-T # sort by Time

 

Grep

This command is mainly used for text content search to find the information we need in the text, in the format:grep 'keyword' filenameYou can use the following parameters to view logs:

1
2
3
Grep 'create order' filename. log-c # count the number of times the keyword 'create order' appears in filename. log
-I ## ignore the case sensitivity of keywords for search
-V ## Reverse Selection: No keyword is displayed.
Tail

It is often used to view logs. It is used to display the content at the end of a specified file. format:Tail [parameter] filename, Common parameters:

1
2
-F # dynamically display the content at the end of the text to view the current log output in real time. You can also directly enter tailf filename
-N # display n rows of information, such as: tail-n 5 filename. The last five lines of content in the file are: tail-n + 5 filename. The file is displayed starting from line 1.

 

Less

Powerful command to view text without modifying the content of the text. You can use the keyboard To view. format:Less [parameter] filenameSuch:

1
2
3
-B ## <buffer size> set the buffer size
-E ## automatically exit after the file is displayed
-N # display the row number of each row

 

Input/keywordOr?keyword, You can retrievekeywordInformation.
Auxiliary operations:

JMove one row forward
KMove one row backward
gMove to the first line
GMove to the last row
qExit the less command
ctrl + FMove one screen forward
ctrl + BMove one screen backward
ctrl + DMove half screen forward
ctrl + UMove the half screen backward

Rm

Command Used to delete one or more files and directories. format:Rm [parameter] file/folderSuch:

1
2
3
4
5
Rm file # the system will prompt whether to delete the file
Rm-f file # force delete the file. The system does not prompt
Rm-rf folder # delete all contents in the folder and its directory. No prompt is displayed.
Rm-I *. log # delete all. log Files. Confirm the deletion one by one.
Rm-r folder # Delete All subdirectories and subdirectories

This article permanently updates the link address:

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.