Linux commands to print the number of users & number of processes!!?

M

m7com

Guest
Hello
How R U every one ??
i have a small Q about two Commands >> Are There a command for :
Print out the number of all running processes on the system

And
Are There a command for :
Print out the number of all users defined on the system

i just need this two commands please if it exist.
i need it in bash shell .. Linux operating system

Thank you very much,, happy to become a member in this great forum .
 


You can make a user counter by:
Count the number of lines in the /etc/passwd file
First you would need to read the file into a variable by using:
Code:
export users=`cat /etc/passwd`
Then just count the lines:
Code:
export num=`echo "$users" | wc -l`
Then the number is stored in a nice little variable called num. To call it use $num.
As for the processes, use
Code:
export running=`ps -ef|wc -l`
Then use $running to get the number
 
Total number of users or number of currently logged in users?
If you want the total users bashcommando's should help, if you need the current logged in try the "who" command.
 

Members online


Top