Alternative.....
How about just "less /etc/passwd"?
|
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}' hope it helps someone |
List Users in RHEL6.x
Quote:
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 |
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 |
First look in /etc/login.defs which contains the minimum & max UID for (normal) users
Code:
$ grep "^UID_MIN" /etc/login.defs |
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.
|
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. |
well, jollard, if you're gonna get picky!! You're right of course - there is a difference between "users" and "active users". My bad!
|
How would you utilize trap to display a list of logged on users each time you log out?
|
Quote:
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:
... |
Easy Command
Compgen - u
|
Code:
getent passwd Cut the login-ID (field#1) with Code:
getent passwd | cut -d: -f1 Code:
getent passwd | awk -F: '{print $1}' Code:
getent passwd | awk -F: '$3>=500 {print $1}' |
Seems like this is very old post. Mods, please mark it as solved/closed.
|
All times are GMT -5. The time now is 06:07 AM. |