Common Linux Commands

Source: Internet
Author: User

Linux Novice Common commands to perform view Help commands

The man command, used to view the Help document, can be used to view the optional parameters and usage of a command, in the format: Man command

Common system work commands echo

Used to display a string at the terminal or to output the value after extracting the variable

How to extract variables : By env You can get the values of the environment variables in the system, using echo+\ (variable name * * can print its value, where **\) is the symbol of the extraction variable, ECHO is printed

Date

Used to print a time date, often used to back up files when the memo time, the following parameters can be used to define the format of the print time

Common:

Reboot,poweroff

For system restart and shutdown

Wget (requires network card configuration)

For resource download, the format is: wget[parameter]+http://

Ps

Used to view the status of the process currently running on the system, the format of the ps[parameter],ps command has many parameters, but commonly used is a,u,x three parameters, which are short form-A,-U,-X can be merged into-aux, but the long format and the short format can not be merged.



Among them, the state of the process in the Linux system is the most common 5 kinds:

Top (important)

PS commands View the status of the process is not updated in real-time, to see the status of the real-time update of the process (similar to the Task Manager window System), using the top command

First line parameters: system time, system duration, there are two users logged in the system (each opening a terminal is a user), the system load situation (percentage): Three parameters in turn is the system in 1 minutes, 5 minutes and 15 minutes of the load situation, it should be noted that In the company load value will be before 4-5, this is normal, this indicates full use, but within 1 is the most stable, the company's economy is better, do not let the value is too large, 1-2 is good.
Second line parameter: Tasks for the process, a total of 529 processes, 1 are running, 528 are in hibernation (waiting to be transferred), zombie for the zombie process, if there is a process is a zombie process, may cause some processes cannot shut down, need to see the reason.
The third row of parameters: CPU usage, US represents the percentage of the system CPU used, and the ID represents the resources that can be used.
Line Fourth parameter: indicates the use of physical memory, you can use the free command to view memory usage, FREE-M can be used in megabytes to view memory usage, FREE-G can be used in G to view memory usage, Using the Free-h command will show more human memory usage (large with g, small with m), it should be noted that when the swap partition is used for a long time, it indicates the need to add a memory bar.

How to put the process into the background and need to get it back (because Linux can only open 9 terminals)

Use CTRL + C to terminate the process, CTRL + Z will be a process temporarily shelved in the background, (this time you can do their own things), with jobs can see the number of processes in the background, with the fg+ number of the process continue to hold.

System State Detection Command Ifconfig

Used to view NIC information

parameters to be followed: the name of the NIC (eno16777728 and Lo), inet (IP address), ether (MAC address), RX packets (packet size received), and TX packets (packet size sent)

Uname

View the system kernel information, the-a parameter to see detailed kernel conditions.

Uptime

This command prints the first line parameter of the top command.

W.H.O.

To view user usage

0 is a graphical interface, pts/0 is the number of terminals.

Last

View user's history login information

History

View the history of command execution, use the-C parameter to clear history

The preceding numbers are used in addition to the numbering sequence! + Number call command.

Working directory Toggle Command PWD

View the current working directory

You can use the cd+ directory to convert the directory, use the CD- return to the last directory you visited (not the previous directory), return to the top level directory CD--,CD ~ for home directory.

Ls

View files in the current directory

Use the- L parameter to display (show details) files in a directory with long format

You can use the -al (--all-l) parameter to display all files in a long format, much more . The first file, the hidden file, is related to Linux permissions, and the list is the list of permissions.

Text file Editing command cat more head tail

Cat can view relatively small file content, when viewing the content of more than a file (novel), using the more command, the system will be paginated to display the file content, using head-n "number" command to view the first few lines of content, use the tail-n "number" command to view the last few lines of content.

Tr

Used to replace characters in a text file in the following format: TR [original character] [target character]
For example, to convert all lowercase letters in text to uppercase, you can write this: Cat text name | tr [A-z] [a-z], where | is a pipe character, also called an arbitrary door, whose function is to use the output of the preceding statement as input to the subsequent statement.

Wc

Used to count the number of lines, words, and bytes of the specified text in the format: WC [parameter] text

Cut

Used to extract text characters, format: cut [parameter] text, by column. For example:cut-d:-F 1 indicates that the first column of information is extracted with a colon delimiter.

Diff

To compare differences in multiple text files, format: diff [Parameters] File

File Directory Management Command touch

A variety of times and formats for creating blank files and setting files: Touch [parameters] [file], everything in Linux is a file, including hard drives, directories, etc. However, the file only distinguishes between types, and does not differentiate between suffixes (like txt in window, MD, etc.). The time to set up the file includes setting the modified time (mtime) of the file contents, the change time of the file permissions or properties (CTime), and the read time of the file (Atime).

Mkdir

Used to create a blank folder (catalog file), format: mkdir [parameters] directory, touch create a normal file, with LS query, ordinary files are boldface, directory files are blue characters, in addition to creating a single directory, you can also use "-P" parameter to recursively create a directory with nested overlay relationships.

Cp

For copying files or directories, format: CP [parameters] [target file]

Mv

is cut, format: MV [parameter] source file [target path] [target filename], if a file in the same directory in the cut operation, is actually the role of renaming.

Rm

Used to delete a file or directory, format: RM [parameter] file, when you delete a file on a Linux system, you will be asked to do a deletion by default, if you do not want to see this repeated confirmation information, you can use the "-F" parameter to directly force the deletion, In addition, if you want to delete a directory folder, you need to append an "-r" parameter.

Dd

Used to specify the size of the copy file or specify the conversion file, format: dd[parameter], in addition to replication, you can also test the hard disk read and write speed, you can also make a disc image.

File

Used to view the type of file, all files in Linux, but not like window according to the suffix to know the specific type of file, which is required to use File command, format: File file name

Package compression and Search command tar

Used to package files compressed or decompressed, format: tar [parameters] [file], you need to remember four parameters: C, Z, V, F (can be added in front of the number, or not), the "-C" parameter is used to create a compressed file, "-Z" parameter specifies gzip format compression decompression file, "-V" Parameters to constantly show the compression or decompression process to the user, the "-F" parameter to represent the compressed or unpacked package name, this parameter must be placed in the last one. Common formats for Linux systems are. tar or. tar.gz or. tar.bz2, commonly used "TAR-CZVF compressed package name. tar.gz Directory to package" to package compression, using the TAR-XZVF compressed package name. tar.gz to decompress.

Grep

A search match for keywords for text content, format: grep [parameters] keyword file. There are two common parameters to remember, the "-n" parameter displays the line number of the search information, and the "-V" parameter is used to reverse the information (that is, all the information lines that do not contain keywords)

Find

Used to find files in the system according to specified criteria, format: Find [Search Path] Find conditional action

For example: Find/-name fastab means looking for a file named Fastab under the system root directory

Common Linux Commands

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.