LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Linux Answers > Networking
User Name
Password

Notices


By amitsharma_26 at 2005-09-28 16:29
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 delimiter :
-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 whatever 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

by linuxlinux on Tue, 2006-03-28 19:58
Well when I tried to execute this command this is the answer any idea why has this turned up

[root@unisa ~]# cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1
Harry
harry
steve
master
help
[root@unisa ~]# alias listuser=cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1
-bash: alias: /etc/passwd: not found
[root@unisa ~]#

by gilead on Tue, 2006-03-28 20:43
You need to wrap it in quotes the way they do in the article:
Code:
alias userlist='cat /etc/passwd |grep "/bin/bash" |grep "[5-9][0-9][0-9]" |cut -d: -f1'

by sysconfig on Mon, 2006-11-06 02:09
awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd

by hardened on Fri, 2008-01-11 13:38
Quote:
Originally Posted by sysconfig View Post
awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd
Wow! Awesome alternate method. Thx Sysconfig!
awk and gawk are really powerful, I need to spend some time studying them.

by eponcedeleonc on Mon, 2008-06-30 09:16
how do you list users and passwords? I need to do that.
Thank you

by salasi on Mon, 2008-06-30 15:30
Quote:
Originally Posted by eponcedeleonc View Post
how do you list users and passwords?
Hmm, so you want a potential security hole that allows any hacker who can get the root password (or even get briefly to a terminal in use by a root user) to get every login password on the system? Are you really sure that's a good idea?

PS: I wouldn't tell you even if I knew. Which I don't.

by win32sux on Tue, 2008-07-01 02:06
Quote:
Originally Posted by eponcedeleonc View Post
how do you list users and passwords? I need to do that.
Being able to list users' passwords would imply that the passwords are stored somewhere on the system, which is not the case. What is stored are salted hashes of the passwords. So unless you've changed something to the standard way GNU/Linux handles user passwords, you won't be able to get any password list.

by eponcedeleonc on Tue, 2008-07-01 12:07
well I have a user from another company that has access to the server and DB as root and due to company problems with their company we are going manage the server and DB and i need to know how to block him from having any access to the server and DB.. its just a precaution that needs to be considered, and i dunno if changing the root password would be enough!

by win32sux on Tue, 2008-07-01 18:25
Quote:
Originally Posted by eponcedeleonc View Post
well I have a user from another company that has access to the server and DB as root and due to company problems with their company we are going manage the server and DB and i need to know how to block him from having any access to the server and DB.. its just a precaution that needs to be considered, and i dunno if changing the root password would be enough!
Changing the root password might be enough if you had a way to be sure that he didn't install any sort of backdoor. And you don't have any way to be sure of that unless you did something like take a HIDS snapshot or something before you gave him root access. That said, I'm still not sure how this relates to getting a listing of users' passwords. I mean, you don't need to know that passwords in order to change them. And the guy with root could have easily installed a password sniffer to get everyone's passwords if he wanted them (since cracking the salted hashes would probably be infeasible for him).

by fatima74 on Mon, 2009-11-30 17:54
Quote:
Originally Posted by sysconfig View Post
awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd
Oh so KEWL, first time I am using awk THANK YOU =)

Did my own variation:
awk -F":" '{ print "Linux_name: " $1 "\t\tFull_Name: " $5 }' /etc/passwd


  



All times are GMT -5. The time now is 01:42 PM.

Main Menu
Advertisement
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