18.09.2023

How To Use ps, kill, and nice to Manage Processes in Linux

How To Use ps, kill, and nice to Manage Processes in Linux

Linux is a powerful operating system widely used in the world of servers and personal computers. One of the key advantages of Linux is its ability to efficiently manage processes running on the system. In this article, we'll explore three essential utilities - ps, kill, and nice - that allow you to effectively manage processes in Linux.

ps utility

The ps (process status) utility provides information about the processes running on your system. It allows you to determine the status, identifiers, resource consumption, and other essential details of processes. Here are some key options that can be used with the ps utility:
Displays all processes on the system

ps -A

Displays processes belonging to a specific user

ps -u username

Displays detailed information about processes, including those from all users

ps -aux

By utilizing the ps utility, you can monitor and analyze active processes in your Linux system.

kill utility

The kill utility enables you to terminate running processes. You can use the kill "PID" command to terminate a process by its Process ID (PID). For instance, terminate the process with the ID 1187:

kill 1187

However, there are other options available for the kill utility
Terminates all processes with a specific name

killall process_name

Forcefully terminates a process by ignoring any signals

kill -9 PID

Displays a list of available signals to send to a process

kill -l

The kill utility provides us with the ability to control running processes in the Linux system.

nice utility

The nice utility is used to manage process priorities. Each process in Linux has a "nice value," which is a number that determines its priority. A lower nice value corresponds to a higher priority for the process. The nice utility allows you to modify the priority of a process during execution.

Options available with the nice utility include:
Runs a command with the specified nice value

nice -n

Changes the nice value of an existing process

renice

The nice utility enables us to control running processes and adjust their priorities in Linux.

In conclusion, the ps, kill, and nice utilities are powerful tools that help you manage and control processes in Linux. They provide information on processes, allow termination of unwanted processes, and modify process priorities to optimize system performance. These tools are valuable for both server administrators and regular Linux users.