Connecting Tech Pros Worldwide Help | Site Map

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

Newbie
 
Join Date: Nov 2008
Posts: 8
#1: Nov 18 '08
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's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#2: Nov 19 '08

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


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:
Expand|Select|Wrap|Line Numbers
  1. cat /etc/passwd | grep /bin/bash | cut -d: -f1
If you just want the number of users, use
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. cat /etc/passwd | grep -c /home
If you want to list all users, no matter if human or not,
Expand|Select|Wrap|Line Numbers
  1. 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,
Expand|Select|Wrap|Line Numbers
  1. cat /etc/passwd | grep -c :
only gives you the amount of users.

Greetings,
Nepomuk
Reply