Solaris Interview Questions - User Management

The intent of this post is to help the person who is going to attend the basic level of the Solaris interview. A few of the User Admin’s related Question and Answers are given below, I hope this will help you to refresh your basic knowledge before attending the interview. Most of the time we very much strong in all components, however, a basic level of knowledge is one of our key points while attending the interview.

1. How to create a user? Brief with full syntax.

The syntax:

/usr/sbin/useradd -u uid -g gid -c " User Descriptions" -m -d "Home Directory Path" -s "Shell" username

Example :

# useradd -u 535 -g unix -c "GeekSearch blog" -m -d /export/home/geeksearch -s /usr/bin/bash geeksearch
Options Description
-u UID ( From 0 to 65535 ) , 0 is reserved for root
-g Primary Group
-m Force to Create Home Directory Specified by -d and copy default skeleton files in /etc/skel folder
-d User Home Directory Path
-c User Descriptions
-s Shell Path

2. What are the important files for User Management task?

Important User Management configuration file:

/etc/passwd
/etc/shadow
/etc/group
/etc/default/passwd
/etc/default/login

3. Describe the /etc/passwd fields?

/etc/passwd file is having 7 fields

username:password:uid:gid:comment:home-directory-path:login-shell

For example:

geeksearch:x:535:121:GeekSearch blog:/export/home/geeksearch:/usr/bin/bash

4. Describe the /etc/shadow file fields?

/etc/shadow file is having 9 fields

loginID:password:lastchg:min:max:warn:inactive:expire:reserved

For example:

geeksearch:R1EbI61VDyM2I:15995:7:91:7:::

5. Describe the /etc/group file fields?

/etc/group file is having 4 fields:

groupname:group-pwd:GID:user-list

For example:

geeksearch::121:geeksearch, admin

6. What is the different between “su UserID” and “su - UserID”?

su UserID” - Doesn’t check the PATH and Current Working Directory “su - UserID” - Load the User’s Profiles (PATH/Current Working Directory)

7. Default permission of Passwd/Shadow/Group files?

Default permissions for the Passwd/Shadow/Group files are as follows:

/etc/passwd 644
/etc/shadow 644
/etc/group    400
bash-3.00# ls -ld /etc/passwd /etc/shadow /etc/group
-rw-r--r--   1 root     sys          459 Dec 10 16:32 /etc/group
-rw-r--r--   1 root     sys        18498 Dec 11 09:09 /etc/passwd
-r--------   1 root     sys        10334 Dec 11 09:35 /etc/shadow
bash-3.00#

8. Default permission of file and Directory?

Default permission of file is 644 (666 - 022 (umask vaule)). Default permission of directory is 755 (777 -022 (umask vaule)).

9. How to view the list of users who currently logged in the system?

who” command will show the users who logged in the current system. The command refers /var/adm/utmpx to obtain the information.

bash-3.00# who
root       pts/2        Sep 10 22:11    (192.168.10.22)
root       pts/3        Dec 11 22:55    (192.168.10.22)
bash-3.00#
bash-3.00# ls -ld /var/adm/utmpx
-rw-r--r--   1 root     bin         2976 Dec 11 22:55 /var/adm/utmpx
bash-3.00# file /var/adm/utmpx
/var/adm/utmpx: data
bash-3.00#

10. How to view the User’s login and logout details?

last” command will show the users login and logout details. The command refers /var/adm/wtmpx to obtain the information.

bash-3.00# last
root      pts/3        192.168.10.22    Wed Dec 11 22:55   still logged in
root      sshd         192.168.10.22    Wed Dec 11 22:55   still logged in
root      pts/2        192.168.10.22    Tue Sep 10 22:11   still logged in
root      sshd         192.168.10.22    Tue Sep 10 22:11 - 22:55 (92+00:43)
reboot    system boot                   Tue Sep 10 22:03
reboot    system down                   Fri Sep  6 17:59
wtmp begins Tue Aug 13 01:32
bash-3.00#
bash-3.00# ls -ld /var/adm/wtmpx
-rw-r--r--   1 adm      adm        68820 Dec 11 22:55 /var/adm/wtmpx
bash-3.00# file /var/adm/wtmpx
/var/adm/wtmpx: data
bash-3.00#

11. How to view details information about the User?

finger username” will show the details about the user.

bash-3.00# finger geeksearch
Login name: geeksearch
Directory: /home/geeksearch               Shell: /bin/sh
Never logged in.
No unread mail
No Plan.
bash-3.00#

12. Describe about SETUID/SETGID/StickyBIT?

13. How to check Primary and Secondary Group of One User?

id -a username” will show the user’s Primary and Secondary groups. FYI, One User can be added in 15 no; of Secondary groups, But Only one Primary Group.

bash-3.00# id -a geeksearch
uid=100(geeksearch) gid=1(other) groups=1(other)
bash-3.00#
gid - Primary Group
groups - Secondary Group

14. How to rename the existing User ID?

# usermod -l [newname] [oldname]
bash-3.00# usermod -l geeksearch_new geeksearch
UX: usermod: geeksearch name too long.
bash-3.00# grep -i geeksearch /etc/passwd
geeksearch_new:x:100:1::/home/geeksearch:/bin/sh
bash-3.00#

15. How to lock the User Account?

# passwd -l UserID
bash-3.00# passwd -s geeksearch
geeksearch  PS
bash-3.00# passwd -l geeksearch
passwd: password information changed for geeksearch
bash-3.00# passwd -s geeksearch
geeksearch  LK
bash-3.00#

16. How to unlock the User Account?

# passwd -u [UserID]
bash-3.00# passwd -s geeksearch
geeksearch  LK
bash-3.00# passwd -u geeksearch
passwd: password information changed for geeksearch
bash-3.00# passwd -s geeksearch
geeksearch  PS
bash-3.00#

17. How to make the user account as non-expriry?

# passwd -x -1 [userID]
bash-3.00# passwd -s geeksearch
geeksearch  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -x -1 geeksearch
passwd: password information changed for geeksearch
bash-3.00#
bash-3.00# passwd -s geeksearch
geeksearch  PS
bash-3.00#

18. How do we set force passwd change for User’s first login?

# passwd -f [UserID]
bash-3.00# passwd -s geeksearch
geeksearch  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -f geeksearch
passwd: password information changed for geeksearch
bash-3.00#
bash-3.00# passwd -s geeksearch
geeksearch  PS    00/00/00     7    91     7
bash-3.00#

19. How to delete the User ID?

# userdel [UserID]

or

# userdel -r [UserID]

-r option will delete the User’s Home directory too.

20. Type of SHELLs ? What is initialization file for those SHELLS?

/bin/bash  - Bourne Again shell
/bin/csh    - C shell
/bin/ksh   - Korn shell
/bin/tcsh   - TC shell
/bin/zsh    - Z shell
Shell System-wide Initialization Files Primary User Initialization Files Read at Login User Initialization Files Read When a New Shell Is Started Shell Path Path
Bourne /etc/profile $HOME/.profile N/A /bin/sh
Korn /etc/profile $HOME/.profile and $HOME/.kshrc $HOME/.kshrc /bin/ksh
C /etc/.login $HOME/.cshrc and $HOME/.login $HOME/.cshrc /bin/csh

21. How to Check the User’s Crontabs ? How to allow the User to access the cron?

# crontab -l [username]

or

# ls -ltr /var/spool/cron/crontabs/

/etc/cron.d/cron.allow : If the file exists, the users can use crontab whoever listed in that file.

22. How to check User’s Present Working Directory Path? How to check the Obsolete Path of a running process?

Find the Present Working Directory Path

# pwd

Find the Obsolete Path of Process.

# pwdx