LinuxQuestions.org
Help answer threads with 0 replies.
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 04-18-2010, 12:00 PM   #16
toothpick
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Rep: Reputation: 0
Alternative.....


How about just "less /etc/passwd"?
 
Old 10-13-2010, 10:14 AM   #17
anthalamus
LQ Newbie
 
Registered: Sep 2010
Posts: 4

Rep: Reputation: 0
if someone's looking at this thread for an answer to a good way to reverse look up user per UID, I like:
Code:
getent passwd | awk -F: '$3=='$SOME_USER_ID'{print $1}'
more reliable than using /etc/passwd, especially when user dirs are mounted from elsewhere
hope it helps someone
 
Old 10-22-2013, 12:00 PM   #18
pburwell
LQ Newbie
 
Registered: Jun 2010
Location: PA, USA | NJ, USA
Distribution: CentOS 6
Posts: 19

Rep: Reputation: 0
Wink List Users in RHEL6.x

Quote:
Originally Posted by neo_in_matrix View Post
There are useradd/userdel, but I could not find the command to list users. Plase help.
I know this an OLD question but RedHat STILL has not found an easy way to do this.
SO, make an executable file in /bin with this:

cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1

I used nano and made getusers with 0777 permissions

Last edited by pburwell; 10-22-2013 at 12:01 PM. Reason: - to add last line
 
Old 10-23-2013, 05:28 AM   #19
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Actually that only gets users (actually uids/gids) from 500-999; its perfectly normal to have much higher numbers and (as mentioned above), some systems start the non-priv uids at 1000 ...

Here's a 'std' anomaly
Code:
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
 
Old 10-23-2013, 07:13 AM   #20
GNU/Linux
Member
 
Registered: Sep 2012
Distribution: Slackware-14
Posts: 78

Rep: Reputation: Disabled
First look in /etc/login.defs which contains the minimum & max UID for (normal) users
Code:
$ grep "^UID_MIN" /etc/login.defs
$ grep "^UID_MAX" /etc/login.defs
 
Old 10-23-2013, 09:10 AM   #21
OldSASguy
LQ Newbie
 
Registered: Oct 2013
Location: Columbus, OH
Posts: 4

Rep: Reputation: Disabled
While I am dazzled by the display of programming expertise evidenced in all the replies to this post, I cannot for the life of me understand what is wrong with just using the users command. It gives a non-cluttered view of the actual people (not system, etc.) who are logged on to the box. Sometimes things just get a little too complicated to be of any use. Just MHO.
 
Old 10-23-2013, 03:16 PM   #22
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 1,978

Rep: Reputation: 512Reputation: 512Reputation: 512Reputation: 512Reputation: 512Reputation: 512
Mostly because it doesn't answer the question.

The "users" command only lists those who are logged in. Not all users.

If you want to know all the local users, look in the /etc/passwd file.

HOWEVER, that will not necessarily list all the users. IF you are using NIS then you must also use ypcat passwd.

And even then, that isn't necessarily all the users...

If you are using kerberos, you won't know. The users are authenticated via remote connection to the key distribution server, and you normally will not be able to list those users.

If you are using LDAP, you have yet another place to look... ldapsearch...

How to list users depends on your environment.
 
1 members found this post helpful.
Old 10-23-2013, 03:22 PM   #23
OldSASguy
LQ Newbie
 
Registered: Oct 2013
Location: Columbus, OH
Posts: 4

Rep: Reputation: Disabled
well, jollard, if you're gonna get picky!! You're right of course - there is a difference between "users" and "active users". My bad!
 
Old 02-12-2014, 10:04 PM   #24
dchawk
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Rep: Reputation: Disabled
How would you utilize trap to display a list of logged on users each time you log out?
 
Old 02-12-2014, 10:43 PM   #25
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 1,978

Rep: Reputation: 512Reputation: 512Reputation: 512Reputation: 512Reputation: 512Reputation: 512
Quote:
Originally Posted by dchawk View Post
How would you utilize trap to display a list of logged on users each time you log out?
Depends on the definition of logout...

You can use "trap who exit" in the ~/.bash_login. Then, when that login shell exits you will get the output of "who" (which lists the current logged in users). If you don't want to know how many times they are logged in ... then you can do:

Code:
...
# luu is "list unique users"
function luu {
    who | awk '{print $1}' | sort -u
}
trap luu exit
...
 
  


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 10:06 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