Linux Interview Questions and answers





File Structure in Linux
In Linux all the directories are organized in a tree-structure like manner
/- root directory in the mail and under root there are so many subdirectories
/home = where users profile will be stored
/usr = linux commands and utilities
/bin – binary executable programs
/lib – program libraries, similar to windows dll files
/sbin – more executable programs and linux utilities for administrative purpose
/tmp – temporary work firles
/etc- configuration files
/dev – device files that control drives, terminals and disks
/var – spolls, logs,mail are stored
/proc – system files
/opt – third party applications

Important Port numbers
FTP = 21
SSH = 22
SSL 443
TELNET = 23
SMTP = 25
POP3= 110
IMAP= 143
IMAPS=993
DNS = 53
DHCP(Server) = 67
DHCP(Client) = 68
TFTP = 69
HTTP = 80
HTTPS and SSL = 443
LDAP = 389
APACHE = 8080
SQUID = 3128
MYSQL = 3306
SMB = 445(udp)
Active Directory = 445 (tcp)

RAID
  • RAID 0 (striped disks) distributes data across several disks in a way that gives improved speed and no lost capacity, but all data on all disks will be lost if any one disk fails.
  • RAID 1 (mirrored settings/disks) duplicates data across every disk in the array, providing full redundancy. Two (or more) disks each store exactly the same data, at the same time, and at all times. Data is not lost as long as one disk survives. Total capacity of the array equals the capacity of the smallest disk in the array. At any given instant, the contents of each disk in the array are identical to that of every other disk in the array.
  • RAID 5 (striped disks with parity) combines three or more disks in a way that protects data against loss of any one disk; the storage capacity of the array is reduced by one disk.
  • RAID 6 (striped disks with dual parity) (less common) can recover from the loss of two disks.
  • RAID 10 (or 1+0) uses both striping and mirroring. "01" or "0+1" is sometimes distinguished from "10" or "1+0": a striped set of mirrored subsets and a mirrored set of striped subsets are both valid, but distinct, configurations.
2) OS Layers in Networking
Layer 7: Application Layer
Defines interface to user processes for communication and data transfer in network
Provides standardized services such as virtual terminal, file and job transfer and operations
Layer 6:Presentation Layer
Masks the differences of data formats between dissimilar systems
Specifies architecture-independent data transfer format
Encodes and decodes data; Encrypts and decrypts data; Compresses and decompresses data
Layer 5:Session Layer
Manages user sessions and dialogues
Controls establishment and termination of logic links between users
Reports upper layer errors
Layer 4:Transport Layer
Manages end-to-end message delivery in network
Provides reliable and sequential packet delivery through error recovery and flow control mechanisms
Provides connectionless oriented packet delivery
Layer 3:Network Layer
Determines how data are transferred between network devices
Routes packets according to unique network device addresses
Provides flow and congestion control to prevent network resource depletion
Layer 2:Data Link Layer
Defines procedures for operating the communication links
Frames packets
Detects and corrects packets transmit errors
Layer 1:Physical Layer
Defines physical means of sending data over network devices
Interfaces between network medium and devices
Defines optical, electrical and mechanical characteristics

3) Samba - Samba is a suite of programs that gives your Linux box the ability to speak SMB (Server Message Block). SMB is the protocol used to implement file sharing and printer services between computers running OS/2, Windows NT, Windows 95 and Windows for Workgroups. The protocol is analogous to a combination of NFS (Network File System), lpd (the standard UNIX printer server) and a distributed authentication framework such as NIS or Kerberos
Smb portnumber = 445 (udp)

4) Difference between TCP/UDP
TCP
1)TCP -Transmission control protocol
2)TCP is a connection oriented protocol.
3)slow transmission of data compare to UDP.
UDP
1)UDP -User Datagram protocol
2)UDP is connectionless protocol
3)Faster than TCP

5) Runlevels in Linux
Init Level
0
Runlevel 0 is reserved for the "shutdown" phase. Entering init 0 from the shell prompt will shutdown the system and usually power off the machine.
1
Runlevel 1 is usually for very basic commands. This is the equivalent to "safe mode" used by Windows. This level is usually only used to asses repairs or maintenance to the system. This is a single-user mode and does not allow other users to login to the machine.
2
Runlevel 2 is used to start most of the machines services. However, it does not start the network file sharing service (SMB, NFS). This will allows multiple users to login to the machine.
3
Runlevel 3 is commonly used by servers. This loads all services except the X windows system. This means the system will boot to the equivalent of DOS. No GUIs (KDE, Gnome) will start. This level allows multiple users to login to the machine.
4
Runlevel 4 is usually a "custom" level. By default it will start a few more services than level 3. This level is usually only used under special circumstances.
5
Runlevel 5 is everything! This will start any GUIs, extra services for printing, and 3rd party services. Full multi-users support also. This runlevel is generally used on by workstations.
6
Runlevel 6 is reserved for "reboot" only. Be carefully when running this command. Once you have entered init 6, there is no stopping it!

6) Boot Process in Linux
  • Bios - Load boot sector from one of Harddrive, cdrom, Floppy (Press del, f1, f2, or f10)
  • MBR(Master Boot Record) – Bios loads and execute the first 512 bytes off the disk (/dev/had)
  • GRUB (Grand Unified Boot Loader) – Grub menu will execute from /boot/grub/grub.conf
  • Kernel – Device detection: kernel will compile the device drivers and locate it to the corresponding devices.  Mounts root file system: After the device detection the kernel will mount the root file system as read only.  Load initial process: The very first process (init) is then loaded.
  • Initrd – Loads ramdisk image, Kernel runs /linuxrc (load modules, initialiase devices, )
  • Runlevels – default runlevel will execute
What is the difference between GRUB and LILO
Ans: GRUB understands the file system and LILO does not.

7) Linux Performance Tools
  • Top - The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. Type the top command:
  • Sar – Sar command is performance moniotoring tool. It can generate report and email them to sys admin. To use sar we required sysstat package.
  • Sar displays CPU and Queue, Disk I/0, Swap and Memory, CPU Interrupts, Networking and much more
  • Vmstate - vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity
  • Iostat - The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates i.e. it is useful to monitor disk throughput.
  • Free - The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel
  • Tools used for monitoring: ps , top, uptime, free, iostat, netstat, and vmstat
8) How many users log and using which applications
 Who w and finger command we can see how many users are loged in
 To check which processors are running by users ps –au sateesh

9) What is the difference between SSH and Telnet
SSH: SSH send the data's in Encrypted format
and SSH is a secure shell
Telnet: Telnet send the data's in Ascii format and its not a
secure shell

11) Procedure to add a swap file
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size): # dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area: # mkswap /swapfile1
d) Activate /swapfile1 swap space immediately: # swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi: # vi /etc/fstab
Append following line: /swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not? Simply use free command: $ free -m

Fields in the passwd File
The fields in the passwd file are separated by colons and contain the following information:
username:password:uid:gid:comment:home-directory:login-shell
For example:
kryten:x:101:100:Kryten Series 4000 Mechanoid:/export/home/kryten:/bin/csh

Fields in the shadow File
The fields in the shadow file are separated by colons and contain the following information:
username:password:lastchg:min:max:warn:inactive:expire
For example:
rimmer:86Kg/MNT/dGu.:8882:0::5:20:8978

Repairing Linux ext2 or ext3 file system
1) File system must be unmounted, you cannot repair it while it is running. Take system down to runlevel one (make sure you run all command as root user): # init 1
2)Unmount file system, for example if it is /home (/dev/sda3) file system then type command: # umount /home OR # umount /dev/sda3
3) Now run fsck on the partition: # fsck /dev/sda3
However be sure to specify the file system type using -t option. Recenly one of our sys admin run the command on ext3 file system w/o specifying file system. Result was more corruption as fsck by default assumes ext2 file system. # fsck -t ext3 /dev/sda3 OR # fsck.ext3 /dev/sda3
Tip if you don't know your file system type then typing mount command will display file system type.
fsck will check the file system and ask which problems should be fixed or corrected. If you don't wanna type y every time then you can use pass -y option to fsck. # fsck -y /dev/sda3
Please not if any files are recovered then they are placed in /home/lost+found directory by fsck command.
4) Once fsck finished, remount the file system: # mount /home
5) Go to multiuser mode # init 3
Read man page of fsck for more information. Make sure you replace /dev/sda3 with your actual device name.

How to check free space in linux
df –hT
du –hs /home
free



Linux Interview Questions and answers Linux Interview Questions and answers Reviewed by cloudwalebhaiya on October 30, 2017 Rating: 5

Scribe

http://feeds.feedburner.com/LinuxAndAws
Powered by Blogger.
X

Get Updates On

Linux Tutorial

AWS Tutorial

Devops Tutorial

We are going to send you our resources for free. To collect your copy at first, join our mailing list. So don't miss any updates, stay connected!