In daily operations, it is often time to look at the number of processes that occupy the current system CPU or memory usage. These view commands are listed below:
See the 5 most CPU-intensive processes
PS aux | Sort-k3rn | Head-5
Or
Top (then press p, note uppercase, CPU usage descending)
View the top 5 processes that occupy memory
PS aux | SORT-K4RN | Head-5
Or
Top (then press m, note uppercase, memory utilization descending)
View all information using commands
PS aux
Sort-rn Descending
Sort-k3rn in descending order of the third column
Sort|uniq sort to go heavy
Sort|uniq-c Number of print repetitions
sort|uniq-d part of the print intersection
Sort|uniq-u Print the part that removes the intersection
Example:
[email protected] ~]# Cat A
Sdfasasdf
2
3
4
asdfasf
Asdfsdfasdfasdf
[email protected] ~]# Cat B
adfasf1231
2
3
sdf435
4
[Email protected] ~]# cat a B|sort|uniq
2
3
4
adfasf1231
asdfasf
Asdfsdfasdfasdf
sdf435
Sdfasasdf
[Email protected] ~]# cat a b|sort|uniq-c
2 2
2 3
2 4
1 adfasf1231
1 asdfasf
1 ASDFSDFASDFASDF
1 sdf435
1 SDFASASDF
[Email protected] ~]# cat a b|sort|uniq-d
2
3
4
[Email protected] ~]# cat a b|sort|uniq-u
adfasf1231
asdfasf
Asdfsdfasdfasdf
sdf435
Sdfasasdf
View the top 10 processes for native CPU and memory utilization