Executing programs are called processes. When a program is stored in an executable file and is running, each process is dynamically allocated system resources, memory, security attributes, and status associated with it. Multiple processes can be associated with the same program and executed at the same time without interfering with each other. Operating System
effectively manages and tracks all running processes.
In order to manage these processes, users should be able to:
Linux provides A number of commands are available to allow users to efficiently control the above operations. Next, explain one by one.
1. ps
‘ps’ is the most basic command in the browsing system in Linux. 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 messages.
ps -a - List all running/active processes
ps -ef | Grep - lists the required processes ps -aux - displays process information, including terminalless (x) and processes for users (u): such as USER, PID, %CPU, %MEM, etc.2. pstree
In Linux, every process is created by its parent process. This command visualizes the process and shows the interprocess relationship by displaying a tree view of the process. If pid is specified, then 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. The data showing the process includes PID, process owner, priority, %CPU, %memory, and so on. These displays can be used to indicate resource usage.
4. htop
htop is similar to top, but htop is an interactive text mode process viewer. It graphically displays the CPU and memory usage and swap usage of each process. Use the up and down cursor keys to select the process, F7 and F8 to change the priority, and F9 to kill the process. Htop is not installed by default, so additional installation is required.
5. nice
With the help of the nice command, the user can set and change the priority of the process. To increase the priority of a process, the kernel allocates more CPU time slices to the process. By default, processes start with a priority of zero. The process priority can be viewed by 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 <priority value> <process name> - start a program with a given priority value
In the above command example, See the ‘top’ command to get a -3 priority value.
6. renice
The renice command is similar to the nice command. Use this command to change the running process priority value. Note that users can only change the priority value 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 the process priority value by specifying the user and group
In the above example, the priority value of all processes for the user ‘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 require a forced kill, using the -9 parameter to execute. Note that you must be careful when using forced kills, because the process does not have the opportunity to clean up the site, and perhaps the file is not completed. If we don't know the process PID or plan to kill the process with a name, killall can come in handy.
kill <pid>kill -9 <pid>killall -9 - Kill all processes with the same nameIf 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.
pkill <process name>
8. ulimit
This command is used to control system resources on the shell and process. The amount of distribution. It is most useful for system administrators to manage systems that are heavily used and have performance issues. Restricting resource size ensures that important processes continue to run, and other processes do not consume too much resources.
ulimit -a - Display resource restrictions associated with the current user
-f - Maximum file size -v - Maximum virtual memory size (KB) -n - Increase maximum file description Number of symbols - H : Change and report hard limits -S : Change and report soft limitsBrowse 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 current time, system runtime, total number of logged in users, and load balancing in the past 1, 5, and 15 minutes.
Based on these user information, users should be careful when terminating processes that are not theirs.
who is a similar command that provides a list of currently logged in users, system startup time, run level, and more.
whoami command output current user ID
10. pgrep
pgrep means ”process number global regular match Output & rdquo;. This command scans the currently running process and then lists the matching results to the standard output according to the command matching criteria. It is useful for retrieving the process number by name.
pgrep -u mint shThis command will display the process ID of the user ‘mint’ and the process name ‘sh’.
11. fg , bg
Sometimes, the command takes a long time to execute. For this situation, we can use the ‘bg’ command to put the task in the background, and use ‘fg’ can be used in the foreground.
We can start a program in the background by ‘&’:
find . -name *iso > /tmp/res.txt &A running The program can also be run in the background by the combination of “CTRL+Z” and “bg” commands.
find . -name *iso > /tmp/res.txt & - Start a program ctrl+z - Suspend the current execution program bg - Put the program in the background to runWe can use &lsquo The ;jobs’ command lists all background processes.
jobsUse the ‘fg’ command to bring the daemon to the foreground.
fg %process id
12. ipcs
The ipcs command reports the status of interprocess communication facilities. (shared memory, semaphores, and message queues)
Use the -p parameter with -m, -s, or -q to get the process ID of the associated interprocess communication.
ipcs -p -mThe screenshot below shows the ID and process ID of the creator of the process that recently accessed the shared memory segment.
Summary
In short, these commands can help administrators fix problems and improve performance. Also as a regular user, you need to solve the problem of the process. Therefore, being familiar with such a large number of commands is effective in effectively managing processes.
1. Lock the redundant self-built account in the systemCheck method:Execute the command#cat /etc/pas
Just as Hong Kong is still engaged in tug-of-war on the issue of electronic textbooks for bookseller
When doing the experiment, we burned the bin file into the SD card, such as the previous assembly fl
The Linux command line is useful, efficient, and fun, but sometimes dangerous, especially if you are
Linux instance recovery file deleted
Poll&&epoll implementation analysis (a) - poll implementation
How to force regular changes to Linux passwords
Overview of International Program Implementation Steps
Linux system UMASK usage details
Linux shell script to remove source annotations
Shareholders Lao Li and Win7 story UAC set anti-rogue
This is not good, it is urgent! ! ! ! ! ! ! ! Seeking God
Windows7 RC Build 7022 download screenshot
Win8 touch version IE10 will enable Flash by default
Windows 7 Change User Account Control Settings
How to use the Heiner River Downloader? Heiner Baichuan Downloader Usage Method
Win10 sound suddenly big and small how to do? Win10 play music high and low solution
Enable Gzip compression (HTTP compression) on IIS
Solution for failing to connect to VPN proxy under Win8 system
Win7 system "display desktop" icon disappeared how to recover?