How to know how many users are added to your system account ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • redcodeheaven
    New Member
    • Nov 2008
    • 13

    How to know how many users are added to your system account ?

    Hi everybody,I would like to know what the commands given to the terminal that will let you know how many users are allready in your system account,I am using Ubuntu,thanks for anybody help.
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    OK, I'm guessing you're using bash as your standard shell and nobody has changed it. In that case, this should show you the registered human users:
    Code:
    cat /etc/passwd | grep /bin/bash | cut -d: -f1
    If you just want the number of users, use
    Code:
    cat /etc/passwd | grep -c /bin/bash
    instead.

    If you don't know if any of your users have changed their shell, you can also try this:
    Code:
    cat /etc/passwd | grep /home | cut -d: -f1
    which will list all users who have a home directory in /home/. This can be changed too, but it's the standard. Again, you can count them by using
    Code:
    cat /etc/passwd | grep -c /home
    If you want to list all users, no matter if human or not,
    Code:
    cat /etc/passwd | cut -d: -f1
    will do the job. However, as there are quite a few users created for system processes, this list will be long. Again,
    Code:
    cat /etc/passwd | grep -c :
    only gives you the amount of users.

    Greetings,
    Nepomuk

    Comment

    Working...