Linux Study Notes-common Linux commands-Other Common commands

Source: Internet
Author: User
Tags clear screen

1. display the system command directory which [command]

Display the absolute path of the command, alias record of the command, such as LS. The files displayed on the terminal are marked with colors because LS is bound to -- color = auto.
Whereis [command]

Displays the absolute path of the command and the location of the help document.
2. Search for any file or directory. Find [search path] [Search Keyword]
Find-name
Search by file name (do not search in the root directory)
* Match any character, including null characters
? Match a single character

Size matches the file size. + size indicates that the file size is greater than this size, and-size indicates that the file size is smaller than this size. Note that data blocks are used as the unit. For example, 100 MB = 100 × 1024 K = 204800 block. To search for files larger than MB, use find + 2
-The user matches the user.

Search by Time Value
1. Daily ctime, atime, mtime
2. Minute Cmin, Amin, and mmin
C-change
Changed, indicating that the attributes of the file have been modified, including the owner, owner group, and permission.
A-Access
Access: indicates the file has been viewed, Cat, VI viewing, etc.
M-Modify
Indicates that the file content has been modified.
Used to check hacker intrusion records
-Indicates that the time is less **
+ Indicates that the time exceeds **
Write the time value directly.
Example: Find/etc init-mmin-120
Find application connector-A and logic and
-O or logic or
Find/etc-size + 163840-a-size-204800
-Type file type-type F binary file
-Type l soft link file

-Type D
Directory
Find ***-exec command {}\;
{} Is the result of finding

\ Escape Character
; Indicates the end of the statement.

For example, if the result of which RM is alias Rm = 'rm-I ', the latter is the alias of the command, indicating that the query is required when the file is deleted, if you add \ before RM, you will not ask again.
Find ***-OK command {}\;
-OK indicates whether to execute the command.
Create a file with a special file name
Touch "a B" creates a file named a B.

Touch -- ABC creates a file named-ABC.

However, in most cases, the Creator does not know how to create such a file. Therefore, a common method is required to find and delete the file.
I node, because each file corresponds to a digital identifier
-Inum I Node

Ls-I displays the node information of the file
Find.-inum [node digital ID]-exec RM {}\; where. Indicates searching in the current directory,... indicates searching in the parent directory.
The actual operation can be left empty. You can find it in the current directory.
You can complete the deletion operation.
3. Search for a file or directory locate [search for keywords]
The locate search speed is very fast, but unlike the find search method, the locate allows users to quickly search for specified files in the file system.
The method is to first create a database (updatedb) that includes the names and paths of all files in the system. Then, when searching, you only need to query the database, instead of going into the file system.
Therefore, if a new file is created and the file is not input into the database, it cannot be searched. Therefore, to use it with updatedb, you may need
Updatedb once. Note that the command execution permission is root. The system will schedule tasks to execute this command regularly, so it is not necessary to use the updateb command every time you use locate to search for user files.
UNIX does not have this command.
4. grep [specified string] [source file]
Instead of searching for files in a directory, you can search for Matching lines in the file and Output
The grep command is used to find files whose content contains the specified template style. If the content of a file conforms to the specified template style, the default grep command displays the column containing the template style.
If no file name is specified or the given file name is "-", the grep command reads data from the standard input device.
5. Get help information MAN [command or configuration file]
Man Manual
When the information is displayed, the more command is called, so the operation during viewing is the same as that for more.
You can only view the help of the configuration file, so the configuration file does not need a path. Such as man services
If the command and configuration file have the same name, the help of the configuration file is checked first. Because man has eight types of help, Command help is the first, and configuration file help is the fifth. View
Use man 5 passwd to help with the passwd configuration file
6. View help info [any keyword]
Linux and UNIX
7. Obtain the role of the short Index Command and the location of the command (brief information) whatis
-- Help: Only LIST Command Options
Apropos [configuration file] is equivalent to man-K
When you use whatis and apropos, you need to use the index database. If an error occurs when you use these two commands, whatis database is not created.

Use makewhatis

View help of shell built-in commands

If you use man to view shell built-in commands similar to CD, a lot of irrelevant information is displayed.

8. compression and decompression commands
Gzip [file name]
Only files can be compressed, but directories cannot be compressed.
Source files are not retained after compression.
Gunzip or gzip-D is used to extract the compressed package
The original compressed package is not retained after decompression.
Tar can package a directory into a directory, so it has * .tar.gz
Tar-C [Directory] to generate packaging files
Tar-V [] displays details
Tar-f [] specifies the compressed file name, which is a required Option
Tar-Z [] package and compress
After centos 6.2 is compressed with tar-zcvf, the original file is retained.
Extract more
Tar-zxvf
-X unpack the tar package
-Z Decompression
-F: Specifies the extract file name.
-V: Show Details
Zip Linux and Windows Default supported compression formats
The usage of zip and tar for compression is the same.
Decompress with unzip
Bzip2 is an upgraded version of zips. It is usually used to compress large files, and its format is .bz2.
Bzip2 [file name]
Add the-K option to retain the original file.
Decompress and use bunzip2

Network Communication command write [user name]
Send a message to another user, ending with Ctrl + D. If the other user does not log on, the message cannot be sent in real time. If the other user is offline at the time of sending the message,
It cannot receive it during login.
Send information to all users
Test network connection Ping
If you do not manually terminate the service, ping the service continuously. If you do not obtain an ICMP response packet, the network is normal.
Ping-C 3 192.168.17.17 control the number of Ping times
Ping-s [packet size]
First check the latency, but also check the packet loss rate packet loss. When the network cable is warm in winter or summer, it will be stretched, and the contact between the Network cables will cause packet loss and nic failure will also cause packet loss.
If the other machine cannot be pinged, try to ping its own IP address. If it can be pinged, it may be due to a problem with the network facilities or a problem with the network connection. If
If your IP address cannot be pinged, you should try to ping the loop address. If the IP protocol is not installed properly, you should be able to ping the IP address. machines without NICs can also be pinged.
Ifconfig
-A can not be added in Linux, but in UNIX.
Shutdown and reboot are not commonly used
Shell application tips bash
Tab key command completion
CTRL + l clear screen
CTRL + u Delete All characters before the cursor
Command alias
Alias copy = CP, followed by the alias name
Alias xrm = "RM-R"
Unalias is used to cancel an alias.
Input/Output redirection
0 stdin standard input
1 stdout standard output
2 stderr standard error output
This means that the input is not input from the keyboard, and the output is not output from the monitor.
<Input redirection
> Output redirection
> Used for append to the end
Ls/JD 2>/LS. Err when an error occurs during command execution, write the error message to the LS. Err file for viewing.
Pipeline: Send the output of one command to another as the input of another command
; Sequential Command Execution
& Connect two Commands
Command1 & command2
Executed successfully
Failed to execute
Command1 | command2
Failed
Failed to execute
Command replacement character
'The output of the next command serves as the parameter of the previous command

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.