Linux Interview Questions Answers
Linux Interview Questions Answers
/dev/psaux
16} tell me the name of device file for parallel port
(Printers).
/dev/lp0
17} what does /etc/X11/ directory contains?
The ext3 file system is an enhanced version of the ext2 file system.
The most important difference between Ext2 and Ext3 is that Ext3
supports journaling. After an unexpected power failure or system
crash (also called an unclean system shutdown), each mounted ext2
file system on the machine must be checked for consistency by the
e2fsck program. This is a time-consuming process and during this
time, any data on the volumes is unreachable. The journaling provided
by the ext3 file system means that this sort of file system check is no
longer necessary after an unclean system shutdown. The only time a
consistency check occurs using ext3 is in certain rare hardware failure
cases, such as hard drive failures. The time to recover an ext3 file
system after an unclean system shutdown does not depend on the size
of the file system or the number of files; rather, it depends on the size
of the journal used to maintain consistency. The default journal size
takes about a second to recover, depending on the speed of the
hardware.
# mkfs –j /dev/sda7
mdadm
37} Can we create software RAID during Linux installation?
Firstly disable the swap file by “swapoff” command. Remove Swap file
entry from /etc/fstab file. Now remove the swap file by “rm”
command.
43} What can we do with “parted” command or utility? –
View the existing partition table – Add partitions from free space or
additional hard drives – Change the size of existing partitions
44} How we will check free space on drive /dev/sda with parted
command? #parted /dev/sda
print
45} Can we resize the size of a partition?
LVM1 and LVM2 are the versions of LVM. LVM2 uses device mapper
driver contained in 2.6 kernel version. LVM 1 was included in the 2.4
series kernels.
50} What is Volume group (VG)?
The Volume Group is the highest level abstraction used within the
LVM. It gathers together a collection of Logical Volumes and Physical
Volumes into one administrative unit.
51} What is physical extent (PE)?
lvremove /dev/<vgname>/<lvname>
61} Which command is used to create LVM Snapshot? vcreate
–size <size> -s -n <snapshotname> <lvname>
The lvcreate command is used to create a new logical volume, meaning
there must be free physical extents in the logical volume group to
create a snapshot. The -s option means that the LV is a snapshot,
<snapshotname> is the name of the new LV created, and <lvname> is
the name of the LV from which to create the snapshot.
62} Is there any relation between modprobe.conf file and
network devices?
The log files for the CUPS printing system are located in the
/var/log/cups/ directory.
67} What is YUM?
YUM stands for Yellow dog Updater, Modified because it is based on
YUP, the Yellow dog Updater. Where does the name Yellow dog come
from? Yellow Dog is a version of Linux for the Power Architecture
hardware and is RPM-based, just like Red Hat Enterprise Linux and
Fedora. YUP, and later YUM, were written by the Linux community as
a way to maintain an RPM-based system.
68} What are the advantages of YUM?
There are 7 run levels, with each having its own properties.
– 0: Halt the system –
1: Single-user mode
2: Not used –
6: Reboot
73} Which configuration file is required to change the Run
Level of Server or system?
/etc/inittab
To change the default run level, modify this line.
id:5:initdefault:
74} Explain architectures required for RPMs?
rpm –Va
83} How to verify the signature of an rpm?
rpm -K test-1.0-1.i386.rpm
84} How to list PCI Devices on your server or System?
use “lspci” command.
85} What is the role of “Kudzu”?
The Kudzu program runs each time the system boots and performs a
hardware probe. If new hardware is found, Kudzu attempts to map it
to a kernel module. If successful, the information is saved, and the
device is configured.
87} How to Enable ACLs for /home partition?
getfacl test_file
89} How to remove an ACL?
# passwd <username> -l
This might be useful in the situation where you don’t want to
permanently remove the user, but you just want it disabled and no
longer able to use the system. The user will still receive emails for
example, but he will not be able to login and check them out.
To re-enable the account ,just use below command
16
# passwd <username> -u
92} How to detect CPU architecture/bitmode (32-bit or 64-
bit) for Linux ?
# cat /proc/cpuinfo | grep flags
you will find one of them with name “tm(transparent mode)” or
“rm(real mode)” or “lm(long mode)” 1. rm tells ,it is a 16 bit processor
2. tm tells, it is a 32 bit processor 3. lm tells, it is a 64 bit processor
93} What is the difference between SSH and Telnet ?
The Primary difference between SSH and Telnet is of security i.e in ssh
data transfer between the systems is in encrypted form so it is difficult
for the hackers to understand what is going on network.
In Telnet data transfer between the systems is in plain text.
SSH uses a public key for authentication while Telnet does not use any
authentication.
Due to the security measures that were necessary for SSH to be used in
public networks, each packet contains less data to make room for the
data of the security mechanisms. In order to transmit the same
amount of data, you would need to take-up a lot more bandwidth. This
is called overhead..
SSH adds a bit more overhead to the bandwidth compared to Telnet.
An LVM snapshot is an exact copy of an LVM partition that has all the
data from the LVM volume from the time the snapshot was created.
The big advantage of LVM snapshots is that they can be used to greatly
reduce the amount of time that your services/databases are down
during backups because a snapshot is usually created in fractions of a
second. After the snapshot has been created, you can back up the
snapshot while your services and databases are in normal operation.
98} How to verify the signature of an rpm ?
rpm -K test-1.0-1.i386.rpm
99} What is the meaning of Hard & soft mount option in NFS
server ?
Hard mount – If the NFS file system is hard mounted, the NFS
daemons will try repeatedly to contact the server. The NFS daemon
retries will not time out, will affect system performance, and you
cannot interrupt them
Soft mount – If the NFS file system is soft mounted, NFS will try
repeatedly to contact the server until either:
A connection is established
The NFS retry threshold is met
The nfstimeout value is reached
100} What is an inode ?
An inode is a data structure on a traditional Unix-style file system such
as UFS. An inode stores basic information about a regular file,
directory, or other file system object.
When a file system is created, data structures that contain
information about files are created. Each file has an inode and is
identified by an inode number (often “i-number” or even shorter,
“ino”) in the file system where it resides. Inodes store information on
files such as user and group ownership, access mode (read, write,
execute permissions)
and type of file. There is a fixed number of inodes, which indicates
the maximum number of files each filesystem can hold.
udev is the device manager for the Linux 2.6 kernel series. Primarily, it
manages device nodes in /dev. It is the successor of devfs and hotplug,
which means that it handles the /dev directory and all user space
actions when adding/removing devices, including firmware load.
20
102} What is the difference between ext2 and ext3 file
systems?
The ext3 file system is an enhanced version of the ext2
file system.The most important difference between Ext2 and Ext3 is
that Ext3 supports journaling. After an unexpected power failure or
system crash (also called an unclean system shutdown), each mounted
ext2 file system on the machine must be checked for consistency by
the e2fsck program. This is a time-consuming process and during this
time, any data on the volumes is unreachable. The journaling provided
by the ext3 file system means that this sort of file system check is no
longer necessary after an unclean system shutdown. The only time a
consistency check occurs using ext3 is in certain rare hardware failure
cases, such as hard drive failures. The time to recover an ext3 file
system after an unclean system shutdown does not depend on the size
of the file system or the number of files; rather, it depends on the size
of the journal used to maintain consistency. The default journal size
takes about a second to recover, depending on the speed of the
hardware.
All devices are represented by files called special files that are located
in /dev directory.
104} What is Super Block in Linux/Unix ?
Each file system is different and they have type like ext2, ext3
etc.Further eachfile system has size like 5 GB, 10 GB and status such
as mount status. In short each file system has a superblock, which
contains informationabout file system such as:
File system type
Size
Status
Information about other metadata structures
If this information lost, you are in trouble (data loss) so Linux
maintains multiple redundant copies of thesuperblock in every file
system. This is very important in many emergency situation, for
example you can usebackup copies to restore damaged primary super
block.
Following command displays primary and backup superblock location
on /dev/sda3:
# dumpe2fs /dev/hda3 | grep -i superblock
Q: – What is the load average of the server and What is an
acceptable Server Load Average ?
The load average is the sum of the run queue length and the number of
jobs currently running on the CPUs. The three load-average values in
the first line of top output are the 1-minute, 5-minute and 15-minute
average. (These values also are displayed by other commands, such as
uptime, not only top.)
There are a few factors involved to determine the server average load.
If your server (s) use dual processors, the acceptable Server Load
Average is 2.00. This load is considered “optimal”.
Yes, you can have two different apache servers on one server, but they
can’t listen to the same port at the same time.Normally apache listens
to port 80 which is the default HTTP port. The second apache version
should listen to another port with the Listen option in httpd.conf, for
example to port 81.
For testing a new apache version before moving your sites from one
version to another, this might be a good option.You just
type http://www.example.com:81 in the browser window and you will
be connected to the second apache instance.
107} 22.cmd to clear cache
echo 3 > /proc/sys/vm/drop_caches
108} 24.how to redirect standard output and standard error
Cat kapil >> /tmp/kapil
110} 19.which file contain ssh log
NFS SERVER
1} Explain this entry /shared
192.168.1.0/255.255.255.0(sync,rw)
allows all systems with 192.168.1.* IP addresses read-write access to
the /shared/ directory:
Treat remote root user as local root. Do not map requests from root to
the anony- mous user and group ID.
6} What is NFS ?
NFS stands for Network File System. NFS was originally developed by
Sun Microsystems in the 1980’s. NFS allows remote hosts to mount
file systems over a network and interact with those file systems as
though they are mounted locally. This enables system administrators
to consolidate resources onto centralized servers on the network.
7} Which NFS versions are available ?
nfs 2 default 8kb transfer rate,it did not check the authentication at
the time connection.client wants to access unauthorized file it shows
error messages like “write error”,”read error” nfs 3 32kb transfer rate.
It check at the time connection- ACL Support
9} Can we grant access by Username and password for nfs
share?
No, access is granted only for IP address.
Treat all client users as anonymous users. Map all user and group IDs
to the anonymous user and group ID.
All requests from the user root are translated or mapped as if they
came from the user anonymous (default).
It will flush everything out of the kernels export table. Any clients that
are active will get new entries added by mountd when they make their
next request.
The nfsstat command displays the statistics about NFS client and NFS
server activity.
if a file request fails, the NFS client will report an error to the process
on the client machine requesting the file access. if it cannot be satisfied
(for example, the server is down), then it quits. This is called soft
mounting.
If a file request fails, the NFS client will report an error to the process
on the client machine requesting the file access. if it cannot be
satisfied, then it will not quit until the request is satisfied. This is
called Hard mounting.
To deny specific users access to the FTP server, add their usernames to
the /etc/vsftpd/ ftpusers file. By default, system users such as root and
nobody are included in this list.
FTP uses two ports, 20 and 21. By default, the FTP server listens for
requests on port 21. After a connection is established, the client sends
commands to the server on port 21. However, port 20 is used when the
server sends data back to the client.
7} what is FTP?
FTP stands for File Transfer Protocol. An FTP server allows clients to
connect to it either anonymously or with a username and password
combination. After successful authentication, files can be transferred
back and forth between the server and client. The files are neither
encrypted nor compressed.
14} I want to copy multiple files with out prompting for any
info, how can I do that one?
ftp -i ftpserver
15} Local users cannot log in. How to resolve this
issue? Check “local_enable=YES” in your /etc/vsftpd/vsftpd. conf to
allow local users to log in.
Use TCP_WRAPPERS
18} Does vsftpd support IPv6?
Yes
DNS SERVER
2} What is BIND?
BIND stands for Berkeley Internet Name Domain which is the most
commonly used Domain Name System (DNS) server on the Internet.
BIND 9
Root name server is an authoritative name server for the root domain
(for the dot). Each root name server is a primary server, which
differentiates it from other name servers.
Stealth name server is a secret server. This type of name server is not
published anywhere. It is only known to the servers that have its IP
address statically listed in their configuration. It is an authoritative
server. It acquires the data for the zone with the help of a zone
transfer. It can be the main server for the zone. Stealth servers can be
used as a local backup if the local servers are unavailable.
The Start of Authority (SOA) record determines the name server that
is an authoritative source of information for the particular domain.
There is always only one SOA record in the file, and it is placed at the
beginning of the file of authoritative resource records.
HINFO and TXT records are for information only. An HINFO record
has two items in its data part. The first item is information about
hardware, and the second one is information about software. A TXT
record contains a general data string in its data part.
Example : test.com IN SOA … … mail IN A 192.1.1.2 IN HINFO
My_Server UNIX IN TXT my server …
19} what are “MX Records”?
No. The native NT4 SAM replication protocols have not yet been fully
implemented.
12} What TCP and UDP ports required for NetBIOS over
TCP/IP use?
The NBT name service uses port 137/udp, the NBT session service
uses port 139/tcp, and the NBT datagram service uses port 138/udp.
13} How SMB protocol works?
There will be three stages in creating an SMB connection between a
client and a specific share on a server.
The first stage in connecting to an SMB share is to negotiate the SMB
protocol dialect to use. In the request packet, the client sends a text
listing of all the SMB dialects that it understands. The server selects
the most advanced protocol that it knows and responds to the client,
specifying the protocol number from the list. At this point, the client
and server have agreed that SMB commands can be used for the
remainder of the conversation.
The second stage is to create a session connection between the client
and server. To do this, the client issues a session setup request, which
includes a sername and some proof of validity, such as a password.
The server attempts to validate requesting user. If successful, the
server then returns a session UID to client. This UID is unique for
each session and has no relation to the server internal representation
of users.
The third stage before access to files on a remote share is allowed is for
the client to make a successful tree connection to the shared resource.
The client sends to the server a tree connect request, which includes
the UID previously issued by the server. At this stage the server
verifies that the authenticated user is authorized to access the
requested resource. If the user has sufficient privileges to access the
share, the client is issued a tree connection ID (TID). The TID is used
in all requests to access files contained in the resource to which the
TID refers. In this way SMB protocol works.
It will define the group id to be used for all file access in the place of
the user’s primary group.
Submitted By:-Varun Email-ID: [email protected]
: – Explain “force user” parameter used in smb.conf?
A list of users and/or groups that should be given write access even if
the read only parameter has been enabled.
30} My clients are getting the error message that the Disk is
Full when trying to print to my Samba server, but there is
plenty of space. What is the problem?
If smbd is unable to write the spooled file to the directory defined by
the path parameter for a printer if the write permission were denied,
for example it would respond to the client with the message, Disk is
Full. Samba will also return this error message if the amount of free
disk space in the spool directory has fallen below the value specified by
the min print space parameter.
SENMAIL SERVER
1} How to start sendmail server ?
List of users that can send email as other users without a warning
including system users such as apache for the Apache HTTP Server.
An MUA (Mail User Agent) with access to the mailbox file, directly or
through a network file
system, can read messages from the disk and display them for the
user. This is generally a console or webmail application running on the
server.
define(`confMAX_MESSAGE_SIZE’,`52428800′)dnl
or If you are using a PHP based webmail application like SquirrelMail,
you can adjust the max file size in php.ini file.
vi php.ini
post_max_size = 50M upload_max_filesize = 50M memory_limit =
64M
QMAIL SERVER
3} What is procmail?
7} What is QMAIL?
8} What is Courier-imap?
/var/qmail/control
Domains for which this host should accept mail via SMTP. This
generally contains all of the domains in locals, as well as any virtual
domains and any domains for which this host is a backup mail server.
If rcpthosts does not exist, qmail accepts and delivers mail for any
domain, a severe misconfiguration known as an “open relay,” which
will be hijacked by spammers. Be sure your rcpthosts file exists before
starting qmail. If you haven’t defined any virtual domains, just copy
locals to rcpthosts.
qscand user
Your server is not set up to allow for setuid execution of scripts. The
easiest way to fix this is to install the “perl-suidperl” package. If you’re
running Redhat, you can download the latest RPM of perl-suidperl.
POSTFIX SERVER
2}What is LMTP ?
6} what is qmgr?
postfix 2.6
8} What are the important files for postfix server ?
/etc/postfix/main.cf /etc/postfix/access /etc/postfix/aliases
/var/log/maillog
10} Explain the working of local mail submission for postfix?
When a local email message enters the postfix system. Local messages
are deposited into the maildrop directory of the Postfix queue by the
postdrop command, usually through the sendmail compatibility
program. The pickup daemon reads the message from the queue and
feeds it to the cleanup daemon. The cleanup daemon processes all
inbound mail and notifies the queue manager after it has placed the
cleaned-up message into the incoming queue. The queue manager
then invokes the appropriate delivery agent to send the message to its
next hop or ultimate destination.
Using SMTP AUTH we can make it possible for clients, colleagues, and
ourselves to relay messages from everywhere in the world using only
one (our) SMTP server.
– Being a mobile user, we don’t have to deal with the hassle to find a
SMTP server that permits us to relay.
– We can make use of scripts and daemons that run on our server and
provide services that we need e.g. server-side virus scanning.
# postconf -e myhostname=mail.example.com
# postsuper -d ALL
# postconf -m
nis regexp environ mysql btree unix hash
APACHE SERVER
6} What is DocumentRoot ?
httpd.conf
9}On which version of apache you have worked ?
httpd-2.2.3
It will give you more information in the error log in order to debug a
problem.
No
16} Can you record all the cookies sent to your server by
clients in Web Server logs?
Yes
Use CustomLog and the rotatelogs programs
Add following line in httpd.conf file. CustomLog “| /path/to/rotatelogs
/path/to/logs/access_log.%Y-%m-%d 86400” combined
18} What we can do to find out how people are reaching your
site?
19} If you have only one IP address, but you want to host two
web sites on your server. What will you do?
20} If you have to more than one URL map to the same
directory but you don’t have multiple Alias directives. What
you will do?
ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html
Yes, you can have two different apache servers on one server, but they
can’t listen to the same port at the same time.Normally apache listens
to port 80 which is the default HTTP port. The second apache version
should listen to another port with the Listen option in httpd.conf, for
example to port 81.
LDAP SERVER
Yes, Following are some GUI based tools for LDAP – GQ – Java LDAP
Browser/Editor – Softerra LDAP Browser
The LDAP Interchange Format (LDIF) is a standard text file format for
storing LDAP configuration information and directory contents. LDIF
files are often used to import new data into your directory or make
changes to existing data.
5} Name the object class types?
7} What is LDAP?
JNDI has classes provided by SUN that will help ur appln interact with
and LDAP server. JNDI appln work similarly to JDBC applns once and
be free to use ‘drivers’ from different vendors. SUN provides the
“driver” that will help interact with the LDAP server. Sun also provides
“drivers” for other naming services (like CORBA).
The modulepath directive provides the full path to the directory where
the modules (the compiled libraries) are stored.
ldappasswd
18} How you will verify LDAP configuration file?
ldap.conf
This directive will give the information about the amount of time the
client will wait for the server to respond.
24} Which web based tool you have used for LDAP?
phpLDAPadmin
SQUID SERVER
By default proxy server runs on 3128 port. yes we can change proxy
server port.
vi /etc/squid/squid.conf http_port 3128
Make a file
vi /etc/squid/bad_domains
.xxx.com .abcd.com .sexy.com
Now make following changes in Squid.conf file
acl BAD_DOMAINS dstdom_regex -i “/etc/squid/bad_domains”
http_access deny BAD_DOMAINS
7} What is Squid ?
SQUID is a webcache and proxy server for Linux and UNIX. Users
configure their web browsers to use the Squid proxy server instead of
going to the web directly. The Squid server then checks its web cache
for the web information requested by the user. It will return any
matching information that finds in its cache, and if not, it will go to the
web to find it on behalf of the user. Once it finds the information, it
will populate its cache with it and also forward it to the user’s web
browser.
/var/spool/squid
MYSQL SERVER
No. MySQL permits only one primary key per table, but there may be a
number of unique keys. Both unique keys and primary keys can speed
up the selecting of data with a WHERE clause, but a column should be
chosen as the primary key if this is the column by which you want to
join the table with other tables.
This file is a complete replica of your database in SQL format. You can
do a lot of things with this data. You could re-create your database in
Microsoft SQL Server or Sybase by simply cutting and pasting the
contents of the file. You could also restore your database by using the
dump file and the batching ability of the mysql program.
First log in to the system as the same person who is running the
mysqld daemon (probably root). Kill the process, using the kill
command. Restart MySQL with the following arguments: bin/mysqld
Skip-grant USE mysql; UPDATE user SET password =
password(‘newpassword’) WHERE User = ‘root’; Exit bin/mysqladmin
reload
The next time you log in, you will use your new password
MySQL uses files to store data. These files are under the
data/databasename directory, where databasename is the name of the
database. There are three file types: .ISM, .FRM, and .ISD. The .FRM
file contain the table schema. The .ISD is the file that actually holds
the data. The .ISM file is the file that provides quick access between
the two of them.