LinuxQuestions.org
Visit Jeremy's Blog.
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, 01: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, 01:13 AM   #17
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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 01:15 AM.
 
Old 11-20-2005, 01: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, 02:58 AM   #19
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 01: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, 01:56 AM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
man newusers

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


Cheers,
Tink
 
Old 11-22-2005, 06: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: 670
Blog Entries: 7

Original Poster
Rep: Reputation: 31
Good advice tinkster..........
 
Old 11-23-2005, 04: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}}'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:55 PM
command to list all users of the system?? simi_544 Linux - Networking 9 09-29-2005 04:00 AM
HowTo add specific location into sources.list? Mathsniper Debian 1 08-28-2005 05:21 AM
Howto list last changed files MicroSun Linux - Newbie 3 02-18-2005 06:52 PM
How to get list of system users from command line? tictocdoc Linux - General 3 03-12-2004 04:06 PM


All times are GMT -5. The time now is 09:10 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration