LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-01-2005, 04:57 AM   #1
simi_544
LQ Newbie
 
Registered: Mar 2005
Posts: 4

Rep: Reputation: 0
Talking 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>>>
 
Old 09-01-2005, 05:12 AM   #2
Rinish
Member
 
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93

Rep: Reputation: 15
Use this

[root@host root]# lastlog

Thanks,
Rinish (rinishriju)
 
Old 09-01-2005, 05:18 AM   #3
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
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
Groetjes,

Kees-Jan
 
Old 09-01-2005, 05:30 AM   #4
Rinish
Member
 
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93

Rep: Reputation: 15
cat /etc/passwd doesnt list your ldap users (ie: users at your domain controler) --> kees-jan

/ Rinish (rinishriju)
 
Old 09-01-2005, 05:59 AM   #5
scowles
Member
 
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
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"
 
Old 09-02-2005, 03:38 AM   #6
simi_544
LQ Newbie
 
Registered: Mar 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Smile the command worked

thaks rinish for ur help
 
Old 09-27-2005, 01:23 PM   #7
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
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)
 
Old 09-29-2005, 02:35 AM   #8
Rinish
Member
 
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93

Rep: Reputation: 15
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)
 
Old 09-29-2005, 02:45 AM   #9
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
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 12:51 AM.
 
Old 09-29-2005, 03:00 AM   #10
Rinish
Member
 
Registered: Apr 2005
Location: Bangalore
Distribution: Redhat, CentOS, AIX
Posts: 93

Rep: Reputation: 15
is there any other command that lists all the nis/ldap users?

/ Rinish (rinishriju)
 
  


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 all users in system ALInux Linux - Newbie 27 04-17-2018 02:59 AM
What is the command to list users? neo_in_matrix Linux - Newbie 27 11-29-2017 06:09 AM
List all users, command amer_58 Linux - Newbie 6 03-25-2005 06:07 AM
Is there a command to list how many CPUs a system has? Locura Linux - General 2 02-25-2005 11:28 AM
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 - Networking

All times are GMT -5. The time now is 06:46 AM.

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