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

Discussion in 'Command Line' started by m7com, Apr 30, 2014.

  1. m7com

    m7com New Member

    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    1
    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 .


    bashcommando likes this.
  2. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    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
  3. Jeremy

    Jeremy Member

    Messages:
    34
    Likes Received:
    18
    Trophy Points:
    8
    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.
    bashcommando likes this.
  4. GrumpyOldMan

    GrumpyOldMan Active Member

    Messages:
    133
    Likes Received:
    43
    Trophy Points:
    28
    Doing homework are you?
  5. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    I live on the computer. I am on it from 6-12 hours a day. LOL

Share This Page