LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   List of All user accounts from command line (https://www.linuxquestions.org/questions/linux-general-1/list-of-all-user-accounts-from-command-line-461267/)

sniff 07-05-2006 02:31 PM

List of All user accounts from command line
 
Hello,
Is there a way of listing all the users of a system from the command line? I cannot find anything that will list users even if they are not logged in, I would like to sort them by uid and stuff if possible. The particular server is running FC5 but it would be good if it was general.

Cheers,
Phil

acid_kewpie 07-05-2006 02:33 PM

cat /etc/passwd
or
getent passwd

sniff 07-09-2006 04:11 AM

Hello,
Thank you, just what I needed.

Cheers,
Phil

jschiwal 07-09-2006 04:29 AM

The /etc/passwd file will also contain system users. You could filter out the users how don't have a home directory.

sudo cat /etc/passwd | grep '/home'

hepburnenthorpe 07-09-2006 11:02 AM

You could then trim this down even further to only recieve each username instead of the whole line.
Code:

sudo cat /etc/passwd | grep '/home' | cut -d : -f 1


All times are GMT -5. The time now is 08:37 PM.