Linux Interview Question and Answer

Q1)What is the difference between chmod and chown.

Chmod change  the file/directory permission

The Chown to change the ownership of a file or directory and ownership away to someone else.

Q2)How to check the default run level.

Cat /etc/inittab or who –r

Q3)What is the ID for Logical volume management?

LVM Id: 8e

Q4)What is the steps if the remote server is not connecting?

Ping remote server IP. (to check  alive or not)

Make sure remote server sshd service enabled

If everything is ok, login remote server ILO, open the remote console and check the status

Q5)Explain how to stop ssh connection for a particular server or network.


Q6)How we are giving file permission for the particular user.

Setfacl –m u:username:permission filename

Getfacl username (to check the user permissions)

Q7)I need to check the particular service opened or not. Please explain.

Netstat –anultp service name or port number

Q8)How to enable/disable the services in particular run level.

Chkconfig –level 2 off

Q9)Explain nfs hard and soft mount. :

Hard Mount : After restarting the server keep on search nfs mount partition until found the device, if the device not found server not will not boot,.

Soft mount: if device not found it will skip

Q10)What is the difference between YUM and rpm.

Rpm: need local rpm file and dependencies

Yum: need repository (collections of rpm) local or internet

Q11)What is the command to check the size of file or directory?

du –sh <file/dir>

Q12) Which one is the default sticky bit directory?


Q13)How to check how many files opened in Linux.


Q14)How to find zombie process and how to kill?

ps aux |grep “defunct” and ps aux |grep Z  to Kill: In order to kill these processes, you need to find the parent process first.

pstree –paul and find parent process id, use kill -9

Q15)What is the command for extract RPM?


Q16)Assume the / partition got read only error, what steps has to be take.

Remount –o rw,remount

Q17)How to find out whether the particular user locked or not?

/et/passwd (!!)

Q18)Please let us know how to stop the ssh service from a particular node.

/etc/hosts.deny à sshd: ALL except Node IP

Q19)What is the command to check password expire information for the particular user.

Chage –l username

Q20)How to recover if the user deleted by mistake?

# pwunconv     (It creates the users according  /etc/passwd   file and deletes the  /etc/shadow   file)

Q21)How to put never expiry to a user?

# passwd     -x    -1    <user login name> How to put never expiry to a user?

# passwd     -x    -1    <user login name>

Q22)How to find the users who are login and how to kill them?

# fuser    -cu    (to see who are login)

#fuser    -ck    <user login name>(to kill the specified user)

Q23)How can you make a service run automatically after boot?

# chkconfig <service  name>   on

Q24)How to check whether the ssh is running or not on the remote host?

# nmap   -p  22    <IP address of the remote host>    (to see the ssh is running or not on remote system)

Q25)How to check the remote server services are running or not?

Nmap servername portname

Q26)Explain about kernel panic error.

Hardware error, Kernel error

Q27)Step out if you are facing too many file system while login via ssh?

Lsof |wc –l (list of open files)

If more than 65k, open /etc/sysctl.conf increase the value and execute below command

Sysctl –p

Q28)How to disable direct root login?

Using /etc/ssh/sshd_congig

Q29)Which is default sticky bit directory?


Q30)How to check the integrity of a file system or consistency of the file system?

fsck   <device or partition name>command we can check the integrity of the file system.

The before running the fsck command first unmount that partition and then run fsck command.

Q31)How many types of disk space issues can we normally get?

Disk is full.

Disk is failing or failed.

File system corrupted or crashed.

O/S is not recognizing the remote luns when scanning, …etc.,

Q32)What is the command to check default run level.

The default run level command is /etc/inittab file in most Linux operating systems.

Q33)A system is able to ping locally but not out site. Why?

May be there is no access to outside.

May be outside is in a different network from the local.

May be permission is denied for that system to access outside.

If there is access, but router or modem or network switch or NIC may not be working to access the outside.

Q34)If not able to create the file in any partition, what might be the issue.

Permission check and disk space getting full

Q35)Explain ping Command?

The ping command is used to determine connectivity between hosts on a network

$ ping

Q36)Explain how to check cron job particular user.

Crontab –l –u rbtadmin

Q37)Kernel path


Q38)What is linux library file extension,


Q39)What command use for check IP address?

# ifconfig

Q40)How many type of class and explain?

There are Three types of class

class A 1-126

class B 128-191

class c 192-221

Q41)What command use for save and exit?


Q42)Expline restart the system?

# systemctl restart network

Q43)How to create the use?

# useradd  linux

Q44)How to assign password the user?

# passwd linux

Q45)How to login the user?

# su linux

Q46)How to check user list?

# cat /etc/passwd

Q47)How to create group?

# groupadd my group

# cat /etc/my group

Q48)How to add user the group?

#useradd  -d/root/abi abhi

Q49)Explained date Command?

The date command displays/sets the system date and time like this.

$ date

$ date –set=”8 JUN 2017 13:00:00″

Q50)What is relevance of $?

It reflects the status of previous command

If 0 – Success

If Non-Zero – Not Success

Q51)What happens if #/bin/php as shebang in a script.

It considers the script as a PHP script

Q52)Whether Nested if-else is possible in bash scripting?


Q53)Which is the best command that can be used for checking selinux activation status


Q54)If we need to escape single quote (‘) in echo, what is the process

Two ways

echo “‘hi’”

echo \’hi\’

Q55)What is load-average in linux.

It’s the average of the usage of each CPU

It can be found with 4 commands




cat /proc/loadavg

Q56)How tree format of format listed

pstree -pua

ps ax –forest

Q57)What is the use of the command top

This command is the task manager of linux. We could able to find load average, memory usage, swap usage, total number of processes, CPU, Memory usage of each processes in sorted format.

Q58)What is symbolic link or symlink?

It is shortcut of a big command, we can do this using the command ‘ln’

Eg: ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli

We can directly use the command redis-cli

Q59)What are the features of /proc folder

All process identification is stored in this folder

It will list all process id as folders /proc/12435

It will show the command used by the process

It will show the files used by the process

Memory dump etc

Q60)How to find a pattern from a file or command?

Use ‘grep’ command

Eg: cat /proc/meminfo  | grep MemFree

Q61)Find who all are logged in to the system?

Use command

who -Hu

Q62)Which Terminal you are working in?

Find it using ‘tty’ command or who command

Q63)What to do if $PATH is lost, and its output is blank?

Fix it by adding atleast the system binary path, so that basic command

export PATH=/sbin:/usr/bin:/usr/sbin

Q64)Command ifconfig is not found in my system, how to get my ip address

Use command

ip a

Q65)What is the method to run a command in background?

command &

Q66)How to list selinux users?

semanage user -l

Q67)My command ‘setenforce 0’ is not working, what to do?

Edit /etc/selinux/config anf change the enforcement to disabled and reboot the server.

Q68)What are the known commands for disk partitioning?

fdisk, parted

Q69)Can we have dynamicity for my disk?

Yes, use LVM

Q70)What make LVM different from ext3 and ext4

LVM is a utility for dynamically extent or shrink a volume. ext3, ext4, it is not possible.

Q71)When I executed ‘vgchange -ay’, I could find another lvm disk attached. How to get it mounted in my system.

Once the above command is executed, the new volgroup will be available to use.

Then mount to a location like
mount /dev/mapper/VolGroup/pv /mnt

Q72)How many primary partitions are created by default?


Q73)Which is the hexadecimal code for LVM


Q74)A rpm package is owned by some third-party vendor. How to get the vendor details of an rpm?

rpm -qi <package>

Q75)rpm -qf /sbin/vi : What is the output of this command?

It gives the package in which the provided binary associated.

Q76)Which command will list the current time source?

ntpd -q

Q77)Write the command to list all ports added in firewall.

Firewall-cmd –list-ports

Q78)What does the following command does?

(firewall-cmd –zone external –permanent –add-forward-port port=25:proto=tcp:toaddr=

It will forward the inward traffic of SMTP to the IP mentioned.

Q79)What are the list of sequence of commands to enable Kerberos authentication

kadmin, ktadd, authconfig, kinit

Q80)What to do for enabling remote logging?

Open /etc/rsyslog.conf and add the following line.

*.* @@IP:514

systemctl restart rsyslog

Q81)Which Directive in Apache Virtualhost defines the path of the web files?


Q82)What is the relevance of DirectoryIndex?

It defines the file to be considered as index file. Eg ‘DirectoryIndex index.php index.html’ : In this it will find index.php first when the URL is accessed, if this file is not available, it will search for index.html as index page.

Q83)What is the difference between passwd and htpasswd

Passwd is used for setting the password for a System User.

Htpasswd is used for setting the password for Apache Web User.

Q84)Which SELinux policy is used for Apache WebServer?

For web files, httpd_sys_content_t is used

For NFS mount files, httpd_use_nfs

Q85)Instead systemctl, which all commands used for handling apache service.


apachectl -t : Checks Syntax

apachectl start/stop/restart : For handling service

Q86)How to display all WebSite VirtualHost?

Use command : httpd -D DUMP_VHOSTS

Q87)How to set the SMTP port for all IPs in the servers? How to do this without editing the configuration in Postfix.

Execute command : postconf -e inet_interfaces=all

Q88)If we have 2 smtp service installed in the server, how to switch to the required one?

Use : alternatives –config mta (mta is mail transfer agent)

Q89)What is PTR record in Bind Zone?

Its is Pointer Record for reverse lookup : Inorder to get hostname if IP is queried.

Q90)Which are two main command in bind inorder to make sure that Bind will work perfectly.



Q91)How to lookup a domain using public DNS?

dig @ domainname

Q92)How to reverse lookup for IP address?

dig -x IP-Address

Q93)How to take backup of my wordpress DB?

Use command : mysqldump -hHOST -uUSER -pPASSWORD DB_NAME > DB_NAME.sql

Q94)Restore wordpress DB to mySQL

mysql -hHOST -uUSER -pPASSWORD DB_NAME < DB_NAME.sql (Create DB prior using ‘create database db_name’)

Q95)Instead of using ‘reboot’ or ‘shutdown -r’, which command can be used in Linux to do this.

Use Init command : init 6 (6 option is for reboot in Linux Runlevels)

Q96)Which attribute is set for executable on group level.


chmod g+s /usr/bin/wall

Leave a Reply