command to list all users of the system??
can anyone tell a command to list all the users of a system...........................
to be specific, not the users that are currently logged in, i want a command that lists all the users which have been created(including that ones created by softwares or OS itself) and i do know that it can be found by /etc/passwd...but i want a command............. PLZ HELP>>> |
Use this
[root@host root]# lastlog Thanks, Rinish (rinishriju) |
On my system, lastlog doesn't list all users, but only a subset.
Why do you want a command? What's wrong with Code:
cat /etc/passwd Kees-Jan |
cat /etc/passwd doesnt list your ldap users (ie: users at your domain controler) --> kees-jan
/ Rinish (rinishriju) |
If your system is configured to use winbind to authenticate against AD controllers, then the following commands can be useful:
wbinfo -u wbinfo -g -or- getent passwd getent group If you have applications specifically using LDAP, then the only command I'm aware of is "ldapsearch" |
the command worked
thaks rinish for ur help
|
So how do you see list of users.....
Any guesses.. (I'll tell you & make it short & simple...) As we all know the user list reside in /etc/passwd, so we can view the registered user by looking up at this file. But now the fuss is that it also contains many other fields & machine trust accounts & inbuilt accounts. So now we'll make a command of our own.. We'll start by 1.cat /etc/passwd 2.As we all know that by default all the users created will have their home directories in /home share so we'll modify our command a bit by using grep. Now it'll be cat /etc/passwd | grep "/home" 3. Now we'll get all the user accounts which have their home share in /home. But the only output we need is the list of users & nothing else. 4. So we'll modify our command again cat /etc/passwd | grep "/home" |cut -d: -f1 Now what we have done is that we have piped the output of previous command to another variable "cut" What we have done here is we have added cut -d: -f1 -d: means delimite : -f1 means display first field of line i.e. username. So final command is Cat /etc/passwd |grep "/home" |cut -d: -f1 This works until all your users have their home share in /home. If you have defined their home share to some other destination. Modify the above command. (Hint : In previous case we started grep "/home" , this time we'll use grep "/bin/bash" or whtever valid shell you are using) Now command will be like.. Cat /etc/passwd |grep "/bin/bash" |cut -d: f1 But this will also result some inbuilt user account. To avoid that.. we'll now pipe the output to another variable… as we know that UID starts from 500 & above.. So our new command would be: Cat /etc/passwd |grep "/bin/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1 ---------------- Now as we are finished with desired results… its time to create an ALIAS for the above commands Alias userlist='cat /etc/passwd |grep "/bin/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1' Its all done. ---------------- Type userlist at your prompt & you'll get the list of users. If you have a very large nos of users like at lalbaug & qutab centers, then you can further pipe the output of userlist command. Userlist |grep "admin" It will only list usernames with admin in it. (can be modified to fit your needs) |
This command is not going to help you if you are using SSO or even an ldap/nis authentication. because centralised users will not show up at /etc/passwd file.
/ Rinish (rinishriju) |
Quote:
In case of LDAP/NIS... this procedure is not going to work. |
is there any other command that lists all the nis/ldap users?
/ Rinish (rinishriju) |
All times are GMT -5. The time now is 07:31 PM. |