The document discusses process management in Linux, including getting processor and memory information, monitoring running processes, killing processes, and differentiating between foreground and background processes. Key points covered include checking CPU and memory details in /proc/, using ps, top, pstree and jobs commands to view processes, killing processes by ID or signal, and how foreground processes run sequentially while background processes run simultaneously.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
305 views15 pages
Proses PDF (En)
The document discusses process management in Linux, including getting processor and memory information, monitoring running processes, killing processes, and differentiating between foreground and background processes. Key points covered include checking CPU and memory details in /proc/, using ps, top, pstree and jobs commands to view processes, killing processes by ID or signal, and how foreground processes run sequentially while background processes run simultaneously.
$ gnome-system-monitor Version 1.0 linuxslides.blogspot.com Kernel and hardware info Check our kernel: $ uname -a Linux linuxmint 2.6.24-16-generic ...
$ dmesg | grep Linux
[ 0.000000] Linux version 2.6.24-16-generic ...
Displaying hardware informations:
$ dmesg | less
Displaying PCI hardware info (vga, sound card, etc):
$ lspci
Version 1.0 linuxslides.blogspot.com
Monitoring process Displaying active processes: $ ps PID TTY TIME CMD 9861 pts/0 00:00:00 bash 10157 pts/0 00:00:00 ps
PID: Process identity
TTY: Terminal where the process is running TIME: Time needed by CPU to complete the process CMD: The command which is executed
Version 1.0 linuxslides.blogspot.com
Monitoring process Displaying all active processes: $ ps a PID TTY STAT TIME COMMAND 4471 tty3 Ss+ 0:00 /sbin/getty 38400 tty3 4473 tty6 Ss+ 0:00 /sbin/getty 38400 tty6 8408 tty1 Ss+ 0:00 /sbin/getty 38400 tty1 9861 pts/0 Ss 0:00 bash 10158 pts/0 R+ 0:00 ps a
STAT is the status of the process, which are: Uninterruptible
sleep, Running, Interruptible sleep, Stopped, session leader, foreground, etc. Further info see chapter PROCESS STATE CODES in ps manual.
Version 1.0 linuxslides.blogspot.com
Monitoring process Displaying all active processes from all user: $ ps au USER PID %CPU %MEM VSZ RSS TTY STAT START ... root 4471 0.0 0.0 716 424 tty3 Ss+ 08:14 root 4473 0.0 0.0 716 424 tty6 Ss+ 08:14 root 8408 0.0 0.0 716 424 tty1 Ss+ 08:14 joni 9861 0.0 0.0 716 424 pts/0 Ss 11:07 joni 10158 0.0 0.0 716 424 pts/0 R+ 11:07
USER : user name who run the process
%CPU/MEM: percentage CPU/MEM used by process VSZ : virtual memory size of the process in KB RSS : resident set size, RAM used in KB START : the time process start Version 1.0 linuxslides.blogspot.com Monitoring process Displaying all active processes from all user including non-tty: $ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START ... root 4471 0.0 0.0 716 424 tty3 Ss+ 08:14 root 4473 0.0 0.0 716 424 tty6 Ss+ 08:14 root 8408 0.0 0.0 716 424 tty1 Ss+ 08:14 root 8438 0.0 0.0 716 424 ? Ss 08:14 root 8439 0.0 0.0 716 424 ? Ss 08:14 root 8440 0.0 0.0 716 424 ? Ss 08:14 joni 9861 0.0 0.0 716 424 pts/0 Ss 11:07 joni 10158 0.0 0.0 716 424 pts/0 R+ 11:07
Displaying process which is not associated or executed from a
terminal, such as init process, daemon, etc. Version 1.0 linuxslides.blogspot.com Display a tree of processes $ pstree -p | less init(1)─┬─NetworkManager(4864)───{NetworkManager}(5045) ├─NetworkManagerD(4878) ├─acpid(4646) ├─apache2(8271)─┬─apache2(8321) │ ├─apache2(8323) │ ├─apache2(8324)
Process tree often needed when we have to terminate a parent
process, because the child process is unable to kill.
Version 1.0 linuxslides.blogspot.com
Monitoring process real time $ top
Version 1.0 linuxslides.blogspot.com
Terminating (kill) process
Use the PID to kill a process:
$ kill <PID> $ kill 8710
If command above failed, use option “-9”:
$ kill -9 8710
LAB: Open new terminal in Desktop and type gedit command. Try to find the terminal's PID (not gedit PID) and kill. Make sure the terminal and gedit terminated properly.
Version 1.0 linuxslides.blogspot.com
Foreground process
Process 1 Process 2 Process 3
Background process
Process 1 Foreground process run
sequentially, when Process 2 background process run simultaneously.
Process 3
Version 1.0 linuxslides.blogspot.com
Foreground and background
Sample of foreground process:
$ find / -name xyz > result.txt 2>&1
We have to wait until process above finished, then we can run
another process: $ ls -l
Sample of background process:
$ find / -name xyz > result.txt 2>&1 &
At the same time, we can run another process directly:
$ ls -l
Version 1.0 linuxslides.blogspot.com
Change foreground to background Changing foreground process to background: $ find / -name xyz > result.txt 2>&1 Ctrl+Z [1]+ Stopped find / -name xyz > result.txt 2>&1