1. How can you create a user without useradd command
Follow the below link
How to create a user without useradd command?
2. What is the default permission on user's home directory?
700
3. What is the difference between .bash_profile and .bashrc?
Every time you login to a Linux (Red Hat) machine .bash_profile file is executed but In case you are already logged in and you open a new terminal then .bashrc file is executed
4. What is the command to create a user with a pre defined uid, shell and home directory?
useradd -m -d /path/to/home -s /bin/bash -u 550 <USER>
5. Explain each field of /etc/passwd
deepak:x:512:512:User:/home/deepak:/bin/bash
- 1st field: username
- 2nd field: x tells that an encrypted password is stored in /etc/shadow
- 3rd field: uid
- 4th field: gid
- 5th field: Description
- 6th field: home directory
- 7th field: default login shell
6. How to change primary group for any user?
usermod -g <groupname> <username>
7. If I delete a user, does it's home directory gets deleted? If not then what is the command to delete the home directory of user along with the user
No.
# userdel -r <username>
8. Name any 3 files which are automatically created inside any user's home directory when a user is added
.bashrc .bash_profile .bash_history
9. What is the command to view all the currently logged in users?
w
10. What is the command to change and view the expiry date for any user?
chage
11. What are the details you get with finger command?
Login Details Mail Home directory Last login
12. How can you give a normal user all the root level privileges?
Add the user to wheel group and uncomment the wheel group line in sudoers file
Give the user all command permission in sudoers
How to give normal user root privileges using sudo in Linux/Unix
13. Name any 3 groups of which root is a member by default
root bin daemon sys adm disk wheel
14. How can you give sudo access to any user without asking him to provide passord every time he runs a command?
Add an extra parameter NOPASSWD in sudoers file while giving the user permission to run root level commands
15. Why do we use visudo rather than editing the file with vi or any other editor?
Follow this link
A guide on visudo and its usage
For more interview questions
https://www.golinuxcloud.com/category/interview-questions/
https://www.golinuxcloud.com/category/interview-questions/
Thanks for the nice post, post some tricky user admin interview questions if you have.
Default umask for the Root is 0022 hence file – 644 and dir – 755 whereas default umask for non-root user is 0002 hence file- 664 and dir -775 permissions.
Default Umask of Root is 0022 hence file – 644 and dir – 755 whereas default umask for non-root is 0002 hence file – 664 and dir – 775 .
Very nice.info
very thank full
Suggestion :-
How to lock & unlock a user
Can 2 user have same uid & gid
Hi Shubham
you can lock and unlock if you had two users have with same uid and gid also by using below commands .
ex: i have two users test and test1
usermod -L test –>it will lock to test user
usermod -L test1 –> it will lock to test1 user
u can verify in /etc/shadow file
cat /etc/shadow |grep -i test
cat /etc/shadow |grep -i test1
o/p : u can observer below 2 lines after test: ! is there its indicates user is currently locked.
test:!$6$mC7ZaS/G$4qD3TYhqujmS628mlYG1XcL3TxYYiWBeCMs9TM/.EfJ31RzedqOMQ0SCk3A3NPM7/rmHvNRdU5KmIkWwlZ96J1:17347:0:99999:7:::
test1:!$6$2Z1S8yPW$dnLx0qwxBQOI9c9vjzJsD2IxXB7s2zuy3u4RhrJwjPWMCf7.rHIRBjZ9JgmsLx/VyPs3Rb7zKTQZoAHpoBgAO0:17347::::::
i need step by step process of truobleshooting user login issues when user unable to login??
I have written this article to understand login process
golinuxhub.com/2014/09/how-does-successful-or-failed-login.html
but to troubleshoot login issues there are various things which can be done
Like execute ssh with verbose and check the stage where it fails
monitor the client node's sshd logs and see the error message you get (this will give you the best hint)
Disable firewall on server and client side and see if that is the problem
Minimize sshd hardening if any of your recent sshd hardening changes led to the problem
check password of the usr, if it is blocked
and many more..
nice
How to add 50 or 100 users with out user add
out of 50 users only 10 users are able to work remaining are not able to work how i will rectify this problem