Basically, grep, which stands for ‘global regular expression print’ looks up a specific file for lines which contain a match to some given strings or words or even regular expressions and outputs the corresponding line. It is one of the most invoked utilities on Linux or Unix. Simply put, grep is a powerful pattern based tool used to search text within files. To show the processes of a specific user, you need to use the -U flag which was not giving me appropriate results when paired with the -ef flag.īut still, it is one of the best implementations of the ps command which is why I'm including this in the bonus section.In this article you will learn how to use the grep command on Linux along with simple examples to help you find a string or pattern within a given file. There's a reason why I'm adding this in the bonus section. ![]() To sort the processes based on CPU utilization, you can use the -sort=-%cpu flag as shown here: ps -ef -sort=-%cpu Bonus: Show processes of a specific user To sort the shown processes based on the memory usage, you can use the -sort=-%mem flag as shown: ps -ef -sort=-%mem 5. To tackle this situation, you can use the ww option as shown: ps -efww 4. When you use the ps -ef command, it will cut the execution command (shown in the CMD column) if not enough space is available. In that case, you can use the grep command to sort output: ps -ef | grep "process_name"įor example, if I want to look for if there's any process related to nano, then I will be using the following command: ps -ef | grep "nano" 3. When you execute the ps -ef command, it shows you a bunch of processes and you may want to scroll multiple times to find that suspicious process causing issues. When you pair the -forest flag with the ps -ef command, it can be used to display process tree in Linux: ps -ef -forest 2. In this section, I will walk you through multiple practical ways to use the ps -ef command by which you can get the most out of it. Now, let's have a look at different examples of using the ps -ef command. ![]() CMD: Shows the command that initiated that process.TIME: Tells you for how long that process utilized your CPU.TTY: Terminal associated with that process and if it is not associated with a terminal then it will indicate ? or - mark.STIME: Time when the process was started.This means it will show the process ID of the parent process. PID: Indicates the process ID of that process.UID: Shows the user ID of the process owner.Now, let's break down the output you get when you use the ps -ef command. In simple terms, when you use the ps -ef command, it will list every ongoing process of the system and will give you additional details for every process. -f: Gives you additional details for the selected processes like UID, PID, PPID, etc.-e: Selects all the processes of the system.Now, let's have a look at the meaning of the -ef flag. But that's not what we always want as users may have multiple terminals opened with different ongoing processes.Īnd here's where the use of the -ef flag comes in!īefore I jump to the explanation part of the -ef flag, let's have a look at what output you'd get when you execute the ps command with the -ef flag: ps -efĮven if you don't know the meaning of output (which I'm about to explain in a minute), you can tell that it gives you more data than the ps command without any flags. When you execute the ps command without any additional flags, it will list down the active processes attached to the current terminal session: psĪs you can see, it listed two processes that were attached to the terminal. Let's start with the execution of the ps -ef command. So in this tutorial, first, I will explain the output of the ps -ef command and then will add more examples to get more out of the ps -ef command. ![]() The ps command in Linux is used to get a report of the current processes of your system.īut when you pair the ps command with the -ef flag, it gives you a detailed and comprehensive overview of all processes running on your system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |