Introduction to PS command in Linux
Linux process control could be implemented using the commands PS, kill, Bg, fg, jobs, nice, renice, grep and top . By using these commands any background daemon our program process can be effectively managed. The PS command is the process command which lists running processes and Damons and it is similar to task manager in Windows.
Syntax for PS command:
Options Available for PS command
Common PS option available:
|1||e||e option it displays running Daemons.|
|2||f||with the F option it displays processes with full options.|
|3||l||with the L option it would list more information on those processes.|
|4||ef||we were to combine e and F together that would display all processes and Daemons on all TTYS.|
|5||a||a would list all processes that run on terminals.|
|6||x||X would list all processes that do not run on terminals.|
|7||aux||we were to combine a U and X that would list all processes running on or off terminals and it would format the results with additional information similar to a long listing.|
Examples of PS command in Linux
Given below are the examples:
- Here, we get a basic process ID or ped you TTY it runs on remember there seven we can do all F 1 to F 6 for a command prompt on alt f7 4x Windows or GUI you know the time in this case that the process is taken on the CPU and the command that’s running so in this case it’s the bourne-again shell.
- Type in PS and we may know that pull up a man page or even if we put in bad syntax like a couple of asterisks it’ll give us a list of switches and things.
- We could do PS with the F option it just gives us a little bit more info.
- Again if we just go through this first part the user ID who’s running the process this is the pid the process ID and later when we couple this with the kill command we’ll need to know the pid for any process to be able to kill it or to send it to the background sometimes depends on what you will do with that the ppid is the parent process ID what happens is in the Bourne shell the bourne-again shell in this case bash.
- Whenever you launch a process or a program it basically goes into a wait state and creates another shell and that show will turn around and launch that program and then when it’s done that shell as you know the child shell has its own built-in kill command kills itself and then it goes back to the parent or the parent process ID and the weight function is then complete and then the parent process ID will kind of give the cursor or the console back.
- Snapshot has user ID in this case, the process ID, the parent process ID ppid the next option is the amount of CPU utilization in this case it’s negligible what’s being used at time at the time it started ,TTY,TIME is the you know in this case the time that the processes have taken up on the CPU which again it’s negligible and then following the command itself so just the bourne-again shell and the process command right now um not counting background demons and things that are written in the background.
- Here we wanted to display all processes and Daemons then F would be processes so that might be a useful come in there if you’re looking for a particular process.
- If we want to list more information we can do PSL which will give me even more information on a process.
- If we do that then this first column here the F stands for a flag and in this case if it’s four then that’s the root user in this case is then the next one here s is the process state and there are several states possible that is S for sleeping R for running Z for a zombie state in a zombie state the process is waiting for the parents who release it T that process could be stopped or it could be being traced by another process or W the process has no contents and memory so several different options there under state the UID 1000 again and the group of the user running the process, PPID is the process ID C is still the CPU utilization PR is the process priority so sort of the level of niceness that it’s running under now in the UNIX or Linux world the lower you know the priority that the higher the priority in other words.
- So in other words zero as the highest and 127 would be the lowest in terms of priority the nice value and if that’s zero then they both have you know what the default nice value whatever they were launched under but if that were negative twenty you know the lower the number it has a much greater chance of gaining a higher priority and I say chance it’s not guaranteed but in a time slicing fashion as it shares CPU cycles with other demons and processes.
- If that were nice the negative twenty would have a higher priority on the other hand if that were a positive 19 it would have a much lower chance of getting a high priority all right so the priority itself is different from the actual nice value which you know it is related to or does affect the priority and again we’ll take a look at that in greater detail in a moment we’re just going through the basics of the process commit right now um.
- Let’s look at the next field the address is the memory address of the process okay and then the next field is the size of the process of memory WCHAN is what the process is waiting for while sleeping again the TTY to terminal and time is the time the process has taken on the CPU and command is the individual command process.
This is a guide to PS command in Linux. We have seen how we can see process and it information using PS command. Here we discuss the introduction, options available for PS command, and examples. You may also have a look at the following articles to learn more –