What is the command to list users?
There are useradd/userdel, but I could not find the command to list users. Plase help.
|
cat /etc/passwd
|
I'm not sure about a command but you could look in the /etc/passwd file.
"cat /etc/passwd" should (on most systems) give you a list of all the users on the system. Keep in mind that some special users may be listed here along with the regular ones. |
Try this...
cat /etc/passwd |grep 500*
It will list all lines from /etc/passwd which corresponds to USERs on your box. So from there you can check out the characters before first ":" sign will be the login name for your all users. Reason---> It will list all the users with UID 500 or above... & the result would be the list of your normal users. Start using grep... & be more creative. It will help. Do feedback. |
I'd be more inclined to look for users with a home directory....
Code:
cat /etc/passwd | grep /home | cut -d: -f1 |
Quote:
Code:
cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" Then it could be combined with homey's suggestion for something like this: Code:
cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1 |
Also, as a slightly related aside, the "who" command will tell you who is currently logged onto the system.
|
who & finger too !
|
Quote:
users also. But it wont list any samba users logged in. |
ls /home
|
Might try:
Code:
net rap user |
Quote:
my command: cat /etc/passwd | gawk 'FS=":" {print $1}' |
Quote:
Code:
awk -F: '$6 ~ /\/home/ && $3 >= 500 {print $1}' /etc/passwd And a note to most people in this thread: If you find yourself using 'cat' with only one parameter you're not making good/sensible use of it 99.9% of the time. |
Hi
Hi,
I guess the command cat /etc/passwd is correct and simpler to use. All The Best. |
My Command is :
gawk -F: '{ print $1 }' /etc/passwd
|
All times are GMT -5. The time now is 09:45 AM. |