12 Linux Process Management commands introduced

Source: Internet
Author: User

12 Linux Process Management commands introduced

When a program can execute files stored in the store and run, each process is dynamically assigned system resources, memory, security attributes, and the state associated with it. Multiple processes can be associated to the same program, and simultaneous execution does not interfere with each other. Linux provides a number of commands to enable users to control the above operations efficiently.

The procedure in progress is called a process. When a program can execute files stored in the store and run, each process is dynamically assigned system resources, memory, security attributes, and the state associated with it. Multiple processes can be associated to the same program, and simultaneous execution does not interfere 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 Consumption resources

Locating individual processes and performing specified actions on them

Change the priority of a process

Kills the specified process

Restricting the system resources available to the process, etc.

Linux provides a number of commands to enable users to control the above operations efficiently. Next, one by one to explain the next.

1.ps

' PS ' is a command of the most basic browsing process in Linux. Can list the processes running in the system, including process numbers, commands, CPU usage, memory usage, and so on. The following options give you more useful information.

PS-A-List all running/active processes

Ps-ef |grep-List required processes

Ps-aux-Displays process information, including non-terminal (x) and process for User (U): such as user, PID,%cpu,%MEM, etc.

2.pstree

In Linux, each process is created by its parent process. This command displays the process visually, showing the process's tree graph to show the inter-process relationships. 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. Data that shows the process includes PID, process owner, priority,%CPU,%memory, and so on. You can use these displays to indicate the amount of resource usage.

4.htop

Htop is similar to top, but Htop is the interactive text-mode Process viewer. It graphically displays the CPU and memory usage and swap usage of each process in a text format. Use the up and down cursor keys to select the process, F7 and F8 change the priority, F9 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, the process starts with a priority of 0. The process priority can be viewed by the NI (nice value) column displayed by the top command.

The process priority values range from 20 to 19. the lower the value, the higher the priority.

Nice < priority > < process name >-Start a program with a given priority value

In the above command example, you can see that the ' top ' command has a priority value of-3.

6.renice

The Renice command resembles the nice command. Use this command to change the running process priority value. 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 No. 3806, which has an initial priority of 0, has become 4.

Renice-u-G-Change process priority values by specifying users and groups

In the above example, the user has all the process priority values of ' mint ' changed to '-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 execute. Note that use forced kill must be careful, because the process does not have the opportunity to clean up the scene, perhaps the write file is not completed. Killall can come in handy if we don't know the process pid or if we're going to kill the process with a name.

Kill <pid>

Kill-9 <pid>

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.

Pkill < process name >

8.ulimit

This command is used to control the amount of system resources allocated on the shell and process. 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 excessive 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: Changing and reporting hard limits

-S: changing and reporting soft limits

Browse the Ulimit man page for more options.

7.9

W provides information about the currently logged on user and the process that is being executed. The information header contains information such as the current time, the system runtime, the total number of logged on users, the last 1, 5, and 15 minutes of load balancing.

Based on these 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 boot time, RunLevel, and so on.

WHOAMI command output current User ID

10.pgrep

Pgrep means "process number global regular match output". This command scans the current 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 of the user as ' mint ' and the process name ' sh '.

11.FG, BG

Sometimes, the command takes a long time to complete. In this case, we use the ' BG ' command to perform the task in the background, while the ' FG ' can be transferred to the foreground for 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 through the combination of "CTRL + Z" and "BG" commands.

Find. -name *iso >/tmp/res.txt &-Start a program

CTRL + Z-suspend current execution program

BG-Put the program in the background to run

We can use the ' Jobs ' command to list all background processes.

Jobs

Use the ' FG ' command to transfer background programs to the foreground.

FG% Process ID

12.ipcs

The IPCS command reports inter-process communication facility status. (Shared memory, semaphores, and Message Queuing)

With the-p parameter federated-m,-s or-Q, you can obtain the process ID of the related interprocess communication.

Ipcs-p-M

The following screen lists the ID and process ID of the creator of the process that recently accessed the shared memory segment.

Summarize

In summary, these commands can help administrators fix problems and improve performance. Also, as an ordinary user, there is a need to solve the problem of the process. So, being familiar with so many commands, from being able to manage processes effectively is effective.

--------------------------------------------------------------------------------------------------------------- --------------------------------

Transferred from: http://os.51cto.com/art/201507/485042.htm

12 Linux Process Management commands introduced

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.