While you probably know how to log into your Linux system with a single user account and you’re familiar with the root account, you more than likely don’t have a simple utility for viewing all of the accounts currently on your system. Fortunately, a single command line hack is all that you’ll need to bring the whole list up. This of course means that you’ll need to get a command line going first.
Push either Super+T or Ctrl+Alt+T to start up a graphical one. You might also want to search for the word Terminal on the Ubuntu Unity Dash or find the program under System Tools and utilities under the KDE Applications menu or the Xfce4 Whisker menu. Depending on the distribution you’re using, you probably won’t need any special privileges to run this command. Most modern distributions will assign at least some administrator tasks to the first user, but you can always add sudo to these commands if need be.
Method 1: Getting a List of All Linux Users
You should be able to view a list of all users by typing the following at the command prompt getent passwd | cut -d’:’ -f1 | less yet since this is so long you might want to copy and paste it from this Web resource. If that’s the case, then make sure to click on the Edit menu in your terminal emulator and then click Paste. You might also want to use Shift+Ctrl+V to paste, but keep in mind that Ctrl+V doesn’t paste in most terminal emulators since this has a different function at the command line.
This command should output a long line that you can browse through either with the cursor keys or by using the J key and K key to scroll up and down. Type q to exit. If this is your first time looking at all the users on your system, then you’ll more than likely be surprised. Don’t worry because your system hasn’t been compromised at all. General purpose GNU/Linux distributions have many user accounts set for running different processes as something other than root. Your actual user name on a single-user system can more than likely be found close to the bottom.
Some of these names might be recognizable to you as the names of different programs running in the background. These accounts were probably installed when the packages for those programs came about.
Method 2: Find the Number of Users
Since this list is probably rather long and ungainly, you’ll need to use the wc or word count utility to find the exact number of user accounts configured on your system. At the prompt type or copy getent passwd | wc -l then push enter. You won’t need to use a pipe to a program like more or less because this will surely be only a few digits.
On the sample Xubuntu test system we used to make the screenshots there were no less than 38 user accounts even though a single actual real user account is the only way to log into that machine. This is due to the fact that this program counts the pseudo-accounts created by those packages. Fortunately, there’s a way to restrict yourself to counting only the real ones.
If you’d like to actually see who is logged into the machine, then type users and push enter. Most people using a Debian-based distribution by themselves will find that they have only their account plus root. Server systems and multi-user configurations running something like CentOS or Red Hat Enterprise Linux might find that there are many more accounts logged in at the same time unless they’re using virtual machines to keep the count down. Note that users logged into virtual machines running on bare metal will only appear as logged in from their own environments.
A bit more information can be derived by running the command who with no arguments at all. You’ll find which terminals each of the users are logged into. Remember that tty7 is the graphical X or Wayland server you’re working with if you have Unity or GNOME installed. That explains why your user account might actually still show you logged in somewhere even if you’re only using a standard desktop. Actually, due to some Unix historical curiosities and the way that Unix systems manage user devices, you’ll see this even if you’re on something with a touchscreen.