1. How to create a user ? Brief with full syntax..
/usr/sbin/useradd -u uid -g gid -c " User Descriptions" -m -d "Home Directory Path" -s "Shell" username
Example :
2. What are the important files for User Management task?
/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
Example :
4. Describe the /etc/shadow file fields ?
/etc/shadow file is having 9 fields
loginID:password:lastchg:min:max:warn:inactive:expire:reserved
Example:/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 "Unixrock blog" -m -d /export/home/unixrock -s /usr/bin/bash unixrock
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?
/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
Example :
unixrock:x:535:121:Unixrock blog:/export/home/unixrock:/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
unixrock: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
Example:
unixrock::121:unixrock, raj
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 ?
/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 unixrock Login name: unixrock Directory: /home/unixrock Shell: /bin/sh Never logged in. No unread mail No Plan. bash-3.00#
12. Describe about SETUID/SETGID/StickyBIT ?
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 unixrock uid=100(unixrock) 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 unixrock_new unixrock UX: usermod: unixrock name too long. bash-3.00# grep -i unixrock /etc/passwd unixrock_new:x:100:1::/home/unixrock:/bin/sh bash-3.00#
15. How to lock the User Account ?
# passwd -l UserID
bash-3.00# passwd -s unixrock unixrock PS bash-3.00# passwd -l unixrock passwd: password information changed for unixrock bash-3.00# passwd -s unixrock unixrock LK bash-3.00#
16. How to unlock the User Account?
# passwd -u <UserID>
bash-3.00# passwd -s unixrock unixrock LK bash-3.00# passwd -u unixrock passwd: password information changed for unixrock bash-3.00# passwd -s unixrock unixrock PS bash-3.00#
17. How to make the user account as non-expriry ?
# passwd -x -1 <userID>
bash-3.00# passwd -s unixrock unixrock PS 12/11/13 7 91 7 bash-3.00# bash-3.00# passwd -x -1 unixrock passwd: password information changed for unixrock bash-3.00# bash-3.00# passwd -s unixrock unixrock 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 unixrock unixrock PS 12/11/13 7 91 7 bash-3.00# bash-3.00# passwd -f unixrock passwd: password information changed for unixrock bash-3.00# bash-3.00# passwd -s unixrock unixrock 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
Bourne /etc/profile $HOME/.profile /bin/sh /etc/skel/local.profile
Korn /etc/profile $HOME/.profile /bin/ksh /etc/skel/local.profile
$HOME/.kshrc
C /etc/.login $HOME/.cshrc /bin/csh /etc/skel/local.cshrc
$HOME/.login /etc/skell/local.login
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 running process ?
Find the Present Working Directory Path
# pwd
Find the Obsolete Path of Process.
# pwdx
No comments:
Post a Comment