Insight: Tutorial to list all users in Ubuntu via command line.
In this article, we will show you the process or method to list all users in Ubuntu via command line. Easiest way to list all users in Ubuntu is by using cat command:
$ cat /etc/passwd
List of all users in ubuntu reside in /etc/passwd, so we can view by looking up at this file. One of the problem is that this file also contains other fields and accounts details so we need to filter it out.
So, let’s slightly dig further to list all users by the command mentioned below:
We’ll start by
cat /etc/passwd | grep "/home"
( All the users created will have their home directories here )
cat /etc/passwd | grep "/home" |cut -d: -f1
cat /etc/passwd |grep "/home" |cut -d: -f1
Note: This commands work until your users have their home directories in /home folder. Meanwhile for different destination. Let’s go through the command below:
cat /etc/passwd |grep "/bin/bash" |cut -d: f1
This tutorial is intended for the beginner level of Linux users. Let us know if there is anything wrong in this article, we would love to update it. If you like this article, please don’t forget to share it.