How To Check How Many Users Are Created In Linux

How to check how many users are created in Linux. Here is an easy way to check current user in Linux and check user details in Linux.

Check user details in Linux

You can check user details in Linux using who command. ‘who’ prints information about users who are currently logged on. If you want to see who is currently logged in, use who command.

When no command option is given, ‘who’ prints the following information for each user currently logged on:

  1. login name
  2. terminal line
  3. login time
  4. remote hostname or X display

How to use who command?

You can use the following who commands to get the list of users on your system:

who | wc -l
who | cut -d "" -f 1
who | cut -d "" -f 1 | sort -u

Here the ‘cut’ command is used to write to standard output selected parts of each line of each
input file, or standard input if no files are given or for a file name of ‘-’.

In simple words you can use the cut command to exclude all information except for the user name.

If you want to sort the names alphabetically, you can use the following command (also listed above):

who | cut -d "" -f 1 | sort -u

And if you wish to count the number of unique users, add wc -l at the end of the command as shown below:

who | cut -d "" -f 1 | sort -u | wc -l

Get a List of All Users

If you want to get a list of all users you can use the command /etc/passwd file. Note that when you get the result, each line represents login information for one user.

Original Article