Process Management Commands

Hello everyone, are you ready to slowly approach the exciting scenes in AI movies that many of us crave? Joke aside, when I wrote my codes in the first terminal and performed the query, in my first hello world correspondence, I was as excited as if it were connected to all the systems in the world. Besides, my excitement grew when I started performing operations on users in the terminal. So I’m ready to do little things that will excite you. If you’re ready, let’s get started.

Step-By-Step Management Commands

  • top : A command line that displays all running processes in seconds.

For example, when we run the top command on the console, we need to encounter information such as the visual below. Let’s check it out 🚀

This image has an empty alt attribute; its file name is Ekran-Resmi-2020-09-15-16.51.09-1024x222.png

A total of 308 processes are processed, and if you need to examine the table below, the PID ( processing id) contains a unique value. Each process must have its own PID value.

top -o PID

In the code line above, a sort is performed according to PID values.

This image has an empty alt attribute; its file name is Ekran-Resmi-2020-09-15-22.50.54.png
top | grep firefox

If this code is wrapped, the top command instantly fetches the last line of firefox. It should be noted that the top command works instantaneously in the terminal.

By the way, % CPU determines the amount of use of the central processing unit by processes while %MEM specifies the amount of memory usage.

Just press the ‘q’ character to re-process the terminal.

  • ps : Lists all process information currently running on your computer.
This image has an empty alt attribute; its file name is Ekran-Resmi-2020-09-15-17.26.52.png
Process running with PID value of 825

If we want to know the PID value of the running process, we need to write the following line of code.

ps aux | grep safari
This image has an empty alt attribute; its file name is Ekran-Resmi-2020-09-15-17.29.43-1-1024x33.png

NOTE: The ps aux command only gives all process information when used.

This browser information could have been firefox, you can write it if you want to know which process. So why do you think it’s important to learn PID values? Let me think about it. How do you recognize an unidentified person? Processes must have an identity just like people. When killing processes, processing should be performed according to ID values, not according to processing names.

ps -ef
This image has an empty alt attribute; its file name is Ekran-Resmi-2020-09-15-22.34.33-1024x134.png
  • kill : Kills processes with Kill signals.

❗️To list the kill signals, we must necessarily use the -l argument.

kill -7 2574

For example, we want to kill the signal sent by the firefox process, but we should definitely do this by specifying the PID. In the above command, we send a request to kill signal 2754.

CONCLUSION

If we summarize, the process commands that we use most often are like this. In my next article, I will talk about user management commands. I wish you healthy and abundant research days. Hope to see you.

REFERENCES

https://medium.com/@gokhansengun/linux-prosesleri-nasıl-yönetir-9b1536dc06f7
Yasin Ortakci, Karabuk University, Operating Systems Lab.

Related Posts

Leave a Reply