Linux Processes

Key Goals

  • Listing the running processes
  • Identifing the resource utilization by process
  • Moving tasks to backgroud / foregroud
  • Killing processes
  • Changing the process priority

Content

Listing processes:
  • The /proc directory
  • ps
  • pstree
  • pgrep
  • top
Killing processes:
  • kill and pkill
Foregrouding & Backgrouding jobs:
  • bg
  • fg
  • jobs
Process priority:
  • nice
  • renice

Exercises

  1. Scenario:
    1. Run sleep 10000.
    2. How can you move it to the backgroud?
    3. How would you start it in a background initialy?
    4. Run sleep 10000 again (start it in a backgroud).
    5. Repeat it again.
    6. Run jobs to view the running tasks, what is the meaning of the + sign?
    7. Move the second one to the foreground and stop it.
    8. Terminate the other 2 using the kill command.
  2. Explain the content of the /proc directory.
  3. Which process is repesented by the following directory “cd /proc/$$”?
  4. List the process details with a ProcessID equals to 1, which one is it?
  5. What is the RSS (Resident Set Size), and how can we list it using the ps command?
  6. Use ps and grep to list the sshd daemon.
  7. List all the available signals that can be sent by kill.
  8. Explain the difference between SIGKILL and SIGTERM.
  9. Find your sshd pid and use kill to send it a SIGKILL signal.
  10. Run top and sort it by %MEM (RAM) utilization.
  11. Using pstree print the process tree of the NetworkManager service.
  12. Scenario:
    1. Run sleep& 1000 three times in your bash shell.
    2. Use pgrep to list thier pids
    3. Use pkill to kill those processes
  13. How can we view the Priority(PRI) and Nice(NI) values of a process?
  14. Explain the meaning of the Nice(NI) value of a process ,and how is the CPU Priority(PRI) value is related to the NI value of a particular process?
  15. What is the default values of Priority(PRI) and Nice(NI) variables for a new process?
  16. What is the range of possible values that Priority(PRI) and Nice(NI) can have?
  17. Run the ‘sleep 1000’ in a backgroud with the lowest possible Priority.
  18. What is the usage of the renice command?