LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 11-20-2005, 12:07 AM   #16
whiteshark
LQ Newbie
 
Registered: Sep 2004
Location: Dhaka, Bangladesh.
Posts: 3

Rep: Reputation: 0

Greetings,
In regards to this question, I'm curious about something.
cat /etc/passwd |grep "/bin/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1
This would list all users who are added to the system...How to modify it to make it look like it's an entry of /etc/aliases ? I mean how to add the results in the format of this, "allusers: user1, user2, user3, user4" ? Can anyone help?
 
Old 11-20-2005, 12:13 AM   #17
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by ALInux
What i mean is only those users that I created i.e. uid > 500

Actually, Chris you told me exactly what I wanted to know in the begining but now I do not want to display the users like root etc ........anymore
awk -F: '$3 > 500 {print $1}' /etc/passwd


Cheers,
Tink

Last edited by Tinkster; 11-20-2005 at 12:15 AM.
 
Old 11-20-2005, 12:20 AM   #18
whiteshark
LQ Newbie
 
Registered: Sep 2004
Location: Dhaka, Bangladesh.
Posts: 3

Rep: Reputation: 0
Quote:
Originally posted by Tinkster
awk -F: '$3 > 500 {print $1}' /etc/passwd


Cheers,
Tink
Well mine does the listing properly and more accurately,

The outputs are as follows:

[root@dns root]# awk -F: '$3 > 500 {print $1}' /etc/passwd
nfsnobody
shark


[root@dns root]# cat /etc/passwd |grep "/bin/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1
rony
shark
[root@ronydns root]#


The last output shows the real users who were added using adduser. I just wanna furnish it to add it to /etc/aliases so that sending email to one alias sends mail to everyone.
 
Old 11-20-2005, 01:58 AM   #19
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
On my system I get all users with IDs greater 500 with both
methods ... no idea how you have set-up your passwd file,
and why the shell should make a difference.

That aside: if you take your method to a distro where new users
start with 1000 you won't get any sensible output.

If the shell was important it could easily be added to the awk.

Lastly: my method is more elegant ;}


Cheers,
Tink
 
Old 11-22-2005, 12:06 AM   #20
whiteshark
LQ Newbie
 
Registered: Sep 2004
Location: Dhaka, Bangladesh.
Posts: 3

Rep: Reputation: 0
Another question I would like ask is that is it possible to add several users by reading from a text file ? As for example, there are 20 users listed in the file users.txt. If they're to be added in the system using the useradd command, is it possible to do so using useradd, like the example u stated lists all users having UID > 500 in one single line? Thanks in advance.
 
Old 11-22-2005, 12:56 AM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
man newusers

Not quite in a single line, but in a file with single lines :}


Cheers,
Tink
 
Old 11-22-2005, 05:00 PM   #22
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Good advice tinkster..........
 
Old 11-23-2005, 03:50 AM   #23
prabuayyappan
Member
 
Registered: Sep 2005
Location: Coimbatore
Distribution: Prabuayyappan
Posts: 32

Rep: Reputation: 15
This will print the user with user id greater than 500

cat /etc/passwd | awk -F ":" '{if($3>500){ print $1}}'
 
Old 04-12-2018, 11:54 AM   #24
dbwillia
LQ Newbie
 
Registered: Apr 2018
Posts: 2

Rep: Reputation: Disabled
How to list all userids and the attributes in the security registry

I realize there have been no post in over 6 months, but none of the previous replies provide what I'm looking for.

Is there a single command or one liner that I could use on a Red Hat system to list all userids that can potentially access the system?

On AIX I can issue the command lsuser -R files ALL to list every userid and the attributes contained in the local security registry (i.e., the various /etc/* security files). For example:
====================================================================================================
> lsuser -R files ALL
root id=0 pgrp=system groups=system,bin,sys,security,cron,audit,lp home=/ shell=/usr/bin/ksh auditclasses=general login=true su=true rlogin=true daemon=true admin=true sugroups=ALL admgroups= tpath=nosak ttys=ALL expires=0 auth1=SYSTEM auth2=NONE umask=22 registry=files SYSTEM=compat logintimes= loginretries=0 pwdwarntime=10 account_locked=false minage=0 maxage=0 maxexpired=-1 minalpha=0 minother=0 mindiff=0 maxrepeats=0 minlen=0 histexpire=0 histsize=0 pwdchecks= dictionlist= default_roles= fsize=-1 cpu=-1 data=-1 stack=-1 core=-1 rss=-1 nofiles=2000 time_last_login=1523384199 time_last_unsuccessful_login=1517419013 tty_last_login=/dev/pts/0 tty_last_unsuccessful_login=ssh host_last_login=prodigal1.unch.unc.edu host_last_unsuccessful_login=uncpmp.hprhs.com unsuccessful_login_count=0 roles=
daemon id=1 pgrp=staff groups=staff home=/etc login=true su=true rlogin=true daemon=true admin=true sugroups=ALL admgroups= tpath=nosak ttys=ALL expires=0101000070 auth1=SYSTEM auth2=NONE umask=22 registry=files SYSTEM=compat logintimes= loginretries=0 pwdwarntime=10 account_locked=false minage=0 maxage=13 maxexpired=-1 minalpha=2 minother=2 mindiff=0 maxrepeats=2 minlen=8 histexpire=26 histsize=0 pwdchecks= dictionlist= default_roles= fsize=2097151 cpu=-1 data=262144 stack=65536 core=2097151 rss=65536 nofiles=2000 roles=
bin id=2 pgrp=bin groups=bin,sys,adm home=/bin login=true su=true rlogin=true daemon=true admin=true sugroups=ALL admgroups= tpath=nosak ttys=ALL expires=0101000070 auth1=SYSTEM auth2=NONE umask=22 registry=files SYSTEM=compat logintimes= loginretries=0 pwdwarntime=10 account_locked=false minage=0 maxage=13 maxexpired=-1 minalpha=2 minother=2 mindiff=0 maxrepeats=2 minlen=8 histexpire=26 histsize=0 pwdchecks= dictionlist= default_roles= fsize=2097151 cpu=-1 data=262144 stack=65536 core=2097151 rss=65536 nofiles=2000 roles=
<snip>
====================================================================================================

lsuser -R LDAP ALL would list all userids from the LDAP security registry.
lsuser ALL would list all userids from both the local ("files") and LDAP security registries (plus any other security registries defined to the system).

Thanks.
 
Old 04-15-2018, 02:30 PM   #25
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,809

Rep: Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209
Over 6 months? Over 6 years would be closer.
To list all users known by the system try
Code:
getent passwd
 
Old 04-16-2018, 03:45 PM   #26
dbwillia
LQ Newbie
 
Registered: Apr 2018
Posts: 2

Rep: Reputation: Disabled
Thanks.
I'll look into the getent command. Hopefully it has an option to retrieve security information from multiple security files like the AIX lsuser command.
 
Old 04-17-2018, 02:03 AM   #27
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,162

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Never used and never heard Getent, this wiki link below shows how useful the command is.

https://en.wikipedia.org/wiki/Getent

Example from link above:

Quote:
$ getent passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
Quote:
$ getent passwd joe
joe:x:1000:1000:Joe,,,:/home/joe:/bin/bash
Quote:
$ getent group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:stefan
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
 
Old 04-17-2018, 02:59 AM   #28
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,809

Rep: Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209Reputation: 1209
You must use more commands to get additional information. For example:
Code:
getent passwd | cut -f1 -d: | xargs groups
(Works fine with the Linux/BSD groups command. The SysV groups command is a little different.)
 
1 members found this post helpful.
  


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 Newly Installed Program GNewbie MEPIS 2 11-23-2005 02:55 PM
command to list all users of the system?? simi_544 Linux - Networking 9 09-29-2005 03:00 AM
HowTo add specific location into sources.list? Mathsniper Debian 1 08-28-2005 04:21 AM
Howto list last changed files MicroSun Linux - Newbie 3 02-18-2005 05:52 PM
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 - Newbie

All times are GMT -5. The time now is 07:14 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