Q : – Please describe the Linux boot-up sequence ?
Ans :-
There are seven steps to the boot-up sequence.
1) BIOS (basic input/output system) – executes the MBR where Bootloader sits.
2) MBR- Master boot reads Kernel into memory.
3) GRUB (Grand Unified Bootloader) Kernel starts Init process.
4) Kernel – Kernel executes the /sbin/init program. Init reads inittab, executes rc.sysinit.
5) Init – the rc script then starts services to reach the default runlevel &
6) Run level programs – these programs are executed from /etc/rc.d/rc*.dl/
Q : – Linux is which kind of Operating System ?
Ans :-
Multi User
Multi Tasking
Multi Process
All of the above
Linux is an Operating System which supports Multi User, Running a Number of Processes performing different tasks simultaneously.
Q : – Is Linux Operating system Virus free?
Ans :- No! There doesn’t exist any Operating System on this earth that is virus free. However Linux is known to have least number of Viruses, till date, yes even less than UNIX OS. Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.
Q : – What are the Monitoring Tools used in Linux ?
Ans :-
1 top - Process Activity Command
2 ps - Displays The Processes
3 iostat - Average CPU Load, Disk Activity
4 vmstat - System Activity, Hardware and System Information
These are main monitoring tools ,"Nagios" is also we can use
this is third party open source application software
w for connected user
last for login & reboot history
lastb- for fail login attempts
lastlog- for most recent login
Q : – You are supposed to calculate a real number calculation directly from terminal and not any shell script. What will you do (say the real numbers are 7.56 and 2.453) ?
Ans :-
We need to use bc command in a special way as described below. The output of echo 7.56 + 2.453 should be pipelined to bc.
For example, run the following command to calculate numbers in real time using bc command as shown.
$ echo 7.56 + 2.453 | bc
10.013
Q : – Give me some commands for user management.
Ans :- last, change, chsh, lsof, chown, chmod, useradd, userdel, newusers.
Q : – Give me some security monitoring related commands.
Ans :- lsof, netstat, top, ps -ef, tail, last, tcpdump, sestatus, history, w.
Q : – What is the difference between man, info, whatis commands and a –help option for a command?
Ans :- man command gives you medium size info.
info command gives full details about a commands, lots and lots of information about a command.
–help option for a command gives you one line answers for each option supported by a command
Q: – Every command in Linux is a ?
Ans:- Executable program
Q: – 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)
Q: – Explain Linux Boot Process ?
Ans:- Press the power button on your system, and after few moments you see the Linux login prompt.
Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login
prompt appears?
The following are the 6 high level stages of
a typical Linux boot process.
BIOS :- BIOS stands for Basic Input/Output System
Performs some system integrity checks
Searches, loads, and executes the boot loader program.
It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.
Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it and
So, in simple terms BIOS loads and executes the MBR boot loader
MBR :- MBR stands for Master Boot Record.
It is located in the 1st sector of the bootable disk.
Typically /dev/hda, or /dev/sda
MBR is less than 512 bytes in size.
This has three components
1) primary boot loader info in 1st 446 bytes
2) partition table info in next 64 bytes
and 3) mbr validation check in last 2 bytes.
It contains information about GRUB (or LILO in old systems). and
So, in simple terms MBR loads and executes the GRUB boot loader.
GRUB :- GRUB stands for Grand Unified Bootloader.
If you have multiple kernel images installed on your system, you can choose which one to be executed.
GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS.
As you notice from the above info, it contains kernel and initrd image and
So, in simple terms GRUB just loads and executes Kernel and initrd images.
KERNEL :- Mounts the root file system as specified in the “root=” in grub.conf
Kernel executes the /sbin/init program
Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
initrd stands for Initial RAM Disk.
initrd is used by kernel as temporary root file system until kernel is booted and the real root filesystem is mounted AND
It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.
Runlevel Programs :- When the Linux system is booting up, you might see various services getting started.
For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your runlevel.
Depending on your default init level setting, the system will execute the programs from one of the following directories.
Run level 0 – /etc/rc.d/rc0.d/
Run level 1 – /etc/rc.d/rc1.d/
Run level 2 – /etc/rc.d/rc2.d/
Run level 3 – /etc/rc.d/rc3.d/
Run level 4 – /etc/rc.d/rc4.d/
Run level 5 – /etc/rc.d/rc5.d/
Run level 6 – /etc/rc.d/rc6.d/
Please note that there are also symbolic links available for these directory under /etc directly.
So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
Programs starts with S are used during startup. S for startup.
Programs starts with K are used during shutdown. K for kill.
There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
For example, S12syslog is to start the syslog daemon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.
INIT :- Looks at the /etc/inittab file to decide the Linux runlevel.
0 – halt
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – unused
5 – X11
6 – reboot
Init identifies the default init level from /etc/inittab and uses that to load all appropriate program.
Execute ‘grep initdefault /etc/inittab’ on your system to identify the default runlevel.
If you want to get into trouble, you can set the default run level to 0 or 6.
Since you know what 0 and 6 means, probably you might not do that AND
Typically you would set the default runlevel to either 3 or 5.
Q: – Which files are called for user profile by default when a user gets login ?
Ans:- $HOME/.bash_profile, $HOME/.bash_bashrc
Q: – Which file needs to update if required 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:
Q: – 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
command to change user password expiration time
CHANGE
Q: – Command used to lock user password
Ans:- usermod -L username
Q: – How many default number of Shells available and what are their names?
Ans:- SH, BASH, CSH, TCSH, NOLOGIN, KSH
Q: – Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while adding user
Ans:- /etc/login.defs
Q: – Command used for changing authentication of linux system to LDAP/NIS/SMB/KERBEROS
Ans:- authconfig
Q: – Command used for changing the attributes of any file ?
Ans:- chattr
Q: – What is the path of network (ethX) configuration files ?
Ans:- /etc/sysconfig/network-scripts/ethX
Q: – 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
Q: – Main configuration file and command used for exporting NFS directories and it’s demons?
Ans:- /etc/exports and exportfs -av , demons are quotad, portmapper, mountd, nfsd and nlockmgr/status
Q: – What is command to check ports running/used over local machine ?
Ans:- netstat -antp
Q: – What is the command to check open ports at remote machine ?
Ans:- nmap
Q: – Restricting insertion into file if full permission are assigned to all ?
Ans:- chattr +i filename
Q: – 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 filesystem 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 filesystem boundaries.
4) Hard links always refers to the source, even if moved or removed.
Q: – How to setup never expired user password ?
Ans:- chage -E never username
Display or Kill all processes which are accessing any folder/file
Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder
Q: – Kill any user’s all processes ?
Ans:- killall -u username
Q: – How can we have daily system analysis and reports over mail ?
Ans:- Use logwatch
Q: – How can we rotate logs using logrotate without performing any operation like move and gzipping 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 icon smile Linux and Unix System Administration Interview Questions.
Q: – Command to collect detailed information about the hardware and setup of your system ?
Ans:- dmidecode , sysreport
Q: – Command to check PCI devices vendor or version ?
Ans:- lspci
Q: – 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/SMTPS 25/465, POP3/POP3S 110/995, IMAP/IMAPS 143/993.
Q: – How to setup ACLs in following case ?
Ans:-
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
Q: –How to setup Passwordless 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”
Q: – Command to see default kernel image file ?
Ans:- “grubby –default-kernel”
Q: – How to create lvm mirror ?
Ans:- lvcreate -L 50G -m1 -n LVM mirror vg0
Q: – Command to check last runlevel ?
Ans:- who -r
Q: – 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.
Q: – What is the requirement of udev daemon ?
Ans:- Create and remove device nodes or files in /dev/ directory
Q: – How to Convert ext2 to ext3 File System ?
Ans:- tune2fs -j /dev/{device-name}
Q: – 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
Q: – File which stores the DNS configuration at client side ?
Ans:- /etc/resolve.conf
Q: – File required to modify for setting up kernel parameters permanent ?
Ans:- /etc/sysctl.conf
Q: – 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.
Q: – 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 excited to access remotely/locally
Script : creates a file and store all the terminal output to this file
Q: – 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
Q: – 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)
Disable ping to avoid network/ICMP flood
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
Q: – 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)
Q: – What Squid service do ?
Ans:- Squid provides the Proxy service, which caches and filters web traffic.
Q: – Which popular office suite freely available for both Microsoft and Linux ?
Ans:- Open office suite is freely available. You can install it on both OS Microsoft and Linux.
Q: – You company recently switched from Microsoft to Linux. All their documents are created on Microsoft office 2007. How will you manage documents created on Microsoft office 2007 ?
Ans:- Install open office suite in Linux. It allows you work with Microsoft documents.
Q: – Name any of three spreadsheet programs, those are equivalent to Microsoft Excel and available for Linux ?
Ans:-
Openoffice calc [Free]
KOffice Kspread [Free]
StarOffice Base [commercial ]
Corel Quattro [commercial]
Q: – What is the SMTP ?
Ans:- SMTP is the most common protocol for an e-mail server.
Q: – What is NNTP ?
Ans:- NNTP is the common protocol which is used for news services. LeafNode and INN are examples of news servers.
Q: – Which port should you open in your host firewall to run web server ?
Ans:- By default web server use port 80 and 443 which you need to open in firewall.
Q: – Which IP addressing should you use for Server?
Ans:- For server you should always use static IP address.
Q: – Which IP address should you use for client desktop?
Ans:- For client you can use both static and dynamic method. For easy management using DHCP to assign IP address would be the best option.
Q: – Which ports should you open in host firewall for an email server?
Ans:- Open port 110 which is used by the POP3 e-mail protocol.
Open port 25 which is used by the SMTP e-mail protocol.
Open port 143 which is used by the IMAP e-mail protocol.
Q: – You have a file (say virgin.txt). You want this file to be alter-proof so that no one can edit or delete this file, not even root. What will you do?
Ans:- # chattr +i virgin.txt
# rm -r virgin.txt (Remove the file using normal user)
# rm -r virgin.txt (Remove the file using root user)
If several users are using your Linux Server, how will you find the usage time of all the users, individually on your server?
# apt-get install acct
# ac -p
Q: – It is possible to send query to BIOS from Linux Command Line?
Ans:- # biosdecode
Q: – Most of the Linux Server are headless, i.e., they run in command mode only. No GUI is installed. How will you find hardware description and configuration of your box?
Ans:- # dmidecode
# dmidecode > /path/to/text/file/text_file.txt
Q: – Is it possible to mount an NTFS partition on Linux?
Ans:- Yes! We can mount an NTFS partition/disk on Linux system using application ‘mount.ntfs’ which optionally is called as ‘ntfs-3g’ in order to mount ntfs partition on Linux System.
Q: – What and where you need to edit so that the default desktop at login will be KDE, which at present is GNOME ?
Ans:-
We need to edit a file ‘/etc/sysconfig/desktop’ and add/edit the below lines to load KDE by default and not GNOME.
DESKTOP=”KDE”
DISPLAYMANAGER=”KDE”
Q: – What is the basic difference between UNIX and Linux Operating System?
Ans:- Linux is free and open-source software (allowing programmers to program with Linux not around it), the kernel of which is created by Linus Torvalds and community. UNIX, on the other hand, is UNIX is copyrighted name only big companies are allowed to use the UNIX copyright and name, so IBM AIX and Sun Solaris and HP-UX all are UNIX operating systems.
Q: – What is the core of Linux Operating System?
Ans:-
Shell
Kernel
Command
Script
Terminal
The core of the Linux operating system is Kernel. It is broken down into Shell, Command, Script, and Terminal. Shell is a command Line Interpreter, Command is user Instruction to Computer, Script is collection of commands stored in a file, and Terminal is a command Line Interface.
Q: – What is an INODE?
Ans:- All files have its description stored in a structure called ‘inode’. The inode contains info about the file-size, access and modification time, permission and so on. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file.
Q: – What is the difference between TCP and UDP?
Ans:- The basic difference is that TCP establishes a connection before sending data and this allows it to control the dataflow and guarantee that all packets get delivered. UDP simply chucks datagrams onto the wire and if some get lost or arrive in bad order there’s no way to request a resend. However UDP has low network overhead so some services such as DNS resolution, SNMP, DHCP, RIP and VOIP use UDP for its speed and any errors are usually dealt with on the application layer rather than network layer.
Q: – How does DNS resolution work?
Ans:- A client application requests an IP address from the name server usually by connecting to UDP port 53.
The name server will attempt to resolve the FQDN based on its resolver library, which may contain authoritative information about the host requested or cached data about that name from an earlier query.
If the name server does not already have the answer, it will turn to root name servers to determine the authoritative for the FQDN in question.
Then, with that information, it will query the authoritative nameservers for that name to determine the IP address.
Q: – What is an MX record?
Ans:- An MX record numerically ranks the mail servers you would prefer to receive email for a domain. The MX record with the lowest number is preferred over the others, but you can set multiple email servers with the same value for simple load balancing.
Q: – How do you list and flush all IPtables ?
Ans:- First you use the –L switch to view all the currently present rules and then –F to flush them.
Q: – How To check Memory stats and CPU stats ?
Ans:- Using ‘free’ & ‘vmstat’ command we can display the physical and virtual memory statistics respectively.With the help of ‘sar’ command we see the CPU utilization & other stats.
Q: – What is a shell? What are their names?
Ans:- The shell is the part of the system with which the user interacts. A Unix shell interprets commands such as “pwd”, “cd” or “traceroute” and sends the proper instructions to the actual operating system itself. The shells currently available areAns SH, BASH, CSH, TCSH, NOLOGIN, KSH. Other functions of a shell include scripting capability, path memory, multitasking, and file handling.
Q: – Why is LVM is required ?
Ans:- LVM stands for Logical Volume Manager , to resize file system's size online we required LVM partition in Linux. Size of LVM partition can be extended and reduced using the lvextend & lvreduce commands respectively.
Q: – How to create partition from the raw disk ?
Ans:-Using fdisk utility we can create partitions from the raw disk.Below are the steps to create partition from the raw dsik :
– fdisk /dev/hd* (IDE) or /dev/sd* (SCSI)
– Type n to create a new partition
– After creating partition , type w command to write the changes to the partition table.
Q: – Where the kernel modules are located ?
Ans:- The ‘/lib/modules/kernel-version/’ directory stores all kernel modules or compiled drivers in Linux operating system. Also with ‘lsmod’ command we can see all the installed kernel modules.
Q: – How to check default route and routing table ?
Ans:-Using the Commands ‘netstat -nr’ and ‘route -n’ we can see the default route and routing tables.
Q: – How to check which ports are listening in my Linux Server ?
Ans:- Use the Command ‘netstat –listen’ and ‘lsof -i’
Q: – List the services that are enabled at a particular run level in linux server ?
Ans:- With the help of command ‘chkconfig –list | grep 5:on’ we can list all the service that are enabled in run level5. For other run levels just replace 5 with the respective run level
Q: – How to enable a service at a particular run level ?
Ans:-We can enable a service using the Command ‘chkconfig <Service-Name> on –level 3′
Q: – How to upgrade Kernel in Linux ?
Ans:- We should never upgrade Linux Kernel , always install the new New kernel using rpm command because upgrading a kernel can make your linux box in a unbootable state.