We'll start by
cat /etc/passwd
As we all know that by default all the users created will have their home directories in /home share so we'll modify our command a bit by using grep. Now it'll be
cat /etc/passwd | grep "/home"
Now we'll get all the user accounts which have their home share in /home.But the only output we need is the list of users & nothing else. So we'll modify our command again
cat /etc/passwd | grep "/home" |cut -d: -f1Now what we have done is that we have piped the output of previous command to another variable "cut"
What we have done here is we have added cut -d: -f1
-d: means delimiter :
-f1 means display first field of line i.e. username.
So final command is
cat /etc/passwd | grep "/home" |cut -d: -f1This works until all your users have their home share in /home. If you have defined their home share to some other destination. Modify the above command accordingly.