SlideShare a Scribd company logo
Linux OR Unix Interview Questions
1) What is GRUB
Ans GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader,
which was originally designed and implemented by Erich Stefan Boleyn.
Briefly, a boot loader is the first software program that runs when a computer starts. It is
responsible for loading and transferring control to the operating system kernel software
(such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating
system (e.g. GNU)
2) Explain Linux Boot Process
Ans http://www.thegeekstuff.com/2011/02/linux-boot-process/
3) Which files are called for user profile by default when a user gets login
Ans $HOME/.bash_profile, $HOME/.bash_bashrc
4) Which file needs to update if srequired to change default runlevel 5 to 3
Ans File is /etc/inittab and required to change below lines:
id:5:initdefault: to id:3:initdefault:
5) What command used for showing user info like Login Name, Canonical Name, Home
Directory,Shell etc..
Ans FINGER command can be used i.g; finger username
6) What is inode number
Ans An inode is a data structure on a traditional Unix-style file system such as UFS or ext3. An
inode stores basic information about a regular file, directory, or other file system object
iNode number also called as index number, it consists following attributes:
File type (executable, block special etc)
Permissions (read, write etc)
Owner
Group
File Size
File access, change and modification time (remember UNIX or Linux never stores file
creation
time, this is favorite question asked in UNIX/Linux sys admin job interview)
File deletion time
Number of links (soft/hard)
Extended attribute such as append only or no one can delete file including root user
(immutability)
Access Control List (ACLs)
Following command will be used to show inodes of file and folders:
ls -i
Following command will show complete info about any file or folders with inode number
stat file/folder
Files/Folders can also be deleted using inode numbers with following command:
find out the inode number using 'ls -il' command then run below command
find . -inum inode_number -exec rm -i {} ;
7) How can we increase disk read performance in single command
Ans blockdev command
This is sample output - yours may be different.
# Before test
$ blockdev --getra /dev/sdb
256
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2549+1 records in
2549+1 records out
668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s
real 0m6.845s
user 0m0.004s
sys 0m0.865s
# After test
$ blockdev --setra 1024 /dev/sdb
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2435+1 records in
2435+1 records out
638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s
real 0m0.370s
user 0m0.001s
sys 0m0.370s
8) .... command to change user password expiration time
Ans CHAGE
9) Command used to lock user password
Ans usermod -L username
10) How many default number of Shells available and what are their names?
Ans SH, BASH, CSH, TCSH, NOLOGIN, KSH
11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not
while
adding user
Ans /etc/login.defs
12) ...... command used for changing authentication of linux system to
LDAP/NIS/SMB/KERBOS
Ans authconfig
13) ...... command used for changing the attributes of any file
Ans chattr
14) What is the path of network (ethX) configuration files
Ans /etc/sysconfig/network-scripts/ethX
15) How can we change speed and make full duplex settings for eth0
Ans We can do this with below given 2 methods:
ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
16) File which stores the DNS configuration at client side
Ans /etc/resolve.conf
17) Main configuration file and command used for exporting NFS directories and it's
deamons
Ans /etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status
18) What is command to check ports running/used over local machine
Ans netstat -antp
19) What is the command to check open ports at remote machine
Ans nmap
20) What is the difference between soft and hard links
Ans Soft Links => 1) Soft link files will have different inode numbers then source file
2) If original file deleted then soft link file be of no use
3) Soft links are not updated
4) Can create links between directories
5) Can cross file system boundaries
Hard Links => 1) Hard links will have the same inode number as source file
2) Hard links can not link directories
3) Can not cross file system boundaries
4) Hard links always refers to the source, even if moved or removed
21) How to setup never expired user password
Ans chage -E never username
22) Restricting insertion into file if full permission are assigned to all
Ans chattr +i filename
23) Display or Kill all processes which are accessing any folder/file
Ans Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder
24) Kill any user's all processes
Ans killall -u username
25) How can we have daily system analysis and reports over mail
Ans Use logwatch
26) How can we rotate logs using logrotate without performing any operation like move
and gzip'ng over original file and then creating new file (which is very lengthy process)
Ans We can use "logrotate"'s "copytruncate" option which will simply copy original file and
truncate original file :)
27) Command to collect detailed information about the hardware and setup of your system
Ans dmidecode , sysreport
28) Command to check PCI devices vendor or version
Ans lspci
29) What is the difference between cron and anacron
Ans Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
3) Cron expects system to be running 24 x 7. If a job is scheduled, and
system is down during that time, job is not executed
4) Ideal for servers
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
1) Minimum granularity is only in days
2) Anacron can be used only by super user ( but there are workarounds to
make it usable by normal user )
3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
and system is down during that time, it start the jobs when the system
comes back up.
4) Ideal for desktops and laptops
5) Use anacron when a job has to be executed irrespective of hour and
minute
30) Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps
Ans SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS
143/993
31) How to setup ACLs in following case:
1) Create a file FILE1 and this should be read,write,executable for all user but Read
only for user USER1
2) Copy FILE1 ACLs to FILE2 ACL
3) Delete a USER1's rule for FILE1 which were setup in step 1)
Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1
2) getfacl FILE1 | setfacl --set-file=- FILE2
3) setfacl -x u:USER1 FILE1
32) How to make USB bootable?
Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB
dd if=efidisk.img of=/dev/usb (usb device name)
33) How can we check disk/device status/failure/errors using smartctl utility?
Ans Try following to check:
Enable/Disable SMART on device/disk : smartctl -s on /dev/sda
Check device SMART health : smartctl -H /dev/sda
Check device SMART capabilities : smartctl -c /dev/sda
Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda
Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda
Show device log [TYPE : error, selftest, selective, directory,background,
scttemp[sts,hist]] : smartctl -l TYPE /dev/sda
Run test on device [TEST: offline short long conveyance select,M-N pending,N
afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda
34) What is the difference between ext2 vs ext3 vs ext4?
Ans http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/
35) Disable ping to avoid network/ICMP flood
Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1
Then "sysctl -p"
or
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
36) What is SYN Flood, ICMP Flood
Ans SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a
fake/forged sender address. Each of these packets is handled like a connection request, causing the
server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge),
and
waiting for a packet in response from the sender address(response to the ACK Packet). However,
because the sender address is forged, the response never comes. These half-open connections
saturate the number of available connections the server is able to make, keeping it from responding
to
legitimate requests until after the attack ends
ICMP Flood : There are three types of ICMP Flood :
1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack
2) Ping Flood : http://en.wikipedia.org/wiki/Ping_flood
3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death
37) What is the difference between Unix vs Linux Kernels?
Ans Please find below given link :
http://www.thegeekstuff.com/2012/01/linux-unix-kernel/
38) How to setup Password less remote login/ssh?
Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys
Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys
Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod
0600 ~/.ssh/authorized_keys"
Now try to login from local system to remote_server "ssh root@remote_server"
39) Command to see default kernel image file
Ans "grubby --default-kernel"
40) How to create lvm mirror
Ans lvcreate -L 50G -m1 -n LVMmirror vg0
41) Command to check last runlevel
Ans who -r
42) What do you mean by File System?
Ans File System is a method to store and organize files and directories on disk. A file system can have
different formats called file system types. These formats determine how the information is stored as files
and directories.
43) What is the requirement of udev daemon?
Ans Create and remove device nodes or files in /dev/ directory
44) What are block and character devices?
Ans Both the devices are present in /dev directory
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk (sda, sdb, sdc etc....)
Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers (tty{0,1,2,3......})
45) How to Convert ext2 to ext3 File System?
Ans tune2fs -j /dev/{device-name}
46) File required to modify for setting up kernel parameters permanent
Ans /etc/sysctl.conf
47) Commands used to install, list and remove modules from kernel
Ans Installing/adding a module:
insmod mod_name
modprobe mod_name
List installed modules : lsmod
Removing a module : modprobe -r mod_name
48) How to create swap using a file and delete swap
Ans Adding swap :
dd if=/dev/zero of=/opt/myswap bs=1024 count=4
mkswap /opt/myswap
swapon -a
For adding this myswap at boot time, add following in /etc/fstab file:
/opt/myswap swap swap defaults 0 0
Deleting Swap :
Run "swapoff /opt/myswap" command
Remove the entry from /etc/fstab file
Remove /opt/myswap file (using rm command)
49) What vmstat show
Ans vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays
summary information about operating system memory, processes, interrupts, paging and
block I/O
50) What is tmpfs File System
Ans Reference : http://en.wikipedia.org/wiki/Tmpfs
tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is
intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage
device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file
system.
Everything stored in tmpfs is temporary in the sense that no files will be created on the hard drive;
however, swap space is used as backing store in case of low memory situations. On reboot, everything in
tmpfs will be lost.
The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped
out to swap space.
51) What is the difference between screen and script commands?
Ans Screen is an screen manager with VT100/ANSI terminal emulation and used to take GNU screen
session remotely or locally and while Script make typescript of terminal session
Screen : needs to be detached, should not be exited to access remotely/locally
Script : creates a file and store all the terminal output to this file
52) How can we check which process is assigned to which processor?
Ans Run "ps -elFL" and find out the PSR column which is showing the processor number to the process
53) How can we check vendor, version, release date, size, package information etc... of any
installed rpm?
Ans) rpm -qi package-name , for example:
rpm -qi ypbind-1.19-12.el5
Linux Interview Questions : L1 &L2
1) What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix
processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
2) What Happens when you execute a program?
When you execute a program on your UNIX system, the system creates a special
environment for that program. This environment contains everything needed for the
system to run the program as if no other program were running on the system. Each
process has process context, which is everything that is unique about the state of the
program you are currently running. Every time you execute a program the UNIX system
does a fork, which performs a series of operations to create a process context and then
execute your program in that context. The steps include the following: Allocate a slot in
the process table, a list of currently running programs kept by UNIX. Assign a unique
process identifier (PID) to the process. iCopy the context of the parent, the process that
requested the spawning of the new process. Return the new PID to the parent process.
This enables the parent process to examine or control the process directly. After the
fork is complete, UNIX runs your program.
3) What Happens when you execute a command?
When you enter ‘ls’ command to look at the contents of your current working
directory, UNIX does a series of things to create an environment for ls and the run it:
The shell has UNIX perform a fork. This creates a new process that the shell will use to
run the ls program. The shell has UNIX perform an exec of the ls program. This
replaces the shell program and data with the program and data for ls and then starts
running that new program. The ls program is loaded into the new process context,
replacing the text and data of the shell. The ls program performs its task, listing the
contents of the current directory.
4) What is a Daemon?
A daemon is a process that detaches itself from the terminal and runs,
disconnected, in the background, waiting for requests and responding to them. It can
also be defined as the background process that does not belong to a terminal session.
Many system functions are commonly performed by daemons, including
the sendmail daemon, which handles mail, and the NNTP daemon, which handles
USENET news. Many other daemons may exist. Some of the most
common daemons are: init: Takes over the basic running of the system when the kernel
has finished the boot process. inetd: Responsible for starting network services that do
not have their own stand-alone daemons. For example, inetd usually takes care of
incoming rlogin, telnet, and ftp connections. cron: Responsible for running repetitive
tasks on a regular schedule.
5) What is ‘ps’ command for?
The ps command prints the process status for some or all of the running
processes. The information given are the process identification number (PID),the
amount of time that the process has taken to execute so far etc.
6) How would you kill a process?
The kill command takes the PID as one argument; this identifies which process to
terminate. The PID of a process can be got using ‘ps’ command.
7) What is an advantage of executing a process in background?
The most common reason to put a process in the background is to allow you to do
something else interactively without waiting for the process to complete. At the end of
the command you add the special background symbol, &. This symbol tells your shell to
execute the given command in the background. Example: cp *.* ../backup& (cp is for
copy)
8) How do you execute one program from within another?
The system calls used for low-level process creation are execlp() and execvp().
The execlp call overlays the existing program with the new one , runs that and exits.
The original program gets back control only when an error occurs.
execlp(path,file_name,arguments..); //last argument must be NULL A variant of execlp
called execvp is used when the number of arguments is not known in advance.
execvp(path,argument_array); //argument array should be terminated by NULL
9) What is IPC? What are the various schemes available?
The term IPC (Inter-Process Communication) describes various ways by which
different process running on some operating system communicate between each other.
Various schemes available are as follows: Pipes: One-way communication scheme
through which different process can communicate. The problem is that the two
processes should have a common ancestor (parent-child relationship). However this
problem was fixed with the introduction of named-pipes (FIFO). Message Queues :
Message queues can be used between related and unrelated processes running on a
machine. Shared Memory: This is the fastest of all IPC schemes. The memory to be
shared is mapped into the address space of the processes (that are sharing). The
speed achieved is attributed to the fact that there is no kernel involvement. But this
scheme needs synchronization. Various forms of synchronisation are mutexes,
condition-variables, read-write locks, record-locks, and semaphores.
10) What is the difference between Swapping and Paging?
Swapping : Whole process is moved from the swap device to the main
memory for execution. Process size must be less than or equal to the available main
memory. It is easier to implementation and overhead to the system. Swapping systems
does not handle the memory more flexibly as compared to the paging systems.
Paging : Only the required memory pages are moved to main memory from the
swap device for execution. Process size does not matter. Gives the concept of the
virtual memory. It provides greater flexibility in mapping the virtual address space into
the physical memory of the machine. Allows more number of processes to fit in the main
memory simultaneously. Allows the greater process size than the available physical
memory. Demand paging systems handle the memory more flexibly.
11) What is major difference between the Historic Unix and the new BSD release of
Unix System V in terms of Memory Management?
Historic Unix uses Swapping – entire process is transferred to the main memory
from the swap device, whereas the
Unix System V uses Demand Paging – only the part of the process is moved to
the main memory. Historic Unix uses one Swap Device and Unix System V allow
multiple Swap Devices.
12) What is the main goal of the Memory Management?
It decides which process should reside in the main memory, Manages the parts of
the virtual address space of a process which is non-core resident, Monitors the
available main memory and periodically write the processes into the swap device to
provide more processes fit in the main memory simultaneously.
13) What is a Map?
A Map is an Array, which contains the addresses of the free space in the swap
device that are allocatable resources, and the number of the resource units available
there. This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map
contains one entry – address (block offset from the starting of the swap area) and the
total number of resources. Kernel treats each unit of Map as a group of disk blocks. On
the allocation and freeing of the resources Kernel updates the Map for accurate
information.
14) What scheme does the Kernel in Unix System V follow while choosing a swap
device among the multiple swap devices?
Kernel follows Round Robin scheme choosing a swap device among the multiple
swap devices in Unix System V.
15) What is a Region?
A Region is a continuous area of a process’s address space (such as text, data
and stack). The kernel in a ‘Region Table’ that is local to the process maintains region.
Regions are sharable among the process.
16) What are the events done by the Kernel after a process is being swapped out
from the main memory?
When Kernel swaps the process out of the primary memory, it performs the
following: Kernel decrements the Reference Count of each region of the process. If the
reference count becomes zero, swaps the region out of the main memory, Kernel
allocates the space for the swapping process in the swap device, Kernel locks the other
swapping process while the current swapping operation is going on, The Kernel saves
the swap address of the region in the region table.
17) Is the Process before and after the swap are the same? Give reason.
Process before swapping is residing in the primary memory in its original form.
The regions (text, data and stack) may not be occupied fully by the process, there may
be few empty slots in any of the regions and while swapping Kernel do not bother about
the empty slots while swapping the process out. After swapping the process resides in
the swap (secondary memory) device. The regions swapped out will be present but only
the occupied region slots but not the empty slots that were present before assigning.
While swapping the process once again into the main memory, the Kernel referring to
the Process Memory Map, it assigns the main memory accordingly taking care of the
empty slots in the regions.
18) What do you mean by u-area (user area) or u-block?
This contains the private data that is manipulated only by the Kernel. This is local
to the Process, i.e. each process is allocated a u-area.
19) What are the entities that are swapped out of the main memory while swapping
the process out of the main memory?
All memory space occupied by the process, process’s u-area, and Kernel stack
are swapped out, theoretically. Practically, if the process’s u-area contains the Address
Translation Tables for the process then Kernel implementations do not swap the u-area.
20) What is Fork swap?
fork() is a system call to create a child process. When the parent process calls
fork() system call, the child process is created and if there is short of memory then the
child process is sent to the read-to-run state in the swap device, and return to the user
state without swapping the parent process. When the memory will be available the child
process will be swapped into the main memory.
21) What is Expansion swap?
At the time when any process requires more memory than it is currently allocated,
the Kernel performs Expansion swap. To do this Kernel reserves enough space in the
swap device. Then the address translation mapping is adjusted for the new virtual
address space but the physical memory is not allocated. At last Kernel swaps the
process into the assigned space in the swap device. Later when the Kernel swaps the
process into the main memory this assigns memory according to the new address
translation mapping.
22) How the Swapper works?
The swapper is the only process that swaps the processes. The Swapper
operates only in the Kernel mode and it does not uses System calls instead it uses
internal Kernel functions for swapping. It is the archetype of all kernel process.
23) Who owns the data dictionary?
The SYS user owns the data dictionary. The SYS and SYSTEM users are created
when the database is created.
24) You routinely compress old log files. You now need to examine a log from two
months ago. In order to view its contents without first having to decompress it ?
zcat -> The zcat utility allows you to examine the contents of a compressed file
much the same way that cat displays a file.
25) You suspect that you have two commands with the same name as the command
is not producing the expected results. What command can you use to determine
the location of the command being run?
which -> The which command searches your path until it finds a command that
matches the command you are looking for and displays its full path.
26) You locate a command in the /bin directory but do not know what it does. What
command can you use to determine its purpose.
whatis ->The whatis command displays a summary line from the man page for the
specified command.
27) When you issue the command ls -l, the first character of the resulting display
represents the file’s?
type ->The first character of the permission block designates the type of file that is
being displayed.
28) What utility can you use to show a dynamic listing of running processes?
top -> The top utility shows a listing of all running processes that is dynamically
updated.
29) Where is standard output usually directed?
To the screen or display.
30) What daemon is responsible for tracking events on your system?
syslogd ->The syslogd daemon is responsible for tracking system information
and saving it to specified log files
Basic Linux Interview Questions :
What is Linux and why is it so popular?
Answer - Linux is an operating system that uses UNIX like Operating system.......
Unix interview questions with answers?
Answer -Discuss the mount and unmount system calls, What are the process states in Unix?, What is
use of sed command?, What is 'inode'?,What are the Unix system calls for I/O?, How are devices
represented in UNIX?, Brief about the directory representation in UNIX ......
What is LILO?
Answer - LILO is Linux Loader is a boot loader for Linux. It is used to load Linux into the memory and start the
Operating system.......
What is the difference between home directory and working directory?
Answer - Home directory is the default working directory when a user logs in. On the other hand, working
directory is the user’s current directory.......
What is the difference between internal and external commands?
Answer - Internal commands are commands that are already loaded in the system. They can be
executed any time and are independent.......
Explain the difference between a static library and a dynamic library.
Answer - Static libraries are loaded when the program is compiled and dynamically-linked libraries are
loaded in while......
What is LD_LIBRARY_PATH?
Answer - LD_LIBRARY_PATH is an environment variable. It is used for debugging a new library or a non
standard library.......
What is the file server in Linux server?
Answer - File server is used for file sharing. It enables the processes required fro sharing.......
What is NFS? What is its purpose?
Answer - NFS is Network File system. It is a file system used for sharing of files over a
network.......
How do I send email with linux?
Answer - Email can be sent in Linux using the mail command. ......
Explain RPM (Red Hat Package Manager) features.
Answer - RPM is a package managing system (collection of tools to manage software packages).......
What is Kernel? Explain the task it performs.
Answer - Kernel is used in UNIX like systems and is considered to be the heart of the operating
system.......
What is Linux Shell? What is Shell Script?
Answer - Linux shell is a user interface used for executing the commands. Shell is a program the user......
What are Pipes? Explain use of pipes.
Answer - A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to
another.......
Explain trap command; shift Command, getopts command of linux.
Answer - Trap command: controls the action to be taken by the shell when a signal is received. ......
What Stateless Linux server? What feature it offers?
Answer - A stateless Linux server is a centralized server in which no state exists on the single
workstations. ......
What does nslookup do? Explain its two modes.
Answer - Nslookup is used to find details related to a Domain name server. Details like IP addresses of a
machine, MX records,......
What is Bash Shell?
Answer - Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination
of the C and Korn shell features. ......
Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump,
ntop
Answer - Network monitoring tools are used to monitor the network, systems present on the network,
traffic etc.......
How does the linux file system work?
Answer - Linux file structure is a tree like structure. It starts from the root directory, represented by '/', and
then expands into sub-directories.......
What are the process states in Linux?
Answer - Process states in Linux.......
What is a zombie?
Answer - Zombie is a process state when the child dies before the parent process. In this case the
structural information of the process is still in the process table.......
Explain each system calls used for process management in linux.
Answer - System calls used for Process management......
Which command is used to check the number of files and disk space used and
the each user’s defined quota?
repquota command is used to check the status of the user’s quota along with the disk space and number
of files used. This command gives a summary of the user’s quota that how much space and files are left
for the user. Every user has a defined quota in Linux. This is done mainly for the security, as some users
have only limited access to files. This provides a security to the files from unwanted access. The quota
can be given to a single user or to a group of users.
What is the name and path of the main system log?
By default the main system log is /var/log/messages. This file contains all the messages and the script
written by the user. By default all scripts are saved in this file. This is the standard system log file, which
contains messages from all system software, non-kernel boot issues, and messages that go to 'dmesg'.
dmesg is a system file that is written upon system boot.
How secured is Linux? Explain.
Security is the most important aspect of an operating system. Due to its unique authentication module,
Linux is considered as more secured than other operating systems. Linux consists of PAM. PAM is
Pluggable Authentication Modules. It provides a layer between applications and actual authentication
mechanism. It is a library of loadable modules which are called by the application for authentication. It
also allows the administrator to control when a user can log in. All PAM applications are configured in the
directory "/etc/pam.d" or in a file "/etc/pam.conf". PAM is controlled using the configuration file or the
configuration directory.
Can Linux computer be made a router so that several machines may share a
single Internet connection? How?
Yes a Linux machine can be made a router. This is called "IP Masquerade." IP Masquerade is a
networking function in Linux similar to the one-to-many (1: Many) NAT (Network Address Translation)
servers found in many commercial firewalls and network routers. The IP Masquerade feature allows other
"internal" computers connected to this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as
well. Linux IP Masquerading allows this functionality even if the internal computers do not have IP
addresses.
The IP masquerading can be done by the following steps:
1. The Linux PC must have an internet connection and a connection to LAN. Typically, the Linux PC has
two network interfaces-an Ethernet card for the LAN and a dial-up PPP connection to the
Internet (through an ISP).
2. All other systems on your LAN use the Linux PC as the default gateway for TCP/IP networking. Use
the same ISP-provided DNS addresses on all systems.
3. Enable IP forwarding in the kernel. By default the IP forwarding is not enabled. To ensure that IP
forwarding is enabled when you reboot your system, place this command in the /etc/rc.d/rc.local file.
4. Run /sbin/iptables-the IP packet filter administration program-to set up the rules that enable the Linux
PC tomasquerade for your LAN.
What is the minimum number of partitions you need to install Linux?
Minimum 2 partitions are needed for installing Linux. The one is / or root which contains all the files and
the other is swap. Linux file system is function specific which means that files and folders are organized
according to their functionality. For example, all executables are in one folder, all devices in another, all
libraries in another and so on. / or ‘root’ is the base of this file system. All the other folders are under this
one. / can be consider as C: .Swap is a partition that will be used as virtual memory. If there is no more
available RAM a Linux computer will use an area of the hard disk, called swap, to temporarily store data.
In other words it is a way of expanding your computers RAM.
Which command is used to review boot messages?
dmesg command is used to review boot messages. This command will display system messages
contained in the kernel ring buffer. We can use this command immediately after booting to see boot
messages. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest
data in it. Its basic syntax is
dmesg [options]
Invoking dmesg without any of its options causes it to write all the kernel messages to standard output.
This usually produces far too many lines to fit into the display screen all at once, and thus only the final
messages are visible. However, the output can be redirected to the less command through the use of a
pipe, thereby allowing the startup messages to be viewed on one screen at a time
dmesg | less
Which utility is used to make automate rotation of a log?
logrotate command is used to make automate rotation of log.
Syntax of the command is:
logrotate [-dv] [-f|] [-s|] config_file+
It allows automatic rotation, compression, removal, and mailing of log files. This command is mainly used
for rotating and compressing log files. This job is done every day when a log file becomes too large. This
command can also be run by giving on command line. We can done force rotation by giving –f option with
this command in command line. This command is also used for mailing. We can give –m option for
mailing with this command. This option takes two arguments one is subject and other is recipient name.
What are the partitions created on the mail server hard drive?
The main partitions are done firstly which are root, swap and boot partition. But for the mail server three
different partitions are also done which are as follows:
1. /var/spool- This is done so that if something goes wrong with the mail server or spool than the output
cannot overrun the file system.
2. /tmp- putting this on its own partition prevents any user item or software from overrunning the system
files.
3. /home- putting this on its own is useful for system upgrades or reinstalls. It allow not to wipe off the
/home hierarchy along with other areas.
What are the fields in the/etc/passwd file?
It contains all the information of the users who log into the system. It contains a list of the system's
accounts, giving for each account some useful information like user ID, group ID, home directory, shell,
etc. It should have general read permission as many utilities, like ls use it to map user IDs to user names,
but write access only for the superuser (root). The main fields of /etc/passwd file are:
1. Username: It is used when user logs in. It should be between 1 and 32 characters in length.
2. Password: An x character indicates that encrypted password is stored in /etc/shadow file.
3. User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs
1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for
administrative and system accounts/groups.
4. Group ID (GID): The primary group ID (stored in /etc/group file)
5. User ID Info: The comment field. It allow you to add extra information about the users such as user's
full name, phone number etc. This field use by finger command.
6. Home directory: The absolute path to the directory the user will be in when they log in. If this directory
does not exists then users directory becomes /
7. Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell.
Which commands are used to set a processor-intensive job to use less CPU
time?
nice command is used for changing priority of the jobs.
Syntax: nice [OPTION] [COMMAND [ARG]...]
Range of priority goes from -20 (highest priority) to 19 (lowest).Priority is given to a job so that the most
important job is executed first by the kernel and then the other least important jobs. This takes less CPU
times as the jobs are scheduled and are given priorities so the CPU executes fast. The priority is given by
numbers like -20 describe the highest priority and 19 describe the least priority.
How to change window manager by editing your home directory?
/.xinitrc file allows changing the window manager we want to use when logging into X from that account.
The dot in the file name shows you that the file is a hidden file and doesn't show when you do a normal
directory listing. For setting a window manager we have to save a command in this file. The syntax of
command is: exec windowmanager.After this, save the file. Next time when you run a startx a new
window manager will open and become default. The commands for starting some popular window
managers and desktop environments are:
-KDE = startkde
-Gnome = gnome-session
-Blackbox = blackbox
-FVWM = fvwm
-Window Maker = wmaker
-IceWM = icewm
How documentation of an application is stored?
When a new application is installed its documentation is also installed. This documentation is stored
under the directory named for application. For example if my application name is App1 then the path of
the documentation will be /user/doc/App1. It contains all the information about the application. It contains
date of creating application, name of application and other important module of the application. We can
get the basic information of application from the documentation.
How shadow passwords are given?
pwconv command is used for giving shadow passwords. Shadow passwords are given for better system
security. The pwconv command creates the file /etc/shadow and changes all passwords to ‘x’ in the
/etc/passwd file. First, entries in the shadowed file which don't exist in the main file are removed. Then,
shadowed entries which don't have `x' as the password in the main file are updated. Any missing
shadowed entries are added. Finally, passwords in the main file are replaced with `x'. These programs
can be used for initial conversion as well to update the shadowed file if the main file is edited by hand.
How do you create a new user account?
useradd command is used for creating a new user account. When invoked without the
-D option, the useradd command creates a new user account using the values specified on the command
line and the default values from the system. The new user account will be entered into the system files as
needed, and initial files copied, depending on the command line options. This command uses the system
default as home directory. If –m option is given then the home directory is made.
Which password package is installed for the security of central password?
Shadow password packages are used for security of central passwords. Security is the most important
aspect of every operating system. When this package is not installed the user information including
passwords is stored in the /etc/passwd file. The password is stored in an encoded format. These encoded
forms can be easily identified by the System crackers by randomly encoding the passwords from
dictionaries. The Shadow Package solves the problem by relocating the passwords to another file
(usually /etc/shadow). The /etc/shadow file is set so that it cannot be read by just anyone. Only root will
be able to read and write to the /etc/shadow file.
Which shell do you assign to a POP3 mail-only account?
POP3 mail only account is assigned to the /bin/false shell. However, assigning bash shell to a POP3 mail
only gives user login access, which is avoided. /bin/nologin can also be used. This shell is provided to the
user when we don’t want to give shell access to the user. The user cannot access the shell and it reject
shell login on the server like on telnet. It is mainly for the security of the shells. POP3 is basically used for
downloading mail to mail program. So for illegal downloading of emails on the shell this account is
assigned to the /bin/false shell or /bin/nologin. These both shells are same they both do the same work of
rejecting the user login to the shell. The main difference between these two shells is that false shell
shows the incorrect code and any unusual coding when user login with it. But the nologin shell simply tells
that no such account is available. So nologin shell is used mostly in Linux.
Which daemon is responsible for tracking events on Linux system?
syslogd is responsible for tracking system information and save it to the desired log files. It provides two
system utilities which provide system logging and kernel message trapping. Internet and UNIX domain
sockets support enable this utility package to support both local and remote logging. Every logged
message contains at least a time and a hostname field, normally a program name field, too. So to track
these information this daemon is used. syslogd mainly reacts to the set of signals given by the user.
These are the signals given to syslogd: SIGHUP: This lets syslogd perform a re-initialization. All open files
are closed, the configuration file (default is /etc/syslog.conf) will be reread and the syslog facility is started
again. SIGTERM: The syslogd will die. SIGINT, SIGQUIT: If debugging is enabled these are ignored,
otherwise syslogd will die. SIGUSR1: Switch debugging on/off. This option can only be used if syslogd is
started with the - d debug option. SIGCHLD: Wait for Childs if some were born, because of waiting
messages.
Which daemon is used for scheduling of the commands?
The crontab command is used for scheduling of the commands to run at a later time. SYNTAX
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
Options
-l List - display the current crontab entries.
-r Remove the current crontab.
-e Edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables.
When user exits from the editor, the modified crontab will be installed automatically. Each user can have
their own crontab, and though these are files in /var, they are not intended to be edited directly. If the –u
option is given than the crontab gives the name of the user whose crontab is to be tweaked. If it is given
without this then it will display the crontab of the user who is executing the command.
How environment variable is set so that the file permission can be
automatically set to the newly created files?
umask command is used to set file permission on newly created files automatically.
Syntax
umask [-p] [-S] [mode]
It is represented in octal numbers. We can simply use this command without arguments to see the current
file permissions. To change the permissions, mode is given in the arguments. The default umask used for
normal user is 0002. The default umask for the root user is 0022. For calculating the original values, the
values shown by the umask must be subtracted by the default values. It is mainly used for masking of the
file and directory permission. The /etc/profile script is where the umask command is usually set for all
users. The –S option can be used to see the current default permissions displayed in the alpha symbolic
format.
For example, umask 022 ensures that new files will have at most 755 permissions (777 NAND 022).
The permissions can be calculated by taking the NAND of original value with the default values of files
and directories.

More Related Content

What's hot

Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
samrat das
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
Harish1983
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
Sreenatha Reddy K R
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
anandvaidya
 
Raid
RaidRaid
Linux file system
Linux file systemLinux file system
Linux file system
Midaga Mengistu
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
Archana Chandrasekharan
 
Nfs
NfsNfs
Introduction to linux ppt
Introduction to linux pptIntroduction to linux ppt
Introduction to linux ppt
Omi Vichare
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
Md. Zahid Hossain Shoeb
 
RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)
skalaivanibutp
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Linux interview questions and answers
Linux interview questions and answersLinux interview questions and answers
Linux interview questions and answers
Ganapathi Raju
 
Linux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sLinux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA's
Mydbops
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
Lilesh Pathe
 

What's hot (20)

Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Raid
RaidRaid
Raid
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
 
Nfs
NfsNfs
Nfs
 
Introduction to linux ppt
Introduction to linux pptIntroduction to linux ppt
Introduction to linux ppt
 
Linux
Linux Linux
Linux
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)RPM (Red Hat Package Manager)
RPM (Red Hat Package Manager)
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux interview questions and answers
Linux interview questions and answersLinux interview questions and answers
Linux interview questions and answers
 
Linux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sLinux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA's
 
RPM (LINUX)
RPM (LINUX)RPM (LINUX)
RPM (LINUX)
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 

Viewers also liked

Sol linux cmg-t_1_1.pptx
Sol linux cmg-t_1_1.pptxSol linux cmg-t_1_1.pptx
Sol linux cmg-t_1_1.pptx
Bob Sneed
 
Linux system administrators-guide
Linux system administrators-guideLinux system administrators-guide
Linux system administrators-guide
Keith Wright
 
RHEL-7 Administrator Guide for RedHat 7
RHEL-7  Administrator Guide for RedHat 7RHEL-7  Administrator Guide for RedHat 7
RHEL-7 Administrator Guide for RedHat 7
Hemnath R.
 
Rhel7 vs rhel6
Rhel7 vs rhel6Rhel7 vs rhel6
Rhel7 vs rhel6
Arunvignesh Venkatesh
 
Chapter09 -- networking with unix and linux
Chapter09  -- networking with unix and linuxChapter09  -- networking with unix and linux
Chapter09 -- networking with unix and linux
Raja Waseem Akhtar
 
VMware Interview questions and answers
VMware Interview questions and answersVMware Interview questions and answers
VMware Interview questions and answers
vivaankumar
 
30 important-virtualization-vmware-interview-questions-with-answers
30 important-virtualization-vmware-interview-questions-with-answers30 important-virtualization-vmware-interview-questions-with-answers
30 important-virtualization-vmware-interview-questions-with-answersLatif Siddiqui
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
iimjobs and hirist
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questionsKavya Sri
 

Viewers also liked (11)

Sol linux cmg-t_1_1.pptx
Sol linux cmg-t_1_1.pptxSol linux cmg-t_1_1.pptx
Sol linux cmg-t_1_1.pptx
 
Linux system administrators-guide
Linux system administrators-guideLinux system administrators-guide
Linux system administrators-guide
 
RHEL-7 Administrator Guide for RedHat 7
RHEL-7  Administrator Guide for RedHat 7RHEL-7  Administrator Guide for RedHat 7
RHEL-7 Administrator Guide for RedHat 7
 
Rhel7 vs rhel6
Rhel7 vs rhel6Rhel7 vs rhel6
Rhel7 vs rhel6
 
Chapter09 -- networking with unix and linux
Chapter09  -- networking with unix and linuxChapter09  -- networking with unix and linux
Chapter09 -- networking with unix and linux
 
VMware Interview questions and answers
VMware Interview questions and answersVMware Interview questions and answers
VMware Interview questions and answers
 
8086 microprocessor
8086 microprocessor8086 microprocessor
8086 microprocessor
 
30 important-virtualization-vmware-interview-questions-with-answers
30 important-virtualization-vmware-interview-questions-with-answers30 important-virtualization-vmware-interview-questions-with-answers
30 important-virtualization-vmware-interview-questions-with-answers
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questions
 

Similar to Linux or unix interview questions

Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
Alessandro Selli
 
UNIX Basics and Cluster Computing
UNIX Basics and Cluster ComputingUNIX Basics and Cluster Computing
UNIX Basics and Cluster Computing
Bioinformatics and Computational Biosciences Branch
 
Interview questions
Interview questionsInterview questions
Interview questions
xavier john
 
Unixcommandsinetltesting 130712050932-phpapp01
Unixcommandsinetltesting 130712050932-phpapp01Unixcommandsinetltesting 130712050932-phpapp01
Unixcommandsinetltesting 130712050932-phpapp01Gyanendra Kumar
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testing
Garuda Trainings
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
KunalKewat1
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
 
Linux clustering solution
Linux clustering solutionLinux clustering solution
Linux clustering solution
Chanaka Lasantha
 
Linux startup
Linux startupLinux startup
Linux startup
Amin Hashemi
 
Jana treek 4
Jana treek 4Jana treek 4
Jana treek 4
Jana Treek
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filtersAcácio Oliveira
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Bimal Jain
 
Unix Administration 2
Unix Administration 2Unix Administration 2
Unix Administration 2
Information Technology
 
2345014 unix-linux-bsd-cheat-sheets-i
2345014 unix-linux-bsd-cheat-sheets-i2345014 unix-linux-bsd-cheat-sheets-i
2345014 unix-linux-bsd-cheat-sheets-iLogesh Kumar Anandhan
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
KarthickS942388
 

Similar to Linux or unix interview questions (20)

Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
UNIX Basics and Cluster Computing
UNIX Basics and Cluster ComputingUNIX Basics and Cluster Computing
UNIX Basics and Cluster Computing
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Unixcommandsinetltesting 130712050932-phpapp01
Unixcommandsinetltesting 130712050932-phpapp01Unixcommandsinetltesting 130712050932-phpapp01
Unixcommandsinetltesting 130712050932-phpapp01
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testing
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
unixtoolbox
unixtoolboxunixtoolbox
unixtoolbox
 
Linux clustering solution
Linux clustering solutionLinux clustering solution
Linux clustering solution
 
Linux startup
Linux startupLinux startup
Linux startup
 
Jana treek 4
Jana treek 4Jana treek 4
Jana treek 4
 
KCC_Final.pdf
KCC_Final.pdfKCC_Final.pdf
KCC_Final.pdf
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Unix Administration 2
Unix Administration 2Unix Administration 2
Unix Administration 2
 
2345014 unix-linux-bsd-cheat-sheets-i
2345014 unix-linux-bsd-cheat-sheets-i2345014 unix-linux-bsd-cheat-sheets-i
2345014 unix-linux-bsd-cheat-sheets-i
 
.ppt
.ppt.ppt
.ppt
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 

More from Teja Bheemanapally (20)

Teradata
TeradataTeradata
Teradata
 
Teradata
TeradataTeradata
Teradata
 
Linux notes
Linux notesLinux notes
Linux notes
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux01122011
Linux01122011Linux01122011
Linux01122011
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Installing red hat enterprise linux1
Installing red hat enterprise linux1Installing red hat enterprise linux1
Installing red hat enterprise linux1
 
Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
Common linuxcommandspocketguide07
Common linuxcommandspocketguide07Common linuxcommandspocketguide07
Common linuxcommandspocketguide07
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Basic commands
Basic commandsBasic commands
Basic commands
 
File system hierarchy standard
File system hierarchy standardFile system hierarchy standard
File system hierarchy standard
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
15 practical grep command examples in linux
15 practical grep command examples in linux15 practical grep command examples in linux
15 practical grep command examples in linux
 
25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples
 
Shell intro
Shell introShell intro
Shell intro
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 

Linux or unix interview questions

  • 1. Linux OR Unix Interview Questions 1) What is GRUB Ans GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. Briefly, a boot loader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software (such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating system (e.g. GNU) 2) Explain Linux Boot Process Ans http://www.thegeekstuff.com/2011/02/linux-boot-process/ 3) Which files are called for user profile by default when a user gets login Ans $HOME/.bash_profile, $HOME/.bash_bashrc 4) Which file needs to update if srequired to change default runlevel 5 to 3 Ans File is /etc/inittab and required to change below lines: id:5:initdefault: to id:3:initdefault: 5) What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc.. Ans FINGER command can be used i.g; finger username 6) What is inode number Ans An inode is a data structure on a traditional Unix-style file system such as UFS or ext3. An inode stores basic information about a regular file, directory, or other file system object iNode number also called as index number, it consists following attributes: File type (executable, block special etc) Permissions (read, write etc) Owner Group File Size File access, change and modification time (remember UNIX or Linux never stores file creation time, this is favorite question asked in UNIX/Linux sys admin job interview) File deletion time Number of links (soft/hard)
  • 2. Extended attribute such as append only or no one can delete file including root user (immutability) Access Control List (ACLs) Following command will be used to show inodes of file and folders: ls -i Following command will show complete info about any file or folders with inode number stat file/folder Files/Folders can also be deleted using inode numbers with following command: find out the inode number using 'ls -il' command then run below command find . -inum inode_number -exec rm -i {} ; 7) How can we increase disk read performance in single command Ans blockdev command This is sample output - yours may be different. # Before test $ blockdev --getra /dev/sdb 256 $ time dd if=/tmp/disk.iso of=/dev/null bs=256k 2549+1 records in 2549+1 records out 668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s real 0m6.845s user 0m0.004s sys 0m0.865s # After test $ blockdev --setra 1024 /dev/sdb $ time dd if=/tmp/disk.iso of=/dev/null bs=256k 2435+1 records in 2435+1 records out 638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s real 0m0.370s user 0m0.001s sys 0m0.370s 8) .... command to change user password expiration time
  • 3. Ans CHAGE 9) Command used to lock user password Ans usermod -L username 10) How many default number of Shells available and what are their names? Ans SH, BASH, CSH, TCSH, NOLOGIN, KSH 11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while adding user Ans /etc/login.defs 12) ...... command used for changing authentication of linux system to LDAP/NIS/SMB/KERBOS Ans authconfig 13) ...... command used for changing the attributes of any file Ans chattr 14) What is the path of network (ethX) configuration files Ans /etc/sysconfig/network-scripts/ethX 15) How can we change speed and make full duplex settings for eth0 Ans We can do this with below given 2 methods: ethtool -s eth0 speed 100 duplex full ethtool -s eth0 speed 10 duplex half OR mii-tool -F 100baseTx-HD mii-tool -F 10baseT-HD 16) File which stores the DNS configuration at client side Ans /etc/resolve.conf 17) Main configuration file and command used for exporting NFS directories and it's deamons
  • 4. Ans /etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status 18) What is command to check ports running/used over local machine Ans netstat -antp 19) What is the command to check open ports at remote machine Ans nmap 20) What is the difference between soft and hard links Ans Soft Links => 1) Soft link files will have different inode numbers then source file 2) If original file deleted then soft link file be of no use 3) Soft links are not updated 4) Can create links between directories 5) Can cross file system boundaries Hard Links => 1) Hard links will have the same inode number as source file 2) Hard links can not link directories 3) Can not cross file system boundaries 4) Hard links always refers to the source, even if moved or removed 21) How to setup never expired user password Ans chage -E never username 22) Restricting insertion into file if full permission are assigned to all Ans chattr +i filename 23) Display or Kill all processes which are accessing any folder/file Ans Display User who are using file/folder : fuser -u file/folder Kill All Processes which are using file/folder: fuser -k file/folder 24) Kill any user's all processes Ans killall -u username 25) How can we have daily system analysis and reports over mail Ans Use logwatch 26) How can we rotate logs using logrotate without performing any operation like move and gzip'ng over original file and then creating new file (which is very lengthy process)
  • 5. Ans We can use "logrotate"'s "copytruncate" option which will simply copy original file and truncate original file :) 27) Command to collect detailed information about the hardware and setup of your system Ans dmidecode , sysreport 28) Command to check PCI devices vendor or version Ans lspci 29) What is the difference between cron and anacron Ans Cron : 1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed every minute) 2) Cron job can be scheduled by any normal user ( if not restricted by super user ) 3) Cron expects system to be running 24 x 7. If a job is scheduled, and system is down during that time, job is not executed 4) Ideal for servers 5) Use cron when a job has to be executed at a particular hour and minute Anacron : 1) Minimum granularity is only in days 2) Anacron can be used only by super user ( but there are workarounds to make it usable by normal user ) 3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled, and system is down during that time, it start the jobs when the system comes back up. 4) Ideal for desktops and laptops 5) Use anacron when a job has to be executed irrespective of hour and minute 30) Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps Ans SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS 143/993 31) How to setup ACLs in following case: 1) Create a file FILE1 and this should be read,write,executable for all user but Read only for user USER1 2) Copy FILE1 ACLs to FILE2 ACL 3) Delete a USER1's rule for FILE1 which were setup in step 1) Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1 2) getfacl FILE1 | setfacl --set-file=- FILE2
  • 6. 3) setfacl -x u:USER1 FILE1 32) How to make USB bootable? Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB dd if=efidisk.img of=/dev/usb (usb device name) 33) How can we check disk/device status/failure/errors using smartctl utility? Ans Try following to check: Enable/Disable SMART on device/disk : smartctl -s on /dev/sda Check device SMART health : smartctl -H /dev/sda Check device SMART capabilities : smartctl -c /dev/sda Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda Show device log [TYPE : error, selftest, selective, directory,background, scttemp[sts,hist]] : smartctl -l TYPE /dev/sda Run test on device [TEST: offline short long conveyance select,M-N pending,N afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda 34) What is the difference between ext2 vs ext3 vs ext4? Ans http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/ 35) Disable ping to avoid network/ICMP flood Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1 Then "sysctl -p" or echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all 36) What is SYN Flood, ICMP Flood Ans SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a fake/forged sender address. Each of these packets is handled like a connection request, causing the server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge), and waiting for a packet in response from the sender address(response to the ACK Packet). However, because the sender address is forged, the response never comes. These half-open connections saturate the number of available connections the server is able to make, keeping it from responding to legitimate requests until after the attack ends
  • 7. ICMP Flood : There are three types of ICMP Flood : 1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack 2) Ping Flood : http://en.wikipedia.org/wiki/Ping_flood 3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death 37) What is the difference between Unix vs Linux Kernels? Ans Please find below given link : http://www.thegeekstuff.com/2012/01/linux-unix-kernel/ 38) How to setup Password less remote login/ssh? Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod 0600 ~/.ssh/authorized_keys" Now try to login from local system to remote_server "ssh root@remote_server" 39) Command to see default kernel image file Ans "grubby --default-kernel" 40) How to create lvm mirror Ans lvcreate -L 50G -m1 -n LVMmirror vg0 41) Command to check last runlevel Ans who -r 42) What do you mean by File System? Ans File System is a method to store and organize files and directories on disk. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories. 43) What is the requirement of udev daemon? Ans Create and remove device nodes or files in /dev/ directory 44) What are block and character devices? Ans Both the devices are present in /dev directory
  • 8. Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)]. Examples: - USB disk, CDROM, Hard Disk (sda, sdb, sdc etc....) Character device files talk to devices character by character. Examples: - Virtual terminals, terminals, serial modems, random numbers (tty{0,1,2,3......}) 45) How to Convert ext2 to ext3 File System? Ans tune2fs -j /dev/{device-name} 46) File required to modify for setting up kernel parameters permanent Ans /etc/sysctl.conf 47) Commands used to install, list and remove modules from kernel Ans Installing/adding a module: insmod mod_name modprobe mod_name List installed modules : lsmod Removing a module : modprobe -r mod_name 48) How to create swap using a file and delete swap Ans Adding swap : dd if=/dev/zero of=/opt/myswap bs=1024 count=4 mkswap /opt/myswap swapon -a For adding this myswap at boot time, add following in /etc/fstab file: /opt/myswap swap swap defaults 0 0 Deleting Swap : Run "swapoff /opt/myswap" command Remove the entry from /etc/fstab file Remove /opt/myswap file (using rm command) 49) What vmstat show Ans vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays
  • 9. summary information about operating system memory, processes, interrupts, paging and block I/O 50) What is tmpfs File System Ans Reference : http://en.wikipedia.org/wiki/Tmpfs tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system. Everything stored in tmpfs is temporary in the sense that no files will be created on the hard drive; however, swap space is used as backing store in case of low memory situations. On reboot, everything in tmpfs will be lost. The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped out to swap space. 51) What is the difference between screen and script commands? Ans Screen is an screen manager with VT100/ANSI terminal emulation and used to take GNU screen session remotely or locally and while Script make typescript of terminal session Screen : needs to be detached, should not be exited to access remotely/locally Script : creates a file and store all the terminal output to this file 52) How can we check which process is assigned to which processor? Ans Run "ps -elFL" and find out the PSR column which is showing the processor number to the process 53) How can we check vendor, version, release date, size, package information etc... of any installed rpm? Ans) rpm -qi package-name , for example: rpm -qi ypbind-1.19-12.el5 Linux Interview Questions : L1 &L2 1) What are the process states in Unix? As a process executes it changes state according to its circumstances. Unix processes have the following states: Running : The process is either running or it is ready to run . Waiting : The process is waiting for an event or for a resource. Stopped : The process has been stopped, usually by receiving a signal.
  • 10. Zombie : The process is dead but have not been removed from the process table. 2) What Happens when you execute a program? When you execute a program on your UNIX system, the system creates a special environment for that program. This environment contains everything needed for the system to run the program as if no other program were running on the system. Each process has process context, which is everything that is unique about the state of the program you are currently running. Every time you execute a program the UNIX system does a fork, which performs a series of operations to create a process context and then execute your program in that context. The steps include the following: Allocate a slot in the process table, a list of currently running programs kept by UNIX. Assign a unique process identifier (PID) to the process. iCopy the context of the parent, the process that requested the spawning of the new process. Return the new PID to the parent process. This enables the parent process to examine or control the process directly. After the fork is complete, UNIX runs your program. 3) What Happens when you execute a command? When you enter ‘ls’ command to look at the contents of your current working directory, UNIX does a series of things to create an environment for ls and the run it: The shell has UNIX perform a fork. This creates a new process that the shell will use to run the ls program. The shell has UNIX perform an exec of the ls program. This replaces the shell program and data with the program and data for ls and then starts running that new program. The ls program is loaded into the new process context, replacing the text and data of the shell. The ls program performs its task, listing the contents of the current directory. 4) What is a Daemon? A daemon is a process that detaches itself from the terminal and runs, disconnected, in the background, waiting for requests and responding to them. It can also be defined as the background process that does not belong to a terminal session. Many system functions are commonly performed by daemons, including the sendmail daemon, which handles mail, and the NNTP daemon, which handles USENET news. Many other daemons may exist. Some of the most common daemons are: init: Takes over the basic running of the system when the kernel has finished the boot process. inetd: Responsible for starting network services that do not have their own stand-alone daemons. For example, inetd usually takes care of incoming rlogin, telnet, and ftp connections. cron: Responsible for running repetitive tasks on a regular schedule. 5) What is ‘ps’ command for? The ps command prints the process status for some or all of the running processes. The information given are the process identification number (PID),the amount of time that the process has taken to execute so far etc.
  • 11. 6) How would you kill a process? The kill command takes the PID as one argument; this identifies which process to terminate. The PID of a process can be got using ‘ps’ command. 7) What is an advantage of executing a process in background? The most common reason to put a process in the background is to allow you to do something else interactively without waiting for the process to complete. At the end of the command you add the special background symbol, &. This symbol tells your shell to execute the given command in the background. Example: cp *.* ../backup& (cp is for copy) 8) How do you execute one program from within another? The system calls used for low-level process creation are execlp() and execvp(). The execlp call overlays the existing program with the new one , runs that and exits. The original program gets back control only when an error occurs. execlp(path,file_name,arguments..); //last argument must be NULL A variant of execlp called execvp is used when the number of arguments is not known in advance. execvp(path,argument_array); //argument array should be terminated by NULL 9) What is IPC? What are the various schemes available? The term IPC (Inter-Process Communication) describes various ways by which different process running on some operating system communicate between each other. Various schemes available are as follows: Pipes: One-way communication scheme through which different process can communicate. The problem is that the two processes should have a common ancestor (parent-child relationship). However this problem was fixed with the introduction of named-pipes (FIFO). Message Queues : Message queues can be used between related and unrelated processes running on a machine. Shared Memory: This is the fastest of all IPC schemes. The memory to be shared is mapped into the address space of the processes (that are sharing). The speed achieved is attributed to the fact that there is no kernel involvement. But this scheme needs synchronization. Various forms of synchronisation are mutexes, condition-variables, read-write locks, record-locks, and semaphores. 10) What is the difference between Swapping and Paging? Swapping : Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems. Paging : Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into
  • 12. the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly. 11) What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management? Historic Unix uses Swapping – entire process is transferred to the main memory from the swap device, whereas the Unix System V uses Demand Paging – only the part of the process is moved to the main memory. Historic Unix uses one Swap Device and Unix System V allow multiple Swap Devices. 12) What is the main goal of the Memory Management? It decides which process should reside in the main memory, Manages the parts of the virtual address space of a process which is non-core resident, Monitors the available main memory and periodically write the processes into the swap device to provide more processes fit in the main memory simultaneously. 13) What is a Map? A Map is an Array, which contains the addresses of the free space in the swap device that are allocatable resources, and the number of the resource units available there. This allows First-Fit allocation of contiguous blocks of a resource. Initially the Map contains one entry – address (block offset from the starting of the swap area) and the total number of resources. Kernel treats each unit of Map as a group of disk blocks. On the allocation and freeing of the resources Kernel updates the Map for accurate information. 14) What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices? Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V. 15) What is a Region? A Region is a continuous area of a process’s address space (such as text, data and stack). The kernel in a ‘Region Table’ that is local to the process maintains region. Regions are sharable among the process. 16) What are the events done by the Kernel after a process is being swapped out from the main memory?
  • 13. When Kernel swaps the process out of the primary memory, it performs the following: Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory, Kernel allocates the space for the swapping process in the swap device, Kernel locks the other swapping process while the current swapping operation is going on, The Kernel saves the swap address of the region in the region table. 17) Is the Process before and after the swap are the same? Give reason. Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process out. After swapping the process resides in the swap (secondary memory) device. The regions swapped out will be present but only the occupied region slots but not the empty slots that were present before assigning. While swapping the process once again into the main memory, the Kernel referring to the Process Memory Map, it assigns the main memory accordingly taking care of the empty slots in the regions. 18) What do you mean by u-area (user area) or u-block? This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area. 19) What are the entities that are swapped out of the main memory while swapping the process out of the main memory? All memory space occupied by the process, process’s u-area, and Kernel stack are swapped out, theoretically. Practically, if the process’s u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area. 20) What is Fork swap? fork() is a system call to create a child process. When the parent process calls fork() system call, the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device, and return to the user state without swapping the parent process. When the memory will be available the child process will be swapped into the main memory. 21) What is Expansion swap? At the time when any process requires more memory than it is currently allocated, the Kernel performs Expansion swap. To do this Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later when the Kernel swaps the
  • 14. process into the main memory this assigns memory according to the new address translation mapping. 22) How the Swapper works? The swapper is the only process that swaps the processes. The Swapper operates only in the Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process. 23) Who owns the data dictionary? The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created. 24) You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it ? zcat -> The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file. 25) You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine the location of the command being run? which -> The which command searches your path until it finds a command that matches the command you are looking for and displays its full path. 26) You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose. whatis ->The whatis command displays a summary line from the man page for the specified command. 27) When you issue the command ls -l, the first character of the resulting display represents the file’s? type ->The first character of the permission block designates the type of file that is being displayed. 28) What utility can you use to show a dynamic listing of running processes? top -> The top utility shows a listing of all running processes that is dynamically updated. 29) Where is standard output usually directed?
  • 15. To the screen or display. 30) What daemon is responsible for tracking events on your system? syslogd ->The syslogd daemon is responsible for tracking system information and saving it to specified log files Basic Linux Interview Questions : What is Linux and why is it so popular? Answer - Linux is an operating system that uses UNIX like Operating system....... Unix interview questions with answers? Answer -Discuss the mount and unmount system calls, What are the process states in Unix?, What is use of sed command?, What is 'inode'?,What are the Unix system calls for I/O?, How are devices represented in UNIX?, Brief about the directory representation in UNIX ...... What is LILO? Answer - LILO is Linux Loader is a boot loader for Linux. It is used to load Linux into the memory and start the Operating system....... What is the difference between home directory and working directory? Answer - Home directory is the default working directory when a user logs in. On the other hand, working directory is the user’s current directory....... What is the difference between internal and external commands? Answer - Internal commands are commands that are already loaded in the system. They can be executed any time and are independent....... Explain the difference between a static library and a dynamic library. Answer - Static libraries are loaded when the program is compiled and dynamically-linked libraries are loaded in while...... What is LD_LIBRARY_PATH? Answer - LD_LIBRARY_PATH is an environment variable. It is used for debugging a new library or a non standard library....... What is the file server in Linux server? Answer - File server is used for file sharing. It enables the processes required fro sharing.......
  • 16. What is NFS? What is its purpose? Answer - NFS is Network File system. It is a file system used for sharing of files over a network....... How do I send email with linux? Answer - Email can be sent in Linux using the mail command. ...... Explain RPM (Red Hat Package Manager) features. Answer - RPM is a package managing system (collection of tools to manage software packages)....... What is Kernel? Explain the task it performs. Answer - Kernel is used in UNIX like systems and is considered to be the heart of the operating system....... What is Linux Shell? What is Shell Script? Answer - Linux shell is a user interface used for executing the commands. Shell is a program the user...... What are Pipes? Explain use of pipes. Answer - A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another....... Explain trap command; shift Command, getopts command of linux. Answer - Trap command: controls the action to be taken by the shell when a signal is received. ...... What Stateless Linux server? What feature it offers? Answer - A stateless Linux server is a centralized server in which no state exists on the single workstations. ...... What does nslookup do? Explain its two modes. Answer - Nslookup is used to find details related to a Domain name server. Details like IP addresses of a machine, MX records,...... What is Bash Shell? Answer - Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and Korn shell features. ...... Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump, ntop Answer - Network monitoring tools are used to monitor the network, systems present on the network, traffic etc....... How does the linux file system work? Answer - Linux file structure is a tree like structure. It starts from the root directory, represented by '/', and then expands into sub-directories.......
  • 17. What are the process states in Linux? Answer - Process states in Linux....... What is a zombie? Answer - Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table....... Explain each system calls used for process management in linux. Answer - System calls used for Process management...... Which command is used to check the number of files and disk space used and the each user’s defined quota? repquota command is used to check the status of the user’s quota along with the disk space and number of files used. This command gives a summary of the user’s quota that how much space and files are left for the user. Every user has a defined quota in Linux. This is done mainly for the security, as some users have only limited access to files. This provides a security to the files from unwanted access. The quota can be given to a single user or to a group of users. What is the name and path of the main system log? By default the main system log is /var/log/messages. This file contains all the messages and the script written by the user. By default all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to 'dmesg'. dmesg is a system file that is written upon system boot. How secured is Linux? Explain. Security is the most important aspect of an operating system. Due to its unique authentication module, Linux is considered as more secured than other operating systems. Linux consists of PAM. PAM is Pluggable Authentication Modules. It provides a layer between applications and actual authentication mechanism. It is a library of loadable modules which are called by the application for authentication. It also allows the administrator to control when a user can log in. All PAM applications are configured in the directory "/etc/pam.d" or in a file "/etc/pam.conf". PAM is controlled using the configuration file or the configuration directory. Can Linux computer be made a router so that several machines may share a single Internet connection? How? Yes a Linux machine can be made a router. This is called "IP Masquerade." IP Masquerade is a networking function in Linux similar to the one-to-many (1: Many) NAT (Network Address Translation) servers found in many commercial firewalls and network routers. The IP Masquerade feature allows other "internal" computers connected to this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as well. Linux IP Masquerading allows this functionality even if the internal computers do not have IP addresses. The IP masquerading can be done by the following steps:
  • 18. 1. The Linux PC must have an internet connection and a connection to LAN. Typically, the Linux PC has two network interfaces-an Ethernet card for the LAN and a dial-up PPP connection to the Internet (through an ISP). 2. All other systems on your LAN use the Linux PC as the default gateway for TCP/IP networking. Use the same ISP-provided DNS addresses on all systems. 3. Enable IP forwarding in the kernel. By default the IP forwarding is not enabled. To ensure that IP forwarding is enabled when you reboot your system, place this command in the /etc/rc.d/rc.local file. 4. Run /sbin/iptables-the IP packet filter administration program-to set up the rules that enable the Linux PC tomasquerade for your LAN. What is the minimum number of partitions you need to install Linux? Minimum 2 partitions are needed for installing Linux. The one is / or root which contains all the files and the other is swap. Linux file system is function specific which means that files and folders are organized according to their functionality. For example, all executables are in one folder, all devices in another, all libraries in another and so on. / or ‘root’ is the base of this file system. All the other folders are under this one. / can be consider as C: .Swap is a partition that will be used as virtual memory. If there is no more available RAM a Linux computer will use an area of the hard disk, called swap, to temporarily store data. In other words it is a way of expanding your computers RAM. Which command is used to review boot messages? dmesg command is used to review boot messages. This command will display system messages contained in the kernel ring buffer. We can use this command immediately after booting to see boot messages. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it. Its basic syntax is dmesg [options] Invoking dmesg without any of its options causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe, thereby allowing the startup messages to be viewed on one screen at a time dmesg | less Which utility is used to make automate rotation of a log? logrotate command is used to make automate rotation of log. Syntax of the command is:
  • 19. logrotate [-dv] [-f|] [-s|] config_file+ It allows automatic rotation, compression, removal, and mailing of log files. This command is mainly used for rotating and compressing log files. This job is done every day when a log file becomes too large. This command can also be run by giving on command line. We can done force rotation by giving –f option with this command in command line. This command is also used for mailing. We can give –m option for mailing with this command. This option takes two arguments one is subject and other is recipient name. What are the partitions created on the mail server hard drive? The main partitions are done firstly which are root, swap and boot partition. But for the mail server three different partitions are also done which are as follows: 1. /var/spool- This is done so that if something goes wrong with the mail server or spool than the output cannot overrun the file system. 2. /tmp- putting this on its own partition prevents any user item or software from overrunning the system files. 3. /home- putting this on its own is useful for system upgrades or reinstalls. It allow not to wipe off the /home hierarchy along with other areas. What are the fields in the/etc/passwd file? It contains all the information of the users who log into the system. It contains a list of the system's accounts, giving for each account some useful information like user ID, group ID, home directory, shell, etc. It should have general read permission as many utilities, like ls use it to map user IDs to user names, but write access only for the superuser (root). The main fields of /etc/passwd file are: 1. Username: It is used when user logs in. It should be between 1 and 32 characters in length. 2. Password: An x character indicates that encrypted password is stored in /etc/shadow file. 3. User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups. 4. Group ID (GID): The primary group ID (stored in /etc/group file) 5. User ID Info: The comment field. It allow you to add extra information about the users such as user's full name, phone number etc. This field use by finger command. 6. Home directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes / 7. Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Which commands are used to set a processor-intensive job to use less CPU time? nice command is used for changing priority of the jobs. Syntax: nice [OPTION] [COMMAND [ARG]...] Range of priority goes from -20 (highest priority) to 19 (lowest).Priority is given to a job so that the most important job is executed first by the kernel and then the other least important jobs. This takes less CPU times as the jobs are scheduled and are given priorities so the CPU executes fast. The priority is given by numbers like -20 describe the highest priority and 19 describe the least priority.
  • 20. How to change window manager by editing your home directory? /.xinitrc file allows changing the window manager we want to use when logging into X from that account. The dot in the file name shows you that the file is a hidden file and doesn't show when you do a normal directory listing. For setting a window manager we have to save a command in this file. The syntax of command is: exec windowmanager.After this, save the file. Next time when you run a startx a new window manager will open and become default. The commands for starting some popular window managers and desktop environments are: -KDE = startkde -Gnome = gnome-session -Blackbox = blackbox -FVWM = fvwm -Window Maker = wmaker -IceWM = icewm How documentation of an application is stored? When a new application is installed its documentation is also installed. This documentation is stored under the directory named for application. For example if my application name is App1 then the path of the documentation will be /user/doc/App1. It contains all the information about the application. It contains date of creating application, name of application and other important module of the application. We can get the basic information of application from the documentation. How shadow passwords are given? pwconv command is used for giving shadow passwords. Shadow passwords are given for better system security. The pwconv command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file. First, entries in the shadowed file which don't exist in the main file are removed. Then, shadowed entries which don't have `x' as the password in the main file are updated. Any missing shadowed entries are added. Finally, passwords in the main file are replaced with `x'. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand. How do you create a new user account? useradd command is used for creating a new user account. When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. The new user account will be entered into the system files as needed, and initial files copied, depending on the command line options. This command uses the system default as home directory. If –m option is given then the home directory is made. Which password package is installed for the security of central password? Shadow password packages are used for security of central passwords. Security is the most important aspect of every operating system. When this package is not installed the user information including passwords is stored in the /etc/passwd file. The password is stored in an encoded format. These encoded forms can be easily identified by the System crackers by randomly encoding the passwords from dictionaries. The Shadow Package solves the problem by relocating the passwords to another file (usually /etc/shadow). The /etc/shadow file is set so that it cannot be read by just anyone. Only root will
  • 21. be able to read and write to the /etc/shadow file. Which shell do you assign to a POP3 mail-only account? POP3 mail only account is assigned to the /bin/false shell. However, assigning bash shell to a POP3 mail only gives user login access, which is avoided. /bin/nologin can also be used. This shell is provided to the user when we don’t want to give shell access to the user. The user cannot access the shell and it reject shell login on the server like on telnet. It is mainly for the security of the shells. POP3 is basically used for downloading mail to mail program. So for illegal downloading of emails on the shell this account is assigned to the /bin/false shell or /bin/nologin. These both shells are same they both do the same work of rejecting the user login to the shell. The main difference between these two shells is that false shell shows the incorrect code and any unusual coding when user login with it. But the nologin shell simply tells that no such account is available. So nologin shell is used mostly in Linux. Which daemon is responsible for tracking events on Linux system? syslogd is responsible for tracking system information and save it to the desired log files. It provides two system utilities which provide system logging and kernel message trapping. Internet and UNIX domain sockets support enable this utility package to support both local and remote logging. Every logged message contains at least a time and a hostname field, normally a program name field, too. So to track these information this daemon is used. syslogd mainly reacts to the set of signals given by the user. These are the signals given to syslogd: SIGHUP: This lets syslogd perform a re-initialization. All open files are closed, the configuration file (default is /etc/syslog.conf) will be reread and the syslog facility is started again. SIGTERM: The syslogd will die. SIGINT, SIGQUIT: If debugging is enabled these are ignored, otherwise syslogd will die. SIGUSR1: Switch debugging on/off. This option can only be used if syslogd is started with the - d debug option. SIGCHLD: Wait for Childs if some were born, because of waiting messages. Which daemon is used for scheduling of the commands? The crontab command is used for scheduling of the commands to run at a later time. SYNTAX crontab [ -u user ] file crontab [ -u user ] { -l | -r | -e } Options -l List - display the current crontab entries. -r Remove the current crontab. -e Edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. When user exits from the editor, the modified crontab will be installed automatically. Each user can have their own crontab, and though these are files in /var, they are not intended to be edited directly. If the –u option is given than the crontab gives the name of the user whose crontab is to be tweaked. If it is given without this then it will display the crontab of the user who is executing the command.
  • 22. How environment variable is set so that the file permission can be automatically set to the newly created files? umask command is used to set file permission on newly created files automatically. Syntax umask [-p] [-S] [mode] It is represented in octal numbers. We can simply use this command without arguments to see the current file permissions. To change the permissions, mode is given in the arguments. The default umask used for normal user is 0002. The default umask for the root user is 0022. For calculating the original values, the values shown by the umask must be subtracted by the default values. It is mainly used for masking of the file and directory permission. The /etc/profile script is where the umask command is usually set for all users. The –S option can be used to see the current default permissions displayed in the alpha symbolic format. For example, umask 022 ensures that new files will have at most 755 permissions (777 NAND 022). The permissions can be calculated by taking the NAND of original value with the default values of files and directories.