Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-02-2006, 10:58 AM   #1
Registered: Apr 2006
Location: Singapore
Distribution: RHEL4,FC4,FC5
Posts: 89

Rep: Reputation: 15
how to list all users in shell?

i can do a system-config-users but this will open a gui.

any other command?

Old 05-02-2006, 11:33 AM   #2
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
ls /home or awk -F: '{ print $1 }' /etc/passwd

Or if you want to only get usernames that are actual users (i.e. leave out system made users like nobody, root, ftp, etc), try this:
awk -F: '$3 >= 1000 && $3 < 10000 { print $3 " " $1 }' /etc/passwd
Note that you'll probably have to modify the number range. In my system, UID's start at 1000 for normal users. $1 corresponds to the column of /etc/passwd containing usernames, $3 is the UID column. Once you figure out the range you need, you can remove the $3 " " section of the print statement.
Old 05-02-2006, 11:40 AM   #3
Senior Member
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
# awk -F: '{if (($3>=500)&&($3<=60000)) print $1}' /etc/passwd
500 is the minimum UID in your system.
60000 is the maximum UID. Check the MINUID and MAXUID for your system at /etc/login.defs.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
List of users nickyboy Linux - Newbie 1 04-20-2006 01:15 PM
list of users Ab3n Linux - Newbie 3 03-08-2006 12:30 PM
list out the users. bruse Linux - Newbie 2 07-19-2005 08:46 AM
List all users eam Linux - Newbie 7 05-15-2005 11:55 PM
[Samba] how to list users yan1 Linux - Networking 2 04-04-2005 07:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration