Interview Questions Linux
This article provides basic Linux interview questions with
answers.
What
command do you use to format a partition with a file system?
You could use mkfs command to
format partition with file system.
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
Which option in fdisk
will display the partition table?
In fidisk utility, the
"p" command will print the partition table.
To create a recurring
scheduled task, which Linux scheduling tool should you use?
The cron command allows you to
create recurring tasks
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
How will you
decompress the demo.tar.gz file?
To decompress use following
command
#tar -zxvf demo.tar.gz
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.
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
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.
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.
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.
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
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
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
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.
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.
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.
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.
How can you list all
running process?
Use ps -ef command to list all
running process.
#ps -ef
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
Which
log file keeps track of all user logins and logouts?
/var/log/wtmp log file keeps
track of all user logins and logouts.
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.
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.
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
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
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.
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.
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.
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.
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
No comments:
Post a Comment