LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 11-06-2005, 04:53 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
HowTo list all users in system


Hi guys ....I want to ask you if you have a command that allows me to list all users in the linux system Iam using....?
 
Old 11-06-2005, 05:00 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
cat /etc/password shows you all existing users.
w shows you all active.
 
Old 11-06-2005, 05:18 AM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Thank you for the help ... I will check it as soon as I get to my linux box
 
Old 11-06-2005, 02:21 PM   #4
amer_58
Member
 
Registered: Mar 2004
Distribution: Slackware 10.2
Posts: 213

Rep: Reputation: 30
cat /etc/passwd | cut -d ":" -f1
 
Old 11-06-2005, 03:30 PM   #5
pritchardtom
Member
 
Registered: Oct 2005
Location: Swansea, UK
Distribution: Slackware // Mandriva
Posts: 32

Rep: Reputation: 15
I think there is a "users" command as well that you can use if your using Linux on a network, such as a University server to see all who are currently connected.

man users for more information
 
Old 11-07-2005, 02:26 AM   #6
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
In /etc/passwd Ive got the following user....
The user name is ali
what is x?
what is 1001:1001
what do the 3 commas represent?
where is the group ?
where is the description ?

ali:x:1001:1001:,,,:/home/ali:/bin/bash


Last edited by ALInux; 11-07-2005 at 02:30 AM.
 
Old 11-07-2005, 02:28 AM   #7
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
And to amer_58 could you explain more how your command did what it did ?
 
Old 11-07-2005, 03:28 AM   #8
kbflamelet
LQ Newbie
 
Registered: Nov 2005
Posts: 7

Rep: Reputation: 0
amer_58's command printed the first column of /etc/passwd to the screen. -f1 denotes the column; -d ":" denotes the seperator.

x is where the password goes, but the passwords are stored in a seperate file, /etc/shadow, to improve security.

1001:1001 is your user and group, respectively (correct me if I'm wrong).

I think ,,, is "full name", but I'm not too sure.


I hope this was helpful.
 
Old 11-07-2005, 04:24 AM   #9
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
That was surely helpfull but I need one more thing please

Lets say I want to extract a column that contains only the userid what should I add to the "cat" command ?
 
Old 11-08-2005, 12:24 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
man cat, man cut or
cat /etc/passwd|cut -d':' -f3
 
Old 11-08-2005, 04:29 AM   #11
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Thank you guys for the support ......... just one more question I read man cat and man cut...........but I wana know if there is a method to extract only the uid of one user.........( I want to know if it can be done this way) lets say how to extract the ID of user root using cat and cut ( I know that it is 0)

Last edited by ALInux; 11-08-2005 at 04:35 AM.
 
Old 11-10-2005, 04:14 AM   #12
kbflamelet
LQ Newbie
 
Registered: Nov 2005
Posts: 7

Rep: Reputation: 0
This should do the trick for root: cat /etc/passwd | cut -d':' -f3 | head -n 1

If you want to do it for any user, then I'm afraid I can't help.
 
Old 11-10-2005, 06:09 AM   #13
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
I know how to do that.............. I want to display all users
 
Old 11-10-2005, 11:23 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
My suggestion does list all user ids... what are you after exactly??
If you want to find the uid for a specific user, eg fred, specify the username like this:
cat /etc/passwd|grep fred|cut -d':' -f3
 
Old 11-11-2005, 02:42 AM   #15
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
What i mean is only those users that I created i.e. uid > 500

Actually, Chris you told me exactly what I wanted to know in the begining but now I do not want to display the users like root etc ........anymore

Last edited by ALInux; 11-11-2005 at 02:45 AM.
 
  


Reply



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
HowTo List Newly Installed Program GNewbie MEPIS 2 11-23-2005 02:55 PM
command to list all users of the system?? simi_544 Linux - Networking 9 09-29-2005 03:00 AM
HowTo add specific location into sources.list? Mathsniper Debian 1 08-28-2005 04:21 AM
Howto list last changed files MicroSun Linux - Newbie 3 02-18-2005 05:52 PM
How to get list of system users from command line? tictocdoc Linux - General 3 03-12-2004 03:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:31 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration