PS command is used to check the currently running process in Linux/Unix operating system. Basically it reports the snapshot of a processes. Every process has some unique id assigned which is PID.
Let’s start exploring PS command. Just open your terminal and start typing PS and hit enter
1 |
PS |
1 2 3 4 |
rajkumar@rajkumar-Lenovo-Z580:~$ ps PID TTY TIME CMD 2549 pts/1 00:00:00 bash 2908 pts/1 00:00:00 ps |
It list all the currently running processes on your system.
PS -ef Command
1 |
PS -ef |
This command shows all the processes with full format listing.
-e – Currently running processes
-f – full format listing
1 2 3 4 5 6 7 8 |
rajkumar@rajkumar-Lenovo-Z580:~$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 22:44 ? 00:00:00 /sbin/init root 2 0 0 22:44 ? 00:00:00 [kthreadd] root 3 2 0 22:44 ? 00:00:01 [ksoftirqd/0] root 6 2 0 22:44 ? 00:00:00 [migration/0] root 7 2 0 22:44 ? 00:00:00 [watchdog/0] root 8 2 0 22:44 ? 00:00:00 [migration/1] |
PS -l
Display processes including those which are in wait state.
1 |
PS -l |
1 2 3 4 |
rajkumar@rajkumar-Lenovo-Z580:~$ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1000 2549 2544 0 80 0 - 6807 wait pts/1 00:00:00 bash 0 R 1000 2916 2549 0 80 0 - 3480 - pts/1 00:00:00 ps |
Mostly the ps command is used in linux to grep the PID of malfunctioning processes and terminate it using kill command.
To terminate any process you can use kill command
Syntax –
PID – Id of a process which you want to terminate.
1 |
kill PID |