Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What commands do Linux have to use?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "what are the useful commands for Linux". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

View help commands

In the Linux system, there are many commands. How do I know what a command is for? I can execute a help command to check: man man.

The general format for executing Linux commands is as follows: command name [command parameters] [command object]

Note: there is a space between them.

Common system commands

The echo command, which is used to output the value of a string or variable at the terminal in the format "echo [string] [$variable]"

Date command, used to display and set the time or date of the system, the format is "date [options] [specified format]" this command is very common in daily work when looking for backup data, of course, as long as your backup data is related to the date.

Date command to view the current system time: date

View the current system time in the format of "year-month-day hour: minute: second": date "+% y-%m-%d% H:%M:%S"

Set system time: date-s + time format

Reboot command, restart command. This command is very common, after all, when the virtual machine is stuck, there is no problem that cannot be solved by rebooting. If there is, restart it again.

Poweroff command, shutdown command. I won't say much about this.

The wget command is used to download the network file in the terminal in the format of "wget [parameter] download address". Wget is an installation tool, equivalent to Thunderbolt.

The yum command is used to install the software. The format is "yum install Software name"

Ps command to view the status of processes on the system in the format "ps [parameters]"

For example, check the status of Nginx:

The pidof command, which is used to query the PID value of a specified service process in the format "pidof [parameter] [service name]". It is generally used with the kill command.

Kill command to terminate a specified PID service process in the format "kill [parameters] [process PID]"

First use the pidof command to find out the PID of the service you want to stop, and then use the kill command to kill the process.

The killall command, which terminates all processes corresponding to a service with a specified name. Sometimes, there are child processes under the parent process. For convenience, killall directly kills all the processes of the specified service. The format is "killall [parameter] [process name]"

System detection command

Ifconfig command, which is used to obtain information such as network card configuration and network status, in the format of "ifconfig [network equipment] [parameters]"

Uname command, which is used to view information such as system kernel and system version. The format is "uname [- a]"

Uptime command to view the load information of the system, which can display information such as the current system time, the time the system has run, the number of enabled terminals and the average load value

The free command, which is used to display memory usage information on the current system.

Who command, which is used to view the user terminal information of the currently logged-in host in the format of "who [parameters]"

The last command, which is used to view login records for all systems. The format is "last [parameter]". Speaking of this command, A Fan still remembers that another colleague in the company asked me if I was logged in to the XX virtual machine. I was quite surprised at that time. How did he know? he should not be spying on me. Now I know why.

The history command, which is used to display commands that have been executed in history, in the format "history [- c]"

Sosreport command to collect system configuration and architecture information and output diagnostic documents

Working directory switch command

The pwd command, which is used to display the working directory where the user is currently located.

Cd command, the user switches the work path. The format of the command "cd [directory name]" can be said to be very common, for example: Ah Fan wants to return to the last directory cd-go, want to enter the next directory, cd. To switch to the current user's home directory, try cd ~

Ls command, which is used to display the file information in the directory. The format is "ls [options] [File]". For example, ls-a can view all files (including hidden files), ls-l, you can view file attributes, size and other details.

Text file editing command

Cat command to view plain text files (less content) in the format "cat [options] [files]"

If you want to display the line number by the way when viewing the text, you can try appending a-n parameter to the cat: cat-n file

More command to view plain text files (with more content) in the format "more [options] [files]"

Head command to view the first N lines of a plain text document in the format "head [options] [File]"

File directory management command

The mkdir command is used to create a blank directory in the format "mkdir [options] [directory]". In addition to creating a single blank directory, the mkdir command can also be combined with the-p command to recursively create a file directory with a nested stack relationship.

Mv command to cut or rename a file in the format "mv [option] source file [destination path | destination file name]

The file command, which is used to view the type of file, in the format "file file name"

Cp command, which is used to copy files or directories. The format is "cp [option] source file destination file"

The parameters and functions of the cp command:

Parameter function-p retains the properties of the original file-d if the object is a "linked file", then retain the attributes of the "linked file"-r recursive continuous copy (for directories)-I if the target file exists, asking whether to overwrite-an is equivalent to performing cp-pdr

Package Compression and search Command

Tar command, which is used to package, compress or extract files in the format of "tar [options] [files]"

The parameters and functions of the tar command:

The role of the parameter-c to create a compressed file-x to unzip a compressed file-t to see what files are in the package-v shows the process of compression or decompression-p retains the original permissions and attributes-P uses an absolute path to compress-C specifies the directory to which it is extracted

The grep command, which is used to perform a keyword search in the text and display the matching results. The format is "grep [options] [file]"

The parameters and functions of the grep command:

Parameter function-b searches the executable file (binary) as a text file (text)-c shows only the number of lines found-I ignore case-n display line number-v reverse selection-lists only lines that do not have "keywords"

The find command, which is used to find files according to the specified criteria. The format is "find [find path] find conditional operation". In Linux system, the search work is usually done through the find command.

About service startup and shutdown

Sometimes, we need to restart, shut down, and start a service, and these commands are quite common.

Systemctl start service name start service systemctl restart service name restart service systemctl stop service name stop service systemctl enable service name add to boot item systemctl disable service name cancel add to boot item systemctl status service name check service status "what are the useful commands for Linux", thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report