LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 09-26-2005, 09:27 AM   #1
neo_in_matrix
Member
 
Registered: Sep 2003
Posts: 52

Rep: Reputation: 15
What is the command to list users?


There are useradd/userdel, but I could not find the command to list users. Plase help.
 
Old 09-26-2005, 09:44 AM   #2
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
cat /etc/passwd
 
Old 09-26-2005, 09:44 AM   #3
visaris
Member
 
Registered: Dec 2004
Distribution: gentoo
Posts: 190

Rep: Reputation: 30
I'm not sure about a command but you could look in the /etc/passwd file.

"cat /etc/passwd"
should (on most systems) give you a list of all the users on the system. Keep in mind that some special users may be listed here along with the regular ones.
 
Old 09-26-2005, 09:02 PM   #4
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Try this...

cat /etc/passwd |grep 500*


It will list all lines from /etc/passwd which corresponds to USERs on your box. So from there you can check out the characters before first ":" sign will be the login name for your all users.

Reason---> It will list all the users with UID 500 or above... & the result would be the list of your normal users.

Start using grep... & be more creative. It will help.


Do feedback.
 
Old 09-26-2005, 09:51 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
I'd be more inclined to look for users with a home directory....
Code:
cat /etc/passwd | grep /home | cut -d: -f1
 
Old 09-26-2005, 10:28 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally posted by amitsharma_26
cat /etc/passwd |grep 500*
...
It will list all the users with UID 500 or above.
That's not entirely true. That grep pattern will match 50, 500-509, 5000-5099, etc. It won't list users with ID's of 510-4999. Also, different distributions use different starting points for beginning UIDs. 500 is pretty common, but I've seen some that start at 1000. A slightly improved version of the command above would be:
Code:
cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]"
That's not perfect, but it would list UIDs of 500-999. And it would prevent any matching of numbers in comment or GID fields.

Then it could be combined with homey's suggestion for something like this:
Code:
 cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1
But now it's getting to be a pretty long command, and not the easiest to remember. Alias time

Last edited by Dark_Helmet; 09-26-2005 at 10:32 PM.
 
Old 09-27-2005, 12:49 AM   #7
Vgui
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware
Posts: 496

Rep: Reputation: 31
Also, as a slightly related aside, the "who" command will tell you who is currently logged onto the system.
 
Old 09-27-2005, 02:14 AM   #8
harisund
Member
 
Registered: Sep 2005
Location: Baton Rouge
Distribution: Ubuntu 5.10
Posts: 74

Rep: Reputation: 15
who & finger too !
 
Old 09-27-2005, 09:54 AM   #9
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally posted by Vgui
Also, as a slightly related aside, the "who" command will tell you who is currently logged onto the system.
That will be done by

users

also.

But it wont list any samba users logged in.
 
Old 02-17-2009, 06:29 AM   #10
Tomas Tyser
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
ls /home
 
Old 02-20-2009, 10:19 AM   #11
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
Might try:
Code:
 net rap user
Seems to give a pretty comprehensive list
 
Old 02-26-2009, 07:10 PM   #12
enthus
LQ Newbie
 
Registered: Sep 2007
Distribution: opensuse
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by Tomas Tyser View Post
ls /home
genius!!!

my command:

cat /etc/passwd | gawk 'FS=":" {print $1}'
 
Old 02-26-2009, 07:38 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,988
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally Posted by Dark_Helmet View Post
Then it could be combined with homey's suggestion for something like this:
Code:
 cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1
But now it's getting to be a pretty long command, and not the easiest to remember. Alias time
Code:
awk -F: '$6 ~ /\/home/ && $3 >= 500 {print $1}' /etc/passwd

And a note to most people in this thread:

If you find yourself using 'cat' with only one parameter you're
not making good/sensible use of it 99.9% of the time.

Last edited by Tinkster; 02-26-2009 at 07:48 PM.
 
Old 02-26-2009, 11:59 PM   #14
palisetty_suman
Member
 
Registered: Feb 2007
Location: TX, USA
Distribution: fedora
Posts: 191

Rep: Reputation: 33
Thumbs up Hi

Hi,

I guess the command

cat /etc/passwd

is correct and simpler to use. All The Best.
 
Old 11-04-2009, 02:02 AM   #15
anirudhm
LQ Newbie
 
Registered: Nov 2009
Posts: 2
Blog Entries: 1

Rep: Reputation: 0
Thumbs up My Command is :

gawk -F: '{ print $1 }' /etc/passwd
 
  


Reply


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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Command to run another command against a list of files psweetma Linux - General 3 11-09-2005 05:29 PM
command to list all users of the system?? simi_544 Linux - Networking 9 09-29-2005 03:00 AM
List all users, command amer_58 Linux - Newbie 6 03-25-2005 06:07 AM
How to get list of system users from command line? tictocdoc Linux - General 3 03-12-2004 03:06 PM


All times are GMT -5. The time now is 12:13 PM.

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