We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Solaris/SunOS - How to list user accounts

dholbanga
dholbanga asked
on
Medium Priority
6,544 Views
Last Modified: 2013-12-04
Hello

How do you list user accounts in Solaris (SunOS 5.2)?  I am looking everywhere but can't find it.  I would like to list the user accounts on the server and also see their rights (whether they are root or not).

Thanks,
D
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007
Commented:
users are listed in /etc/passwd file. The first field of each line is the user name. you may get names by running

awk -F: '{print $1}' /etc/passwd

users are grouped in groups and the fourth field in this file is the group id to which the user belongs

groups are defined in /etc/group file. this file shows the other groups to which the user belongs

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks!  I did that and got the following output:

$ awk -F: '{print $1}' /etc/passwd
root
daemon
bin
sys
adm
lp
uucp
nuucp
smmsp
listen
nobody
noaccess
nobody4
bb
webservd
test
guest

It doesn't tell me the rights of the accounts though.  It just lists the accounts.  Also, how do you disable or delete an account?
CERTIFIED EXPERT
Top Expert 2007
Commented:
only root (user id 0 , the 3rd field in /etc/passwd) is privileged as administrator. users are given permissions over files and directories based on their user ids and groups they belong to. What type of rights are you looking for?

to manage users you may use commands like:

useradd , usermod

http://docs.sun.com/app/docs/doc/806-4073/6jd67r94i?a=view
http://www.kobhi.com/solaris/user_management/solaris_user_management.htm
CERTIFIED EXPERT
Top Expert 2007
Commented:
please be careful while dealing with users and do not delete system users (those that come created with the system)

Author

Commented:
Thanks for your help Omar.  I'm trying to see which user has root privileges aside from the root user.  Then I want to lower their privileges if they don't need it.  What's the command for that? I know "usermod" will do it but I am new to this and need some direction.  

Thanks!
CERTIFIED EXPERT
Top Expert 2007
Commented:
if the user id is not 0 and not in group id 0 and he is not given rights to run commands as root (e.g. via sudo command, please see http://www.gratisoft.us/sudo/man/sudoers.html) then he is normal user on the system.

from the list of users you found, only bb , test, guest are the users on your system other than the ones that come with the system, hence if they are not given user id 0 and not in group id 0 then I think they are not privileged

Author

Commented:
That's very useful information.  I tried logging in to sudo for root and got the following error:

$ sudo -u root
sudo: not found

So there is something I'm not doing correctly.

Also, how do I check the user ID?  Is there a command for that?  
CERTIFIED EXPERT
Top Expert 2007
Commented:
use the command

id username

or look into the /etc/passwd file in the 3rd field, e.g.

omar1:x:2005:1::/export/home/omar1:/usr/bin/csh

here user id for omar1 is 2005 and he is in group id 1

Author

Commented:
This is what I get for using that command:

$ id username
id: invalid user name: "username"

So it didn't work :(
CERTIFIED EXPERT
Top Expert 2007
Commented:
put actual username e.g. bb

you could do the following also;

awk -F: '{print $1,"\t",$3}' /etc/passwd

Author

Commented:
Yes that worked!!  Thank you so much.  Also, how do you disable an account?  Say I want to disable a user named "guest" how would I do that?
CERTIFIED EXPERT
Top Expert 2007
Commented:
use

passwd -l guest

this will lock the account, please see:

http://docs.sun.com/app/docs/doc/816-5165/passwd-1?a=view
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.