LFCS Admin Exam preparation guide – Diagnose and manage processes

LFCS Admin Exam preparation guide – Diagnose and manage processes

LFCS Admin Exam preparation guide series, main page can be found here.

This post is part of the Operation of Running Systems from the domain competency list for the exam. The full list can be found in the link above paragraph or the Linux Foundation page here.

Like every Operating System, Linux is full of running processes, there is few ways we can manage them. Let’s us take a look.

Gathering information

The ps command – display a snapshot of processes at a specific time, useful to capture running processes, check ownership, and PID of the process. Running the command without any operators, we will get processes running in the current shell, PID – unique ID, TTY – a type of terminal user is logged on, TIME – the time the process has been running, CMD – the command that launched the process. Adding –ax will display all processes running and as well not associate with our terminal.

ps command example

Running ps command with –help option give us idea what kind of information about processes we can retrieve and how we can modify the output.

ps – Basic Options
ps – selection by list
ps command output formatting options
ps command for display processes by threads
ps command miscellaneous options

We can use most of the option above to help us to manage what information we will like to see about processes.

Monitoring processes

The most popular command to monitor running processes will be – top – this command display processes and provides a dynamic real-time view. We can see information like how long is our server running, how many users are logged on, what the CPU and memory usage, and much more information.

top command display

We can access the interactive help for the top by pressing the h key, we will see all the options we can change to view a different kinds of information about our running system.

top interactive help

htop – is another monitoring tool, very similar to the top but it expands its abilities, provides color highlighting, mouse integration, ability to search, sort, and kill processes. Same with the above tool by pressing h key we can access help but as well we can use the F1 key and few other F keys to access other abilities.

htop command interface
htop command help window

Managing processes

One additional function of htop is the possibility to kill processes, we can simply select the process and press k or F9 to be redirected to a new menu where we have many options to send a command to the process, select number 9, and press Enter to proceed. To learn more about the signal options we can run man 7 signal scroll down to line 140. We will be present with all the signal option and explanation (screenshot below)

htop kill command view
htop signals option and explanation

In Linux, we can manage process scheduling with the nice command, which modifies the priority for new process -20 is the highest 19, the lower and default value is 0. We use this command to set the “niceness” of the process. nice -n <nice value> <process name> is the command we can use. This command will allow us to the launch process with niceness specify by us.

nice command help window

Another useful command is renice, which allows is to change the priority of already running processes. The range is the same -20 for the highest and 19 for the lowest.

renice command window

That was long post. Thank you for reading. Keep on learning!

Advertisements