Showing posts with label Linux Interview Questions & Answers. Show all posts
Showing posts with label Linux Interview Questions & Answers. Show all posts

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


Sunday, July 19, 2020

Linux Interview questions with answers Part-1

Q-1. What is the shortest command to take you back to the home directory? 
A. cd ~ 
B. cd $HOME 
C. cd 
D. . 

 Answer. C 

 Q-2. Which of the following best defines the purpose of the following operator >>? 
A. Forwards the output of one command, so that it becomes the input for another. 
B. It sends both input and output to the same file. 
C. It’ll overwrite the contents of the target file. 
D. Appends data to a file without overwriting it. 

 Answer. D 

 Q-3. Which of the options specifies the system file meant for holding the processor information? 
A. /bin/cpu 
B. /dev/cpuinfo 
C. /proc/cpuinfo 
D. /etc/cpu

 Answer. C

 Q-4. Which of the commands would search for the string “Linux” at the end of the line in a file called textfile? 
A. grep ‘Linux# ‘ textfile 
B. grep ‘ Linux! ‘ textfile 
C. grep ‘ Linux$ ‘ textfile 
D. grep ‘ Linux^’ textfile

 Answer. C  

Q-5. What is the command to list the hidden files in your HOME directory?
 A. ls -hn 
B. ls -h 
C. ls -la 
D. ls -la ~/ 

 Answer. D 

 Q 6 - The following command can list out all the current active logins. 
A - whoami 
B - who am i 
C - who 
D - None of the above.

 Answer : C 

 Q 7 - Choose the correct from below to search for lines beginning with the pattern using grep. 
A - ^pattern 
B - pattern^ 
C - $pattern 
D - pattern$ 

 Answer : A 

 Q 8 - Which command can be used to start the process with the required priority?
 A - schedule 
B - nohup 
C - nice 
D - prefer 

 Answer : C 

 Q 9 - Per user configuration setting are found in the following file of user’s home directory. 
A - profile 
B - .profile 
C - .mbox 
D - .exrc 

 Answer : B 

 Q 10 - Which command is used to copy file across different system? 
A - rcp 
B - ftp 
C - mcp 
D - ncp 

 Answer : B 

 Q 11 - In general the working directory of the user root is __ 
A - / 
B - /root 
C - /admin 
D - /home/root 

 Answer : B 

 Q 12 - What does the following command will do? $ chmod 888 file 
A - It enables r,w,x premissions for all users 
B - It disable r,w,x permissions for all users 
C - It enables r,w,x permissions only for owner of the file 
D - None of the above. 

 Answer : D