Common Linux commands-general Linux technology-Linux programming and kernel information. For more information, see the following. 1. Number of calculated rows
Wc-l doc.txt
2. wildcard characters
* Match one or more characters in any order
? Match any single character
[] Match a group of closed characters or ranges
Only the 3th part of the document is specified. The name of doc1_0-92.16.txt is doc0.txtand will be matched to doc9.txt.
3. Help commands
Man keyword
Keyword is the usage of the command you know. q can exit
4. Directory switch command cd
Cd returns to the current user's home directory
Cd ~ Returns to the current user's home directory.
Cd/return to the root directory of the entire system
Switch cd/root to the root directory of the Super User
Cd ~ Switch other user names to the Home Directory of another user
Cd .. return to the upper-level directory of the current directory
Cd... is returned to the two levels of directory in the current directory.
Cd subdir: Enter the subdirectory subdir of the current directory
Switch cd/dir1/subdir to the subdir directory under the dir1 directory under the root directory
5. Print the current directory command pwd
When you get lost in directory switching or want to know the full name of the current directory: pwd
6. File Location (Search) command locate
Usage: updatedb
Locate keyword
// Keyword supports fuzzy match. It seems that updatedb can be omitted. My machine is like this.
7. Directory LIST Command ls
Ls-l [keyword]
// There are many keyword options, which can be left blank (list all the items in the current directory) or a directory name (based on the current directory and the absolute directory)
8. file content display command cat
Cat filename
Cat file1> file2 // input the content of file1 to file2. overwrite the content of file2.
Cat file1 file2> file3 // combines file1 and file2 into file3
Cat file1> file2 // append the content of file1 to file2. Note that the content of file2 is not overwritten.
Cat file1 file2> file3 // append all file1 file2 content to file3
Note: the target file does not need to be created in advance; there must be spaces around the symbol; ctrl + d to end this command
9. more and less commands
The cat command is useful in displaying short files, but it may only display the last screen when the file is too long. This introduces the more less command.
More filename // display text by page. The blank key displays the next page. The B key is the previous page.
Less filename // fast, because it does not read the entire file at one time at a time, you can use the direction key Paging
10. head tail command
When you want to read the first few rows of a file, head can help you.
Head-m filename // m indicates the number of rows to be read, which can be omitted here. The default value is 10.
Similarly, when you want to read the last few rows of a file, tail can help you.
Tail-m filename
11. file copy command cp
Cp file1 file2 // note that there are essential differences with cat. Although the same task can be completed sometimes, the cp operation object is a file, and the cat operation object is the file content, you can use man cp to view some optional parameters.
12. Directory Creation command mkdir
One or more directories can be created at a time, and a complete sub-directory inheritance structure including all parent directories and sub-directories can be created at a time.
Mkdir dir1 dir2 dir3
Mkdir-p dir/subdir // create the directory dir that contains the subdirectory subdir in the current directory
13. File directory deletion command rm
Rm can delete one or more files and directories at a time
Rm-r dirname // The directory cannot be deleted without-r, even if there is no other stuff under the directory. In other words, Dongdong also killed them all.
Rm filename // Delete the object
14. Dedicated directory deletion command rmdir
This command is safer than rm-r because only empty directories can be deleted.
Rmdir dirname // dirname is required to be an empty directory
15. file and directory Movement (rename) command mv
Mv file1 file2 // rename file1 to file2. If file2 exists in advance, the original file2 will be overwritten.
Mv-I file1 file2 // rename file1 to file2. If file2 exists in advance, the system will prompt whether to overwrite the original file2.
Mv file1 dir1 // move the file to the directory dir1
[The above commands are all tested in UBUNTU (Africa) 8.04]
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