In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
What are the knowledge points of this article "Linux process management commands?" most people do not understand, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Linux process management commands" article.
An executing program is called a process. When a program can execute files in storage and run, each process is dynamically assigned system resources, memory, security attributes, and associated states. Multiple processes can be associated with the same program and executed at the same time without interference with each other. The operating system effectively manages and tracks all running processes.
To manage these processes, users should be able to:
● to view all running processes
● View process consumes resources
● locates individual processes and performs specified operations on them
● changes the priority of the process
● kills the specified process
● limits the system resources available to the process, etc.
Linux provides a number of commands to allow users to efficiently control the above operations. Next, let's explain it one by one.
1.ps
'ps' is the most basic command in Linux to browse processes in the system. Can list the processes running in the system, including process number, command, CPU usage, memory usage and so on. The following options can get more useful information.
Ps-a-list all running / active processes ps-ef | grep-list the required processes ps-aux-display process information, including processes without terminals (x) and for users (u): such as USER, PID,% CPU,% MEM, etc. 2.pstree
In linux, each process is created by its parent. This command displays the process visually and shows the relationship between processes by displaying a tree view of the process. If pid is specified, the root of the tree is the pid, otherwise it will be init (pid: 1).
3.top
'top' is a more useful command to monitor the resources used by different processes in the system. It provides real-time system status information. Data showing the process includes PID, process owner, priority,% CPU,% memory, and so on. You can use these displays to indicate resource usage.
4.htop
Htop is similar to top, but htop is a process viewer in interactive text mode. It graphically displays the CPU and memory usage and swap usage of each process through text. Use the up and down cursor keys to select the process, F7 and F8 change the priority, and F9 kill the process. Htop is not installed by default on the system, so additional installation is required.
5.nice
With the help of the nice command, users can set and change the priority of the process. Raise the priority of a process, and the kernel allocates more CPU time slices to the process. By default, the process starts with a priority of 0. The process priority can be seen through the NI (nice value) column displayed by the top command.
Process priority values range from-20 to 19. The lower the value, the higher the priority.
Nice-starts a program with a given priority value
In the above command example, you can see that the 'top' command gets the priority value of-3.
6.renice
The renice command is similar to the nice command. Use this command to change the priority value of the running process. Note that users can only change the priority values of their own processes.
Renice-n-p-change the priority value of the specified process
The priority value of process 3806 with an initial priority value of 0 has become 4.
Renice-u-g-change process priority values by specifying users and groups
In the above example, the priority value of all processes whose user is' mint' 'becomes'-3'.
7.kill
This command is used to send a signal to end the process. If a process does not respond to the kill command, this may need to be forced to kill, using the-9 parameter to perform. Note that you must be careful when using forced killing, because the process does not have the time to clean up the scene, and the write file may not be completed. Killall can come in handy if we don't know the process PID or plan to kill the process by name.
Kill kill-9 killall-9-Kills all processes with the same name
If you use kill, you need to know the process ID number. Pkill is a similar command, but uses pattern matching, such as process name, process owner, and so on.
Pkill8.ulimit
This command is used to control the amount of system resources allocated on shell and processes. It is most useful for system administrators to manage systems that are heavily used and have performance problems. Limiting the size of resources ensures that important processes continue to run, and that other processes do not take up too much resources.
Ulimit-a-displays the resource limits associated with the current user
-f: maximum file size
-v: maximum virtual memory size (KB)
-n: increase the maximum number of file descriptors
-H: change and report hard limits
-S: change and report soft limits
Browse the ulimit man page for more options.
9.w
W provides information about the currently logged-in user and the process they are executing. The display header contains information, such as the current time, the running time of the system, the total number of logged-in users, and the number of load balancers in the past 15 minutes.
Based on this user information, users should be careful when terminating processes that do not belong to them.
Who is a similar command that provides a list of currently logged-in users, system startup time, run level, and so on.
The whoami command outputs the current user ID
10.pgrep
Pgrep means "process number global regular match output". This command scans the currently running process and then lists the matching results to standard output according to the command matching criteria. It is useful for retrieving process numbers by name.
Pgrep-u mint sh
This command will display the process ID with the user 'mint'' and the process name 'sh'.
11.fg, bg
Sometimes a command takes a long time to complete. In this case, we can use the 'bg' command to execute the task in the background, while the' fg' 'can be called to the foreground to use.
We can start a program in the background through'&':
Find. -name * iso > / tmp/res.txt &
A running program can also be run in the background with a combination of "CTRL+Z" and "bg" commands.
Find. -name * iso > / tmp/res.txt &-start a program ctrl+z-suspend the currently executing program bg-put the program to run in the background
We can use the 'jobs' command to list all background processes.
Jobs
Use the 'fg' command to call the background program to the foreground for execution.
Fg% process id12.ipcs
The ipcs command reports the status of the interprocess communication facility. (shared memory, semaphores and message queues)
Using the-p parameter in conjunction with-m,-s, or-Q, the process ID for related inter-process communication can be obtained.
Ipcs-p-m
The screenshot below lists the ID and process ID of the creator of the process that recently accessed the shared memory segment.
The above is about the content of this article on "what are the Linux process management commands?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.