Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-01-2005, 05:57 AM
|
#1
|
LQ Newbie
Registered: Mar 2005
Posts: 4
Rep:
|
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>>>
|
|
|
09-01-2005, 06:12 AM
|
#2
|
Member
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93
Rep:
|
Use this
[root@host root]# lastlog
Thanks,
Rinish (rinishriju)
|
|
|
09-01-2005, 06:18 AM
|
#3
|
Member
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273
Rep:
|
On my system, lastlog doesn't list all users, but only a subset.
Why do you want a command? What's wrong with
Groetjes,
Kees-Jan
|
|
|
09-01-2005, 06:30 AM
|
#4
|
Member
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93
Rep:
|
cat /etc/passwd doesnt list your ldap users (ie: users at your domain controler) --> kees-jan
/ Rinish (rinishriju)
|
|
|
09-01-2005, 06:59 AM
|
#5
|
Member
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620
Rep:
|
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"
|
|
|
09-02-2005, 04:38 AM
|
#6
|
LQ Newbie
Registered: Mar 2005
Posts: 4
Original Poster
Rep:
|
the command worked
thaks rinish for ur help
|
|
|
09-27-2005, 02:23 PM
|
#7
|
Member
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777
Rep:
|
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)
|
|
|
09-29-2005, 03:35 AM
|
#8
|
Member
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93
Rep:
|
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)
|
|
|
09-29-2005, 03:45 AM
|
#9
|
Member
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777
Rep:
|
Quote:
Originally posted by Rinish
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)
|
I am taking the case we are using /etc/passwd.
In case of LDAP/NIS... this procedure is not going to work.
Last edited by amitsharma_26; 10-06-2005 at 01:51 AM.
|
|
|
09-29-2005, 04:00 AM
|
#10
|
Member
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93
Rep:
|
is there any other command that lists all the nis/ldap users?
/ Rinish (rinishriju)
|
|
|
All times are GMT -5. The time now is 02:25 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|