LinuxQuestions.org
Help answer threads with 0 replies.
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 08-02-2011, 03:07 AM   #1
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Rep: Reputation: Disabled
how to list user using bash


hellow,
can anybody tell me how to list existing users using bash
 
Old 08-02-2011, 03:14 AM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
check /etc/passwd
 
Old 08-02-2011, 03:23 AM   #3
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Original Poster
Rep: Reputation: Disabled
thank-x kirukan
 
Old 08-02-2011, 03:30 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
Have a look
http://www.linuxquestions.org/linux/...all_your_USERs
 
Old 08-02-2011, 06:06 AM   #5
nkd
Member
 
Registered: Oct 2006
Location: india
Distribution: fedora 8, ubuntu 10.10
Posts: 315

Rep: Reputation: 34
hi
open a terminal and enter the following :-
Quote:
cat /etc/passwd | cut -d: -f1
The /etc/passwd file stores the hashed passwords for all the users in the system. and the cut command will give the first field and that is the username from each line of the passwd file.

that should give you the list of all users in the system

hope that helps
nishith
 
Old 08-02-2011, 07:27 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
@nkd: in modern *nix, passwords are stored in /etc/shadow, not /etc/passwd.
 
Old 08-03-2011, 06:04 AM   #7
nkd
Member
 
Registered: Oct 2006
Location: india
Distribution: fedora 8, ubuntu 10.10
Posts: 315

Rep: Reputation: 34
but I have an Maverick meerkat distro (Ubunut) and it has both the /etc/passwd and /etc/shadow files.
Any idea why have the passwd file if it is no longer needed ? Backward compatibility ?

thanks
nishith
 
Old 08-03-2011, 08:26 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Exactly; way back when, there was only /etc/passwd, but in order for users to be able to edit their settings, it was world readable, NOT a good thing.
Later on, it was decided to create /etc/shadow and put the actual passwd (and add aging info) into /etc/shadow.
The passwd cmd runs as root, using suid bit.
So, (on the solaris box in front of me) we have

Code:
-rw-r--r--   1 root     sys         1466 Jul 12 09:51 /etc/passwd
-r--------   1 root     sys          765 Jul 12 09:51 /etc/shadow

-r-sr-sr-x   1 root     sys        27220 Jan 23  2005 /usr/bin/passwd
Check your system, should look very similar.
 
1 members found this post helpful.
Old 08-08-2011, 12:21 PM   #9
nkd
Member
 
Registered: Oct 2006
Location: india
Distribution: fedora 8, ubuntu 10.10
Posts: 315

Rep: Reputation: 34
Thanks,
I also have the same output and it cleared up the issue.
bye
nishith
 
  


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
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 02:14 PM
[SOLVED] Partial list with ls-l in bash script run in cron but full list run from command line redgshost Linux - General 29 01-16-2011 01:14 PM
print user list, showing a locked user account?? royal024 Linux - Newbie 4 10-18-2008 11:57 AM
super user privileges check for a normal user in bash script freeindy Programming 2 08-01-2008 07:08 AM
PHP List /home/'user' then finger 'user' Caboose Programming 1 09-22-2004 05:12 AM


All times are GMT -5. The time now is 05:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration