Wednesday, September 30, 2020

Linux Interview questions with answers Part-02

Question1 : What is the default permission on user's home directory?

Ans: 

700

Question2 :What is the difference between .bash_profile and .bashrc?

Ans: 

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.


Question3 :Explain each field of /etc/passwd.

Ans: 

hnm:x:512:512:User:/home/hnm:/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


Question4 :How to change primary group for any user?

Ans: 

usermod -g groupname  username


Question5 :If I delete a user(hnm), 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

Ans: No, home directory will not deleted.

Below command is to delete the home directory of user along with user.

# userdel -r username


No comments:

Post a Comment