Which option is used by ps command to get a detailed listing of process attributes?
Solved MCQs of Process Status:ps Command and Phases of a Process. The output of the given command will be? MCQ Answer: b To run the new program we use
___________ system call. MCQ Answer: a By fork, the system call which value is returned. When the child process creation is unsuccessful? MCQ Answer: c For displaying processes of a user, which of the following option is used by the system
administrator? MCQ Answer: a Some attributes of a process are shown by which command? MCQ Answer: d By ps command, which attribute is not shown? MCQ Answer: b To wait for the
child process to complete the parent process use ________ system call? MCQ Answer: d For creating a new process Which system call is used? MCQ Answer: d New PID is got from the child process that is created When the fork() is invoked. MCQ Answer: a For getting the detailed listing of process attributes, which of the following option is used by ps command? MCQ Answer: c The distinct phases of the process are ____. MCQ Answer: a Requests for the service from the kernel of an operating
system the programmatic way is a system call. MCQ Answer: b When the -a option used with ps command it lists the processes of all users but this doesn’t display the system processes. MCQ Answer: b To list the system processes, which of the following option is used with ps command? Next Operating System MCQs
ps (processes status) is a native Unix/Linux utility for viewing information concerning a selection of running processes on a system: it reads this information from the virtual files in the /proc filesystem. It is one of the important utilities for system administration specifically under process monitoring, to help you understand whats is going on in a Linux system. It has numerous options for manipulating its output, however, you’ll find a small number of them practically useful for daily usage. Read Also: All You Need To Know About Processes in Linux [Comprehensive Guide] In this article, we’ll look at 30 useful examples of ps commands for monitoring active running processes on a Linux system. Note that ps produces output with a heading line, which represents the meaning of each column of information, you can find the meaning of all the labels on the ps man page. List All Processes in Current Shell1. If you run the ps command without any arguments, it displays processes for the current shell. $ ps Print All Processes in Different Formats2. Display every active process on a Linux system in generic (Unix/Linux) format. $ ps -A OR $ ps -e 3. Display all processes in BSD format. $ ps au OR $ ps axu 4. To perform a
full-format listing, add the $ ps -ef OR $ ps -eF Display User Running Processes5. You can select all processes owned by you (runner of the ps command, root in this case), type: $ ps -x 6. To display a user’s processes by real user ID (RUID) or name, use the $ ps -fU tecmint OR $ ps -fu 1000 7. To select a user’s
processes by effective user ID (EUID) or name, use the $ ps -fu tecmint OR $ ps -fu 1000 Print All Processes Running as Root (Real and Effective ID)8. The command below enables you to view every process running with root user privileges (real & effective ID) in user format. $ ps -U root -u root Display Group Processes9. If you want to list all processes owned by a certain group (real group ID (RGID) or name), type. $ ps -fG apache OR $ ps -fG 48 10. To list all processes owned by effective group name (or session), type. $ ps -fg apache Display Processes by PID and PPID11. You can list processes by PID as follows. $ ps -fp 1178 12. To select process by PPID, type. $ ps -f --ppid 1154 13. Make a selection using a PID list. $ ps -fp 2226,1154,1146 Display Processes by TTY14. To select processes by tty, use the -t flag as follows. $ ps -t pts/0 $ ps -t pts/1 $ ps -ft tty1 Print Process Tree15. A process tree shows how processes on the system are linked to each other; processes whose parents have been killed are adopted by the init (or systemd). $ ps -e --forest 16. You can also print a process tree for a given process like this. $ ps -f --forest -C sshd OR $ ps -ef --forest | grep -v grep | grep sshd Print Process Threads17. To print all threads of a process, use the $ ps -fL -C httpd Specify Custom Output FormatUsing the -o or –format options, ps allows you to build user-defined output formats as shown below. 18. To list all format specifiers, include the $ ps L 19. The command below allows you to view the PID, PPID, user name, and command of a process. $ ps -eo pid,ppid,user,cmd 20. Below is another example of a custom output format showing file system group, nice value, start time, and elapsed time of a process. $ ps -p 1154 -o pid,ppid,fgroup,ni,lstart,etime 21. To find a process name using its PID. $ ps -p 1154 -o comm= Display Parent and Child Processes22. To select a specific process by its name, use the -C flag, this will also display all its child processes. $ ps -C sshd 23. Find all PIDs of all instances of a process, useful when writing scripts that need to read PIDs from an std output or file. $ ps -C httpd -o pid= 24. Check the execution time of a process. $ ps -eo comm,etime,user | grep httpd The output below shows the HTTPD service has been running for 1 hour, 48 minutes, and 17 seconds. Troubleshoot Linux System PerformanceIf your system isn’t working as it should be, for instance, if it’s unusually slow, you can perform some system troubleshooting as follows. 26. Find top running processes by highest memory and CPU usage in Linux. $ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head OR $ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head 27. To kill Linux processes/unresponsive applications or any process that is consuming high CPU time. First, find the PID of the unresponsive process or application. $ ps -A | grep -i stress Then use the kill command to terminate it immediately. $ kill -9 2583 2584 Print Security Information28. Show security context (specifically for SELinux) like this. $ ps -eM OR $ ps --context 29. You can also display security information in a user-defined format with this command. $ ps -eo euser,ruser,suser,fuser,f,comm,label Perform Real-time Process Monitoring Using Watch Utility30. Finally, since ps displays static information, you can employ the watch utility to perform real-time process monitoring with repetitive output, displayed after every second as in the command below (specify a custom ps command to achieve your objective). $ watch -n 1 'ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head' Important: ps only shows static information, to view frequently updated output you can use tools such as htop; top, and glances: the last two are in fact Linux system performance monitoring tools. You might also like to read the following related articles.
That’s all for now. If you have any useful ps command example(s) to share (not forgetting to explain what it does), use the comment form below. Which option to the ps command will display detailed information about the processes?The -e option instructs ps to display all processes. The -f stands full-format listing, which provides detailed information about the processes.
Which attribute of ps is used to view the process of a specific user?The -g, -G, -p, -s, -t, -u, and -U options can be used to select specific processes by process ID, terminal ID, and user name. The -f, -j, and -l options can be used to display additional status fields using predefined formats.
Which option can be added to the ps command to show the processes of other users?How to list process with the ps command. A : Select all processes.. u : Select all processes on a terminal, including those of other users.. x : Select processes without controlling ttys.. Which command can be used to list all processes on the system?Use the ps command to list all the processes on a system.
|