Ps ef grep command in unix11/11/2023 ![]() Here is an example of finding all forked apache processes. Www-data 4527 2359 0 10:03 ? 00:00:00 \_ /usr/sbin/apache2 -k startĭisplay child processes of a parent process The following command will search for processes by the name apache2 and construct a tree and display detailed information. The '-forest' option will construct an ascii art style tree view of the process hierarchy. Many processes are actually forked out of some parent process, and knowing this parent child relationship is often helpful. Display process hierarchy in a tree style USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND $ ps aux -sort=-pcpu,+pmemĭisplay the top 5 processes consuming most of the cpu. Check the man page for the complete list. There are lots of parameters on which the process list can be sorted. Additionally the fields can be prefixed with a "-" or "+" symbol indicating descending or ascending sort respectively. Multiple fields can be specified with the "-sort" option separated by a comma. The sort option will sort the process list based on a particular field or parameter. ![]() System administrators often want to find out processes that are consuming lots of memory or CPU. To search the process list more flexibly, the usual grep command has to be used $ ps -ef | grep apache 4. The "-C" must be provided with the exact process name and it cannot actually search with a partial name or wildcard. To display processes by process id, use the "-p" option and provides the process ids separated by comma. To search the processes by their name or command use the "-C" option followed by the search term. Multiple usernames can be provided separated by a comma. To filter the processes by the owning user use the "-u" option followed by the username. $ ps -ef -f Why is the USER column not displaying my username, but showing others like root, www-data etc ?įor all usernames (including yours) if the length is greater than 8 characters then ps will fall back to show only the UID instead of username. Use the "u" option or "-f" option to display detailed information about the processes $ ps aux Pipe the output to "less" to make it scrollable. The following command will give a full list of processes $ ps ax For example "ps ax -f".īut in this post we shall mostly focus on the unix style syntax. ps -ef It is okay to mix both the syntax styles on linux systems. UNIX/LINUX style - The options in linux style syntax are preceded by a dash as usual. But "u" means show detailed information.īSD style - The options in bsd style syntax are not preceded with a dash. For example "-u" is used to show process of that user. ![]() Note : "ps aux" is not the same as "ps -aux". So here is some basic info to get it clear before moving on. New users are often confused with and mis-interpret the two styles. The ps command comes with an unusual set of 2 syntax styles. In this post we are going to revise the basics of using the ps command to check the processes and filter and sort them in different ways to suit better. Even though it has fewer features, it is still an essential process management and monitoring tool that every linux user should know about. It does not display data in real time like top or htop commands. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |