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

Summary of Common system Management commands in Linux

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

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "summary of common system management commands in Linux". In daily operation, I believe that many people have doubts about the summary of common system management commands in Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "summary of common system management commands in Linux". Next, please follow the editor to study!

1. Top

1. Action

The top command is used to display the progress of the program in execution, and the permission is for all users.

two。 Format

Top [-] [d delay] [Q] [c] [S] [s] [I] [n]

3. Main parameters

D: specifies the interval between updates, measured in seconds. Q: there are no delayed updates. If the user has a superuser, the top command will be executed in the highest priority. C: displays the full path and name of the process. S: cumulative mode, which accumulates the CPU time of subtrips that have been completed or disappeared. S: safe mode. I: do not show any idle (Idle) or useless (Zombie) itinerary. N: displays the number of updates, and will exit top after completion.

4. Description

Top command is one of the main commands of Linux system management, through which a lot of information can be obtained. Here we combine figure 1 to illustrate the information it gives.

Figure 1 display of the top command

In figure 1, the items represented in the first line are the current time, the system startup time, the number of current system login users, and the average load. The second line shows all started, currently running, Sleeping, and Zombie processes. The third line shows the current usage of CPU, including the percentage occupied by the system, the percentage of users using it, and the percentage of idle (Idle). The fourth line shows the physical memory usage, including the total available memory, used memory, free memory, and memory occupied by buffers. The fifth line shows the swap partition usage, including the total swap partition, used, idle, and the size used for caching. The sixth line shows the most items, and a detailed explanation is listed below.

PID (Process ID): the process identification number. USER: the user name of the process owner. PR: the priority of the process. NI: the priority value of the process. VIRT: the virtual memory value occupied by the process. RES: the physical memory value occupied by the process. SHR: the shared memory value used by the process. S: the state of the process, where S indicates hibernation, R indicates running, Z indicates dead state, and N indicates that the process priority value is negative. % CPU: the CPU usage occupied by this process. % MEM: the percentage of physical memory and total memory consumed by the process. TIME+: the total CPU time spent by the process since it was started. Command: the name of the startup command that the process starts. If this line is not displayed, the process will have a complete command line.

During the use of the top command, you can also use some interactive commands to complete the functions of other parameters. These commands are started by shortcut keys.

Refresh immediately. P: sort by CPU usage size. M: sort by the amount of memory used. T: sort according to time and cumulative time. Q: exit the top command. M: toggles the display of memory information. T: toggles the display of process and CPU status information. C: toggles the display command name and the full command line. W: writes the current settings to the ~ / .toprc file. This is the recommended way to write top configuration files.

As you can see, the top command is a very powerful tool for monitoring the system, especially for system administrators. However, its disadvantage is that it consumes a lot of system resources.

5. Application example

Use the top command to monitor specified users, and the default is to monitor the processes of all users. If you want to see the situation of the specified user, press the "U" key in the terminal, and then enter the user name, and the system will switch to the process running interface of the specified user, as shown in figure 2.

Figure 2 using the top command to monitor the specified user

II. Free

1. Action

The free command is used to show memory usage, with permissions for all users.

two。 Format

Free [- b |-k |-m] [- o] [- s delay] [- t] [- V]

3. Main parameters

-b-k-m: displays memory usage in bytes (KB, MB), respectively. -s delay: displays the number of seconds per second to show memory usage. Lmurt: displays the memory sum column. -o: the buffer adjustment column is not displayed.

4. Application example

The free command is the main command used to view memory usage. Compared with the top command, it has the advantage of being easy to use and consuming only a small amount of system resources. With the-S parameter, you can use the free command to continuously monitor how much memory is used, so that it can be used as a convenient real-time monitor.

# free-m-s 3

After using this command, the terminal will continuously report memory usage (in MB), updated every 3 seconds.

III. Kill

1. Action

The kill command is used to abort a process.

two。 Format

Kill [- s signal |-p] [- a] pid...

Kill-l [signal]

3. Parameters.

-s: specifies the signal to be sent. -p: analog transmission signal. -l: specifies the name list of the signal. Pid: the ID number of the process to be aborted. Signal: indicates a signal.

4. Description

Process is a very important concept in Linux system. Linux is a multitasking operating system on which multiple processes are often running at the same time. We don't care how these processes are allocated, or how the kernel manages the allocated time slices, what we care about is how to control these processes so that they can serve users well.

The Linux operating system includes three different types of processes, each with its own characteristics and attributes. An interactive process is a process started by a Shell. Interactive processes can be run either in the foreground or in the background. The batch process has no connection with the terminal and is a process sequence. Monitor the process (also known as the system daemon) that the Linux system starts when it starts and runs in the background. For example, httpd is the monitoring process of the famous Apache server.

The kill command works by sending a system operation signal and the process identification number of a program to the kernel of the Linux system, and then the kernel can operate on the process specified by the process identification number. For example, in the top command, we see that the system is running many processes, and sometimes we need to use kill to abort certain processes to improve system resources. When explaining the installation and login commands, it was mentioned that the function of multiple virtual consoles of the system is that when a program goes wrong and causes the system deadlock, you can switch to another virtual console to close the program. The command used at this point is kill, because kill is something that most Shell internal commands can call directly.

5. Application example

(1) forcibly abort (often kill) a process with identification number 324:

# kill-9 324

(2) unlock the Linux system

It sometimes happens in Linux that a program crashes and is in a deadlock state. At this point, there is generally no need to restart the computer, just stop (or close) the problematic program. When kill is in the X-Window interface, the main programs (except for crashed programs) are generally started normally. At this point, open a terminal and abort the problematic program there. For example, if a Mozilla browser program is locked, you can use the kill command to abort all programs that contain Mozolla browsers. First use the top command to check the program's PID, and then use the kill command to stop the program:

# kill-SIGKILL XXX

Where XXX is the process identification number of the program that contains the Mozolla browser.

(3) use the command to reclaim memory

We know that memory is very important to the system, and recycling memory can improve system resources. The kill command can stop some "deviant" programs in time or have no corresponding programs for a long time. For example, to find a Zombie process using the top command, you can use the following command:

# kill-9 XXX

Where XXX is a useless process identification number.

Then use the following command:

# free

At this point, you will find that the amount of available memory has increased.

(4) killall command

Linux also provides a killall command that can directly use the name of the process instead of the process identification number, for example:

# killall-HUP inetd

4. Check the remaining space on the disk df (df-h)

Usage: df [option]... [document]...

Displays information for each file system on which it resides, and all file systems are displayed by default.

The parameters that the long option must use are also necessary when using the short option.

-a,-all includes a file system with a size of 0 blocks-B,-block-size= size blocks in specified bytes-h,-human-readable prints the file system size in an easy-to-understand format (for example, 1K 234m 2G)-H,-si similar to-h But take the power of 1000 instead of 1024Coli,-inodes displays inode information instead of block usage-k that is-block-size=1K-l,-local only shows native file system-no-sync does not perform sync action before obtaining usage data (default)-P,-portability uses POSIX output format-sync action before sync gets usage data-t,-type= type only prints specified file system information-T -print-type print out file system type-x,-exclude-type= type prints only non-specified file system information-v (this option is not processed)

Summary:

Top-c

Free-m

Kill-9 2312 (description: forcibly kill process kill-9 pid)

Df-h

At this point, the study on "summary of common system management commands in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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