SlideShare a Scribd company logo
1 of 1
Download to read offline
Create a bash script named ‘most_proc.sh’. This script should show the top 10 users according to
the number of processes they are running. It should show the process count and the user name.
The output of the script should look something like this, depending on which users are active.
$ ./most_proc.sh
157 root
12 apache
11 brun1992
4 bb
2 postfix
2 hart4492
2 68
1 USER
1 sshd
1 rpcuser
I don’t care about the order of users with the same number of processes.
Some hints: 1) you will probably want to use ‘ps’ with certain options to see all processes of all
users. 2) if you use “awk ‘{print $2}’ “ you will get the second column of text. 3) don’t forget
some of the text processing commands we covered in lecture this week.
Solution
most_proc.sh:
$> ps hax -o user |sort | uniq -c | sort -n -r | head -n 10
In above script,
ps - Lists processes
h in hax will remove header
-o prints only user column
sort will sort in alphabetically
uniq -c - counts each occurence for particular user and displays count of all occurences instead of
separately dipalying each occurence
sort -n -r - prints the output in descending order by listing users with maximum number of
processes first
head -n -10 will print only top 10 users

More Related Content

Similar to Top 10 Users by Process Count with most_proc.sh Script

8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
Using R on High Performance Computers
Using R on High Performance ComputersUsing R on High Performance Computers
Using R on High Performance ComputersDave Hiltbrand
 
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL DevroomFlame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL DevroomValeriy Kravchuk
 
Linuxppt
LinuxpptLinuxppt
LinuxpptReka
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0venkatakrishnan k
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.pptGowthamRaju15
 
BACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxBACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxwilcockiris
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Dmitry Ponomarenko
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02duquoi
 

Similar to Top 10 Users by Process Count with most_proc.sh Script (20)

Linux
LinuxLinux
Linux
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
 
Licão 05 scripts exemple
Licão 05 scripts exempleLicão 05 scripts exemple
Licão 05 scripts exemple
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
Using R on High Performance Computers
Using R on High Performance ComputersUsing R on High Performance Computers
Using R on High Performance Computers
 
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL DevroomFlame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
 
Powershell notes
Powershell notesPowershell notes
Powershell notes
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0Power point on linux commands,appache,php,mysql,html,css,web 2.0
Power point on linux commands,appache,php,mysql,html,css,web 2.0
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
BACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxBACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docx
 
unix-OS-Lab-4.doc
unix-OS-Lab-4.docunix-OS-Lab-4.doc
unix-OS-Lab-4.doc
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
 
Licão 14 debug script
Licão 14 debug scriptLicão 14 debug script
Licão 14 debug script
 

More from fatoryoutlets

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdffatoryoutlets
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdffatoryoutlets
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdffatoryoutlets
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdffatoryoutlets
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdffatoryoutlets
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdffatoryoutlets
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdffatoryoutlets
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdffatoryoutlets
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdffatoryoutlets
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdffatoryoutlets
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdffatoryoutlets
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdffatoryoutlets
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdffatoryoutlets
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdffatoryoutlets
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdffatoryoutlets
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdffatoryoutlets
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdffatoryoutlets
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdffatoryoutlets
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdffatoryoutlets
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdffatoryoutlets
 

More from fatoryoutlets (20)

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdf
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdf
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdf
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdf
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdf
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdf
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdf
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdf
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Top 10 Users by Process Count with most_proc.sh Script

  • 1. Create a bash script named ‘most_proc.sh’. This script should show the top 10 users according to the number of processes they are running. It should show the process count and the user name. The output of the script should look something like this, depending on which users are active. $ ./most_proc.sh 157 root 12 apache 11 brun1992 4 bb 2 postfix 2 hart4492 2 68 1 USER 1 sshd 1 rpcuser I don’t care about the order of users with the same number of processes. Some hints: 1) you will probably want to use ‘ps’ with certain options to see all processes of all users. 2) if you use “awk ‘{print $2}’ “ you will get the second column of text. 3) don’t forget some of the text processing commands we covered in lecture this week. Solution most_proc.sh: $> ps hax -o user |sort | uniq -c | sort -n -r | head -n 10 In above script, ps - Lists processes h in hax will remove header -o prints only user column sort will sort in alphabetically uniq -c - counts each occurence for particular user and displays count of all occurences instead of separately dipalying each occurence sort -n -r - prints the output in descending order by listing users with maximum number of processes first head -n -10 will print only top 10 users