LINUX Process Management

If you are new to Linux or using it just because your senior developer in your office wants you to use it to look cool!, then you must be missing some features of windows like the great Process manager where you can see which program is using most of your laptop resources like your RAM, CPU or disk speed and can close it directly from there. Linux has some great tools for process management. Today we will talk about some CLI tools which you can use for process management and in next blog we will talk about some GUI tools.

Before running into process management let talk about what is a process. A process is a program in execution, it’s a running instance of your code or someone else code. It is made up of program instruction (Code), and data that you read from some file or any other resource or user input data.

There are two types of processes Background and Foreground. Foreground are the interactive one with which you can interact, they expect your input and you have to start them. Background are those that run in the background and most of the time the system start them and they don’t need your input.

Linux use Process Id (PID) and parent process id (PPID) for identification of different process. When a process is started Linux assign it an id.

There are a lot of command line tools for managing and listing running process in Linux.

ps Command

ps command is used to display information about the active processes in the system at the current moment. If you want a repetitive update use top instead. If you just run ps in command line it will show information just show currently running processes with minimal information you can use it with different argument to show the information that you want like with -e or -A argument it will show all process. -u option will show user-oriented format with CPU and MEM utilization.

top command

Unlike ps command that shows you process detail at the current moment top command will give you dynamic real-time information about the processes running in the system and their utilization of the system resources. On top it will show number of currently running tasks(processes), CPU, RAM and Swap memory usage in human readable format. by default top update every 3 second but you can change that by just pressing d while top is running and entering the desired interval. to kill a process just press k while top is running and enter PID. to show specific user processes press u and then username. There are a lot of other option you can do with top command just use man top to get full information.

htop command

htop is newer version of top. It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines, as well as viewing them as a process tree, selecting multiple processes and acting on them all at once. Also with htop you can use mouse and also it has a help menu type at the bottom of the shell so you don’t have to remember the keys to operate on processes. As you can see in the picture you can use F3 to search for specific process, F5 for viewing in tree format, F6 to sort them, F7 and F8 for nice and renice, and F9 to kill a process. Other option which you can use with htop are

-d Delay between updates, in tenths of seconds

-u USERNAME to show only specific user processes

-t show processes in tree view

There are several other useful Linux system monitoring tools you can use to list active processes and manage them we will keep exploring them and will share with you. Until then enjoy your day!

Thanks for reading, if you wanna explore more about these command man command is always your friend, just use man command-name.

If you have any question feel free to comment

You can follow me on twitter @ilyash00 where I share some cool stuff about programming and occasionally create some zines

Copyright ©