Top 125 Linux Interview Question and Answers






Q:1 How To check the uptime of a Linux Server ?
Ans: Using uptime command we can determine how long a linux box has been running , also uptime can be viewed by the top & w command.

Q:2 How to check which Redhat version is installed on Server ?
Ans: Use the command cat /etc/redhat-release , output of this command will tell you the redhat version.

Q:3 How to install rpm packages in Redhat & CentOS linux ?
Ans: rpm and yum command are used to install packages in redhat linux and CentOS.

Q:4 How to check the ip address of LAN Card ?
Ans: Using ‘ifconfig’ & ‘ip address’ command we can determine the ip address of LAN Card.

Q:5 How to determine the hostname of a linux box ?
Ans: On typing the hostname command on terminal we can determine the hostname of a linux server.

Q:6 How To check the default gatway ?
Ans: Using ‘route -n’ command we can determine the default gateway in linux.

Q:7 Which Command is used to check the kernel Version ?
Ans: ‘uname -r’

Q:8 How to check the current runlevel of a linux box ?
Ans : ‘who -r’ and ‘runlevel’ , both of these command are used to find current run level.

Q:9 What is Initrd ?
Ans: Initrd stands for initial ram disk , which contains the temporary root filesystem and neccessary modules which helps in mounting the real root filesystem in read mode only.

Q:10 What is Bootloader ?
Ans: Bootloader is a program that boots the operating system and decides from which kernel OS will boot.

Q:11 How to list hidden files from the command line ?
Ans: ‘ls -a’ <Folder_Name>

Q:12 What is soft link ?
Ans: Soft link is a method to create short cuts in linux. It is similar to windows short cut feature.

Q:13 How to create a blank file in linux from command line ?
Ans: Using the command ‘touch <file-name>’

Q:14 What is run level 2 ?
Ans: Run level 2 is the multi-user mode without networking.

Q:15 Why linux is called OpenSource ?
Ans: Because One can customize the existing code and can redistribute it.

Q:16 How to check all the installed Kernel modules ?
Ans: Using the Command ‘lsmod’ we can see the installed kernel modules.

Q:17 What is the default uid & gid of root user ?
Ans: Default uid & gid of root user is 0.

Q:18 How To change the password of user from the Command Line ?
Ans: ‘passwd <User-Name>’

Q:19 What is a Process ?
Ans: Any program in execution is called a process.

Q:20 What is name of first process in linux ?
Ans: ‘init’ is the first process in linux which is started by kernel and whose pid is 1.

Q:21 What command do you use to format a partition with a file system?
You could use mkfs command to format partition with file system.

Q:22 Which command will assign IP address 192.168.1.1 and subnet mask 255.255.255.0 to eth0 network interface?
ifconfig command can be used to assign IP address. Following command will do the given task
ifconfig eth0 192.168.1.1 netmask 255.255.255.0

Q:23 Which option in fdisk will display the partition table?
In fidisk utility, the "p" command will print the partition table.

Q:24 To create a recurring scheduled task, which Linux scheduling tool should you use?
The cron command allows you to create recurring tasks

Q:25 What command can you use to enable an Ethernet network interface that has already been configured?
To enable already configured interface use
ifconfig [interface] up
command. For example to up eth0 interface use following command
#ifconfig eth0 up

Q:26 How will you decompress the demo.tar.gz file?
To decompress use following command
#tar -zxvf demo.tar.gz

Q:27 A core dump file contains this message, “Program terminated with signal 11, segmentation fault.” What does this message indicate?
The core file will tell you what exactly caused the program to crash. So this message indicate that the program crashed because of a segmentation fault in memory.

Q:28 What command runs fdisk on the first ATA/IDE hard drive?
The first ATA/IDE hard drive is hda, so the command would be
# fdisk /dev/hda

Q:29 An application is creating several, very large core dump files. What should the administrator do if he has no intention of debugging these files?
If administrator have no intention of keeping these files for debugging purposes, they should be deleted because they are wasting valuable disk space, and may cause system to run out of space.

Q:30 When checking the partition information on your hard drive with fdisk, you notice that one of the partitions is formatted as "Linux Swap" and is approximately 512MB in size. What is the purpose of this partition?
The Linux swap file is used for virtual memory to store additional information that cannot fit into current memory. This swap file allows information to be cached on disk, and can be retrieved very quickly. Heavy use of the swap file indicates a low memory condition.

Q:31 What sort of kernel error can cause a Linux system to crash and write a memory core dump?
Kernel panic error can cause a Linux system to crash. A kernel panic indicates that a kernel process has crashed. This is a very serious error that causes the entire Linux system to crash. These core dumps should be analyzed carefully to find the root cause of the problem.

Q:32 An administrator wants to assign an IP address of 192.168.1.10, a subnet mask of 255.255.255.0, and a broadcast address of 192.168.1.254 to eth1. What command will accomplish this task?
Following command will do this task
ifconfig eth1 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.254

Q:33 What command should you use to set up a job to run at 11:15 a.m. today?
When you are only running the job once at the specified time, you should always use the at command. In this case following command will do the task
#at 11:15

Q:34 You are tasked to set up a schedule to perform automatic checks of available disk space at the end of the day. How can you accomplish this task?
To accomplish this task set up cron to run a script that will check the disk space daily at 7:00 p.m. The output will be e-mailed to the root account. You can compare the results from day to day to analyze disk space usage.
Your cron file should look similar to the following:
* 19 * * * df -kl

Q:35 As a administrator you need to terminate the sendmail process. How will you do that?
First you need to determine the PID of sendmail so it can be killed.
#ps -ef |grep sendmail
Now you can use kill command to terminate the process associated with sendmail.

Q:36 You noticed a kernel error message during the boot process, but it scrolled before you could read this? What log file could you check to find out that message?
The log file that contains kernel boot messages is /var/log/dmesg.

Q:37 You execute a command that is going to take a long time. How can you get back to your shell prompt to perform other task?
You can use bg command to send a running process to the background.

Q:38 You need to kill all instances of Web Server? What command will you execute to do this?
You can use killall httpd command to kill all httpd process. httpd process run web server.

Q:39 How can you list all running process?
Use ps -ef command to list all running process.
#ps -ef

Q:40 As a Linux admin you want to know what processes are being run by user sumit. What command can you use ?
You can use #ps -au command to list all the process owned by user. Following command will do the assigned task
#ps -au sumit

Q:41 Which log file keeps track of all user logins and logouts?
/var/log/wtmp log file keeps track of all user logins and logouts.

Q:42 What is the first process that is run when a Linux system starts, and is responsible for starting all other system processes and services?
The init process is the first process to be run. It is the parent process of all other Linux system processes, services, and daemons that are needed to run the system.

Q:43 Which command will you use to bring a process in foreground, which is running in the background?
The fg command immediately moves the program to the foreground.

Q:44 An administrator has accidentally killed a core process. What is the result of this action?
Killing a core process can potentially crash your system because many critical services rely on these core processes

Q:45 As a administrator you need to monitor the /var/log/messages file in real time to resolve the issue? How would you do that?
You can use tail command with -f option. Following command will do the assigned task
#tail -f /var/log/messages

Q:46 From the output of ps command how will you determine the ID number of the parent process of a particular program?
PPID refers to the parent process identification number.

Q:47 While scanning the /var/log/messages file, you notices an error stating an authentication failure for root. What could this mean?
Any failed login attempts for root are logged into the /var/log/messages file. It indicate that some has tried to login as root.

Q:48 As an administrator you noticed from top command that an unidentified process is using up all CPU and memory. You suspects that is a user's process that has run away. How should you fix this ?
The process should be immediately killed before it consumes so many resources that the server cannot run properly, and therefore crash.

Q:49 What command can an administrator use to track real-time information on processes and the resources that they are using?
The top command is used to monitor processes and resources in real-time.

Q:50 A developer with username sanjay has told you that one or his processes seem to be locked up and he cannot it. He reported that it a bug in his code and may quickly use up all CPU and RAM resources on the server. How will you tack the process and terminate it?
Your first step is to identify the process, use ps command
#ps -au sanjay
Now run top command to compare the process running, and verify which one is using the most resources. After you have identified the problem process, you can use the kill command to terminate it. Because the user was unable to stop the process, you should probably force a kill signal to make sure that the process stops:
#kill -9 [PID of process]
Now, to verify that it has stopped, run the ps command again on the user:
ps -au sanjay

Q:51 What is Kerberos used for?
Kerberos is used for secure network logon.

Q:52 Which partition store system configuration files in Linux system?
/etc partition stores system configuration files in Linux.

Q:53 What is the purpose of the MD5 option on passwords?
MD5 is an encryption method that encrypts the password before saving.
A better method of password security is to create difficult-to-break passwords that are easy for the users to remember.

Q:54 What is the alternative method to a GUI installation in Linux ?
Linux provides text base installation as the alternative method of GUI installation.

Q:55 What is the purpose of the swapon command ?
swapon command is used to activate a already created swap partition. It cannot be used to create a new swap partition.

Q:56 What is gzip?
gzip is a compression utility created by the GNU project.

Q:57 Name any four general password rules for user account.
·      Include at least eight total characters
·      Use the string in an unrepeated way
·      Avoid use words that can be found in the dictionary
·      Avoid use dates of significance, such as a birthday or anniversary

Q:58 What is tar?
tar is an archive utility that is used to create tape backups.

Q:59 Which is the standard command used to uncompress gzip files?
The standard command used to uncompress gzip files is gunzip.

Q:60 What is the RPM switch for only installing packages?
The command line switch for installing an RPM is -i.

Q:61 What is the command used to install an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to install an RPM package is rpm -ivh. Following command will install the given package
#rpm -ivh demofilename2.2-2.i386.rpm

Q:62 What is the command used to remove an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to remove an RPM package is rpm -evh. Following command will remove the given package
#rpm -evh demofilename2.2-2.i386.rpm

Q:63 What is the command used to update an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to update an RPM package is rpm -Uvh. Following command will update the given package and remove the old.
#rpm -Uvh demofilename2.2-2.i386.rpm

Q:64 Which command is used to see which RPM version of gzip was installed on the system?
#rpm -q gzip

Q:65 Where are the automatically mounted file systems listed?
The automatically mounted file systems are listed in the file /etc/fstab.

Q:66 While installing the new RPM what common steps should take ?
You should follow these common steps
·      Use RPM tools should be used to query or verify the installed packages to
·      confirm the installation of any previous packages.
·      Check the signature of new package
·      RPM should be installed or upgraded by first using the test mode to verify that it works, and then it should be installed
·      At the end query the RPM and verify the installation of RPM
Which organization controls the official releases and updates of the X Window System?
The X Consortium at www.x.org controls the official release and updating of the X Window System

Q:67 PPP is most often used to create?
PPP is most often used to create serial point-to-point connections.

Q:68 When attempting to connect to www.example.com you got unknown host message. Which service is most likely not functioning properly?
DNS

Q:69 Samba is used to provide support for which protocol?
Samba is used to support the Microsoft SMB/CIFS systems.

Q:70 What command is used to load a module into the kernel?
The insmod command is used to load a module into the kernel

Q:71 Name one of the most secure method of remote access.
SSH is the most secure method of remote access

Q:72 With respect to a Linux system’s RAM, how large should the swap file be?
Generally the size of the swap file should be twice the size of installed RAM.

Q:73 How would you create a backup of the fstab file to the /backup folder?
Use cp command to create the backup.
#cp /etc/fstab /backup

Q:74 What command is used to exit the edit mode of VI editor?
The [esc] key is used to exit from the edit mode of VI editor.

Q:75 What key combination will exit from VI editor and not save the changes made?
Esc + q +! Key combination will exit VI without saving the changes.

Q:76 What command would you use to create a file system on a new hard drive?
The mkfs command is used to create file systems.

Q:77 What fstab file do?
The fstab file is used to automatically mount file systems.

Q:78 What inittab file do?
The /etc/inittab file is used to perform the default state and terminal connections for a Linux system.

Q:79 What command can you use to verify the current active shell?
The env command will display the current active shell.

Q:80 Where is the file . bashrc located?
The . bashrc file is usually located in the /home/username directory.

Q:81 What function does the .bash_profile file perform?
The function of the .bash_profile file is to provide login initialization commands.

Q:82 What function does the .bash_logout file perform?
The function of the .bash_logout is to provide logout functions

Q:83 What function does the .bashrc file perform?
The function of the .bashrc file is to provide shell configuration commands.

Q:84 Which version of RHEL officially supports LUKS encryption?
From version 6 or higher LUKS encryption is officially supported by RHEL.

Q:85 What is the default virtualization technology for RHEL6 ?
Default virtualization technology is KVM.

Q:86 Can you configure KVM Virtual machine on 32 bit system ?
No, KVM virtualization requires at least 64 bit system.

Q:87 Which remote management service is allowed through the default firewall and by default installed in RHEL?
By default SSH is always installed in RHEL. SSH uses port 22 which is allowed through the default firewall rules.

Q:88 Which standard directory is used by vsFTP server for file sharing ?
Default Standard directory for ftp is /var/ftp/pub.

Q:89 What is default mode of SELinux during the installation of RHEL ?
·      In RHEL5 you have to choose the mode which you want.
·      From RHEL6 default mode is Enforcing during the installation.
However you can change the mode of SELinux after installation, only difference between RHEL5 and RHEL6 is that in RHEL5 asks you to choose the mode while RHEL6 does not let you to choose the mode during the installation.

Q:90 Which standard directory is used by Apache web server for HTML files ?
standard directory for HTML files is /var/www/html

Q:91 What is the default partition layout during the installation ?
Default partition Layout is the LVM.

Q:92 Which necessary partition cannot be a part of logical volume group ?
boot partition cannot be a part of logical volume group. You must have create it as a regular partition.

Q:93 Which partitions are recommended for custom layout of partition ?
·      /
·      /boot
·      /home
·      swap

Q:94 What step during the installation could you take to prevent a program from creating temporary files that fill up the entire space ?
You can create a separate /tmp partition prevents a program from creating temporary files that fill up the entire filesystem.

Q:95 What is the kickstart ?
kickstart is a installation method used in RHEL. A kickstart installation is started from a kickstart file, which contains the answers to all the questions in the installation program.

Q:96 Name any of two third party distribution based on RHEL6 source code.
CentOS and Scientific Linux

Q:97 Which Log file contains all installation message?
Ans: install.log.syslog file contains all messages that were generated during the installation.

Q:98 What is the core of Linux Operating System?
Ans: Kernel is the core of Linux Operating System. Shell is a command Line Interpreter, Command is user Instruction to Computer, Script is collection of commands stored in a file and Terminal is a command Line Interface

Q.99 What Linus Torvalds Created?
Ans: Linux Torvalds created Linux, which is the kernel (heart) of all of the above Operating System and all other Linux Operating System.

Q.100 Torvalds, Wrote most of the Linux Kernel in C++ programming Language, do you agree?
Ans: No! Linux Kernel contains 12,020,528 Lines of codes out of which 2,151,595 Lines are comments. So remaining 9,868,933 lines are codes and out of 9,868,933 Lines of codes 7,896,318 are written in C Programming Language.
The remaining Lines of code 1,972,615 is written in C++, Assembly, Perl, Shell Script, Python, Bash Script, HTML, awk, yacc, lex, sed, etc.
Note : The Number of Lines of codes varies on daily basis and an average of more than 3,509 lines are being added to Kernel.

Q:101 Linux initially was developed for intel X86 architecture but has been ported to other hardware platform than any other Operating System. Do you agree?.
Ans: Yes, I do agree. Linux was written for x86 machine, and has been ported to all kind of platform. Today’s more than 90% of supercomputers are using Linux. Linux made a very promising future in mobile phone, Tablets. In-fact we are surrounded by Linux in remote controls, space science, Research, Web, Desktop Computing. The list is endless.

Q.102: Is it legal to edit Linux Kernel?
Ans: Yes, Kernel is released under General Public Licence (GPL), and anyone can edit Linux Kernel to the extent permitted under GPL. Linux Kernel comes under the category of Free and Open Source Software (FOSS).

Q.103: What is the basic difference between UNIX and Linux Operating System.
Ans: Linux Operating System is Free and Open Source Software, the kernel of which is created by Linus Torvalds and community. Well you can not say UNIX Operating System doesn’t comes under the category of Free and Open Source Software, BSD, is a variant of UNIX which comes under the category of FOSS. Moreover Big companies like Apple, IBM, Oracle, HP, etc. are contributing to UNIX Kernel.

Q.104: Is Linux Operating system Virus free?
Ans: No! There doesn’t exist any Operating System on this earth that is virus free. However Linux is known to have least number of Viruses, till date, yes even less than UNIX OS. Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.

Q.105: Linux is which kind of Operating System?
Ans: All of the Above. Linux is an Operating System which supports Multi User, Running a Number of Processes performing different tasks simultaneously.

Q.106: Syntax of any Linux command is:
Ans: The correct Syntax of Linux Command is Command [options] [arguments].

Q.107: Which command is used to record a user login session in a file?
Ans: The ‘script’ command is used to record a user’s login session in a file. Script command can be implemented in a shell script or can directly be used in terminal. Here is an example which records everything between script and exit.
Let’s record the user’s login session with script command as shown.
[root@localhost ~]# script my-session-record.txt
Script started, file is my-session-record.txt
The content of log file ‘my-session-record.txt’ can be views as:
[root@localhost ~]# nano my-session-record.txt
script started on Friday 22 November 2013 08:19:01 PM IST

Q.108: The kernel log message can be viewed using which of the following command?
Ans: The kernel log message can be viewed by executing ‘dmesg’ command. In the list kernel is not a valid Linux command, ‘ls -i’ lists the file with inode within the working directory and ‘uname’ command shows os.
[root@localhost ~]# dmesg
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-279.el6.i686 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 10:59:55 UTC 2012
KERNEL supported cpus:
Intel GenuineIntel
AMD AuthenticAMD
NSC Geode by NSC
Cyrix CyrixInstead
Centaur CentaurHauls
Transmeta GenuineTMx86
Transmeta TransmetaCPU
UMC UMC UMC UMC
Disabled fast string operations
BIOS-provided physical RAM map:
...

Q.109: Which command is used to display the release of Linux Kernel?
Ans: The command ‘uname -r’ display the kernel release information. The switch ‘-v’ , ‘-m’ , ‘-n’ , ‘o’ display kernel version, machine hardware name, network node, hostname and operating system, respectively.
[root@localhost ~]# uname -r
2.6.32-279.el6.i686

Q.109: Which command is used to identify the types of file?
Ans: The ‘file’ command is used to identify the types of file. The syntax is ‘file [option] File_name’.
[root@localhost ~]# file wtop
wtop: POSIX shell script text executable

Q.110: Which command locate the binary, source and man page of a command?
Ans: The ‘whereis’ command comes to rescue here. The ‘whereis’ command locate the binary, source, and manual page files for a command.
[root@localhost ~]# whereis /usr/bin/ftp
ftp: /usr/bin/ftp /usr/share/man/man1/ftp.1.gz

Q.111: When a user login, which files are called for user profile, by default??
Ans: The ‘.profile’ and ‘.bashrc’ present under home directory are called for user profile by default.
[root@localhost ~]# ls -al
-rw-r--r--.  1 localhost     localhost            176 May 11  2012 .bash_profile
-rw-r--r--.  1 localhost     localhost            124 May 11  2012 .bashrc

Q:112: The ‘resolv.conf’ file is a configuration file for?
Ans: The ‘/etc/resolv.conf’ is the configuration file for DNS at client side.
[root@localhost ~]# cat /etc/resolv.conf
nameserver 172.16.16.94

Q:113 Which command is used to create soft link of a file?
Ans: The ‘ln -s’ command is used to create soft link of a file in Linux Environment.
[root@localhost ~]# ln -s /etc/httpd/conf/httpd.conf httpd.original.conf

Q:114 The command ‘pwd’ is an alias of command ‘passwd’ in Linux?
Ans: No! The command ‘pwd’ is not an alias of command ‘passwd’ by default. ‘pwd’ stands for ‘print working directory’, which shows current directory and ‘passwd is used to change the password of user account in Linux.
[root@localhost ~]# pwd
/home/localhost
[root@localhost ~]# passwd
Changing password for user root.
New password:
Retype new password:

Q.115: How will you check pci devices vendor and version on a Linux?
Ans: The Linux command ‘lspci’ comes to rescue here.
[root@localhost ~]# lspci
00:00.0 Host bridge: Intel Corporation 5000P Chipset Memory Controller Hub (rev b1)
00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 2-3 (rev b1)
00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 4-5 (rev b1)
00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 6-7 (rev b1)
00:08.0 System peripheral: Intel Corporation 5000 Series Chipset DMA Engine (rev b1)


Q:116 How will you add a new user (say, tux) to your system.?
Ans: All of the above commands i.e., useradd, adduser and linuxconf will add an user to the Linux system.

Q:117 How many primary partition is possible on one drive?
Ans: There are a maximum of ‘4‘ primary partition possible on a drive.

Q:118 The default port for Apache/Http is?
Ans: By default Apache/Http is configured on port 80.

Q:119 What does GNU stand for?
Ans: GNU stands for ‘GNU‘s not Unix‘.

Q:120 You typed at shell prompt “mysql” and what you got in return was “can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’”, what would you check first.
Ans: Seeing the error message, I will first check if mysql is running or not using commands service mysql status or service mysqld status. If mysql service is not running, starting of the service is required.
Note:The above error message can be the result of ill configured my.cnf or mysql user permission. If mysql service starting doesn’t help, you need to see into the above said issues.

Q:121 How to Mount a windows ntfs partition on Linux?
Ans: First install ntfs­3g pack on the system using apt or yum tool and then use “mount sudo mount ­t ntfs­3g /dev/<Windows­partition>/<Mount­point>” command to mount Windows partition on Linux.

Q:122 From the following which is not an RPM based OS.?
§  RedHat Linux
§  Centos
§  Scientific Linux
§  Debian
§  Fedora
Ans: The ‘Debian‘ operating system is not an RPM based and all listed above are ‘RPM‘ based except Debian.

Q:123 Which command can be used to rename a file in Linux.?
Ans: The mv command is used to rename a file in Linux. For example, mv /path_to_File/original_file_name.extension /Path_to_File/New_name.extension.

Q:124 Which command is used to create and display file in Linux?
Ans: The ‘cat‘ command can be used to create and display file in Linux.

Q:125 What layer protocol is responsible for user and the application program support such as passwords, resource sharing, file transfer and network management?
§  Layer 4 protocols
§  Layer 5 protocols
§  Layer 6 protocols
§  Layer 7 protocols
§  None of the above
Ans: The ‘Layer 7 Protocol‘ is responsible for user and the application program support such as passwords, resource sharing, file transfer and network management.


1 Comments

  1. Thank you for sharing. this is really very helpful.

    ReplyDelete
Previous Post Next Post