Linux top human readable

Linux top command, top command in Linux/UNIX.

Top command in Linux and Unix is used to display the Linux Process. The Linux top command program provides a dynamic real-time view of a running system. Also, display the system summary information as well as a list of processes or threads currently being managed by the Linux kernel.

So we will discuss the top command in detail if you want to learn about the output of the top command explained refer the link.

Linux top command run once. Syntax: # top -n [iteration] Command: # top -n 1
Linux top command sort by Memory/Memory Usage. Syntax: # top -o [Field] Command: # top -o %MEM # On top Screen "press Shift + m" or "press M"
Linux top command sort by CPU/CPU Usage. Syntax: # top -o [Field] Command: # top -o %CPU # On top Screen "press Shift + p" or " press P"
Linux top command sort by user. Syntax: # top -o [Field] Command: # top -o USER # On top Screen "press shift + r"
Linux top command sort by TIME. Syntax: # top -o [Field] Command: # top -o TIME # On top Screen "press Shift + t" or "press T"
Linux top command sort by process id/PID. Syntax: # top -o [Field] Command: # top -o PID # On top Screen "press Shift + n" or "press N"
top command monitors the specific process or PID. Syntax: # top -p[pid1,pid2. pidN] Command: # top -p1,2,3,4,5,7,8,9,10
Linux top command filter by Process ID. Command: # On top Screen STEP 1: "pressing shift + o" and get the prompt add filter #1 (case sensitive) as: [!]FLD?VAL PID STEP 2: "Press Enter"
Linux top command filter by Name. Command: # On top Screen STEP 1: "pressing shift + o" and get the prompt add filter #1 (case sensitive) as: [!]FLD?VAL USER=tla STEP 2: "Press Enter"
Linux top command filter by Process name. Command: # On top Screen STEP 1: "pressing shift + o" and get the prompt add filter #1 (case sensitive) as: [!]FLD?VAL COMMAND=nginx STEP 2: "Press Enter"
Linux top command delay time/ run top command every 5 minutes. Syntax: # top -d [delay time] Command: # top -d 300 # On top Screen  STEP 1: "press d" and the prompt will be "Change delay from 3.0 to"300 STEP 2: "press Enter"
Linux top command show memory in GB. Syntax: # top -E [k | m | g | t | p | e] Command: # top -E g # On top Screen "press e"
Linux top command thread view. Command: # top -H
Linux top highlight process. Command: # On top Screen "press z"
Linux top process tree. Command: # On top Screen "press V" or "press Shift + v"
Linux top command full absolute path. Command: # top -c # On top Screen "press c"
Kill the process using top command. Command: # On top Screen STEP 1: "press k" it will prompt like "PID to signal/kill [default pid = 1234]": "Enter the PID" and "press enter" STEP 2: Again it will prompt to "Send PID 1225 signal [15/sigterm]": "press enter to kill".
Linux top command graphical mode. Command: # On top Screen For CPU "press t". For Memory "press m".
top command Add fields/Add column. Command: # On top Screen STEP 1: "pressing f" or "Shift +F" STEP 2: "press SPACE" to select the fields. STEP 3: "Press q" and check in the top Screen
top command running tasks/Active Process. Command: # On top Screen "press i"
top 10 process/limit rows top command output. Command: # On top Screen STEP 1: "press n" it will prompt "Maximum tasks = 0, change to (0 is unlimited)"10 STEP 2: After putting 10 "press Enter"

Linux/UNIX top command run once

If we want to run the top command once we will use -n option with the command.

So, this will run the top command only once and make the exit, what if want to run the command 10 times and then exit.

So this will perform 10 iterations with the top command by using -n option.

Linux/UNIX top command sort by memory, user, CPU, memory usage, CPU usage, process id, PID, TIME.

— top command sort by Memory/Memory Usage.

So, we will sort the process by Memory or by Memory Usage, so there are many options to do the sorting.

So here we have used -o option with the top command for the sorting of Memory by using %MEM.

Also, we can “press Shift + m” or “press M” to sort by Memory or Memory usage in top command.

— top command sort by CPU/CPU Usage.

For sorting by CPU we will use -o option with %CPU , also we can check the usage of CPU

Also, we can “press Shift + p” or ” press P” to sort the top command by CPU or CPU usage.

— top command sort by User.

To sort User by top command use -o option with USER field , let’s look at the command below.

we can also use “press shift + r” or “press R” to check the user or any field in reverse order.

— top command sort by time.

So now we will sort the time with the top command by using -o option.

When you are on the top screen then you can “press Shift + t” or “press T” with that you can sort by time.

— top command sort by Process id/PID.

Process id and the PID are the same, so with the top command, we will use -o option and PID as an argument.

So you can also check on the top screen by “pressing Shift + n” or “Press N” this will sort by process id.

Top command monitor specific process or PID.

So we have to monitor the process id 1, 2, 3, 5, 7, 8, 9, and 10 here we will use -p option.

So this will monitor only the specific process id with -p option

To monitor a specific user we will use grep command refer to link to learn about grep command

So tla is the user which we have grep from the top command and it will show the process of tla user.

top command filter by user, process name, Process ID, USER.

So to filter the user, process name, ID, and CPU on the top screen , we will “press shift + o” or “press O” .

— top command filter by Process ID.

So after “pressing shift + o” you will get the prompt “add filter #1 (case sensitive) as: [!]FLD?VAL”

The FLD is the field name and VAL is the value , let’s see the example.

add filter #1 (case sensitive) as: [!]FLD?VAL PID

So, this will show the PID which will be less than 10 , you can “use =(equal), or >(greater than)” with the PID.

So we got the PID which is less than 10 , now we will see a specific User by “pressing shift + o”.

— top command filter by Name.

add filter #1 (case sensitive) as: [!]FLD?VAL USER=tla

So USER is our field and tla is the user that we have to filter out.

you can also use -u option with top command to filter the specific User .

By using this command we can see the running process of mysql User.

— top command filter by Process name.

Suppose the Nginx process is running on the server and we have to monitor Nginx Process only.

add filter #1 (case sensitive) as: [!]FLD?VAL COMMAND=nginx

So, we have filtered by Process Name and the COMMAND is the field on the top screen.

Linux/UNIX top command delay time/ run top command every 5 minutes.

The top command delay time is the time when it refresh the top screen.

So we will use -d option or we will simply “press d” on the top screen to set the delay time in top command.

So -d option will refresh the top screen by 2 seconds , let’s see the option by “pressing d” on the top screen.

Hereby default the screen refresh interval at every 3 seconds by “pressing d” it will prompt “Change delay from 3.0 to” , So we have to display in every 1 second.

So we have put 1 on the top screen then the refresh interval of the top screen will at every 1 second.

Now we will have to run the top command every 5 minutes , so as we know it takes the input in seconds.

So, for 5 minutes we will use 300 seconds, let’s see with the command.

"press d" and the prompt will be "Change delay from 3.0 to" 300

Linux/UNIX top command show memory in GB.

So here there are two options use -E option which is Extended Memory Scaling , it will show the RAM size in Human readable format.

Other option by “pressing e” on the top screen, let’s see the commands.

So this will show the RAM size in GB , as below screenshot.

Let’s “press e” option inside the top screen for the Extended Memory Scaling.

Linux/UNIX top command thread view.

So if we have to display the individual threads use -H option with top command.

So in the place of “Tasks” it will display the “Threads” on the top screen.

There are total number of threads are 407 and 1 running threads.

Linux/UNIX top highlight process.

So, to highlight the running process in top command we will “press z” on the top screen.

Linux/UNIX top process tree.

So to view the sub process of the processes known as “Forest View Mode”.

We have to “press V” or “press Shift + v” to view the subprocess in the COMMAND field.

Linux/UNIX top command full absolute path.

So to check the full absolute path “press c on the top screen, or use the option -c.

So by using -c or by “pressing c” we can see the full path of the process.

kill the process using top command.

So to kill the process by using top command “press k” and it will prompt like “PID to signal/kill [default pid = 1234]”.

Then “Enter the PID” and “press enter” , so it will prompt “Send PID 1225 signal [15/sigterm]” then press enter to kill.

So it will send the process termination signal to the kernel and that will terminate the process.

So to see the CPU and Memory in graphical mode “press t” and “press m” .

You can see the BAR instead of TEXT in the Memory and CPU.

top command Add fields/Add column.

So in the top command, you can Mange the fields by “pressing f” or “Shift +F” on the top screen.

Now we will select PPID and UID fields from the filed Management Window and use s to sort the fields.

So here we will sort by %CPU and we press SPACE to select the PPID and UID fields.

Now we will press q command and check the top screen with the two field.

top command running tasks/Active Process.

So to check the Active process with top command, “press i(small i)” to check the running task.

top 10 process/limit rows top command output.

If we want to see the top 12 processes “press n” it will prompt like “Maximum tasks = 0, change to (0 is unlimited)” then just put 12 as we want to see the top 12 processes.

So, after “pressing Enter” can see the top 12 processes running on the top command screen.

Now suppose we want to see the top 10 processes than “press n” it will prompt like “Maximum tasks = 0, change to (0 is unlimited)” and write 10 and “press Enter” .

So it will display the top 10 Process in the top command. The same steps to be followed to limit the row in top command.

The Top command output explained into another post please refer the POST to learn detail about the TOP command.

Источник

How to have linux top command show memory summary in megabytes not kilobytes

Redhat EL5 I had my top configured the just the way I like showing the memory summary and swap summary in MB. I had to close my shell and then when I re-opened it, it is back showing in (default ?) kilobytes. I have scoured google, and top help and man the page. I can not seem to find the display in MB option. Although, I did find many other somewhat strange options. If anyone knows I sure would be grateful. Thanks!

Are you sure it was TOP and not a clone with more options ? there is nothing on TOP’s man page saying anything about it being able to display the data in human-readable form.

I am sure it was top. The standard top that comes with Redhat Enterprise Linux 5. procps version 3.2.7

6 Answers 6

I know I’m veeery late on this but I guess you used:

from the tom man page on RHEL 5:

-M : Detect memory units Show memory units (k/M/G) and display floating point values in the memory summary. 

On linux you can use e key to change task memory scale, ranging from bytes to petabytes. When you have selected what you like, press W ( shift + w ) to save changes to ~/.toprc .

Typing capital ‘E’ cycles through KiB, MiB, GiB, TiB, PiB and EiB.

Let me amplify and study bindbn‘s response above. The source to top in the procps package, lines 3131 and 3134, show that the output will go through the scale_num() function defined on line 761. What I read in the scale_num() function says that it will favor precision over beauty. If the available real-estate only allows for human-readable, then so be it, but its default is to show it in KB.

So, what I think happened is that you saw a few processes with MB in their memory consumption (resident or shared) and tricked yourself when you opened it back up. Either that, or you were using a different tool.

If you are satisfied that somehow, you got twisted around, then please mark a reply as The Answer so that this question can come off the Unanswered list. Thanks.

Just to convince yourself, get the source RPM to the package and see if they applied any patches to it. You would probably have to install the SRPM and look at the spec file to get the name of any patch files they used. Learn how to build an RPM (a handy skill) and go look at the patched source of top.c, if it has been patched at all. Compare the tree with the link I provided above and see if there is a difference. Note that going through this may not be trivial.

Источник

Читайте также:  Red hat enterprise linux scientific linux полное руководство пользователя
Оцените статью
Adblock
detector