Linux interview questions Part 1

Q 1. Tell me the ways to see the process that listens a specific TCP port ?
Ans. We can use  lsof & netstat  to listens a specific TCP port.
  •  lsof : list open files including ports.
  • netstat : The netstat command symbolically displays the contents of various network-related data and information.

Q 2. What is a run level ?

Ans. A run level is a state of init and the whole system that defines what system services are operating. Run levels are identified by numbers. Some system administrators use run levels to define which subsystems are working, e.g., whether X is running, whether the network is operational, and so on.

Q 3. What are the differences between soft and hard link ?
Ans. Hard links are useful when the original file is getting moved around. For example, moving a file from /bin to /usr/bin or to /usr/local/bin. Any symlink to the file in /bin would be broken by this, but a hardlink, being a link directly to the inode for the file, wouldn’t care.

Q 4. What is a sparse file ?
Ans. A sparse file is a file which does not take more space on disk than needed. Such a file is usually used to store a partition image on disk, for instance with a virtualization solution like Xen. This can be particularly useful in situations where the full disk may never be completely used. One such situation would be virtual machines. If a virtual machine never fills the disk entirely, then a certain amount of the disk will never have anything but zeros in it – permitting the saving of disk space by using a sparse file.

Q 5. What is a zombie process ?
Ans. Zombie process 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.

Q 6. How do you setup system activity reporting ?
Ans. SAR is the system activity reporter.By interpreting the reports that sar produces, you can locate system bottlenecks and suggest some possible solutions to those annoying performance problems.The Linux kernel maintains internal counters that keep track of requests, completion times, I/O block counts, etc.From this and other information, sar calculates rates and ratios that give insight into where the bottlenecks are occurring.

Q 7. What are the differences between a process and a thread ?

Ans.
  • Each process is started with a primary thread, but can create additional threads when required.
  • Process run in separate address space, but threads of a process share address space.
  • Threads have direct access to data segment of its process; process have their own copy of data segment of parent process.
  • Threads can directly communicate with other threads of that process; processes must use inter-process communication to communicate with sibling processes.
  • New threads are easily created; new process require duplication of parent process, and allocation of memory and resources for it are costly.
  • Context switching between threads in the same process is typically faster than context switching between processes.

Q 8. What is load average ? 

Ans. Load Average is the value which represents the load on your system for a specific period of time. Also it can be considered the ratio of the number of active tasks to the number of available CPUs.You can use either top or uptime command to view the load average.
Q 9. How do you monitor system load ?
Ans. we can monitor system load via various commands like: uptime,top,vmstat,mpstat,pmap,iptraf,nmon,glances etc
Q 10. What are the steps to add a new disk to a Linux system ?
Ans.
  1. Shutdown your computer and  turn off  the  power  switch.
  2. Check  the jumper pins on the back of  your hdd.
  3. Insert  your  disk  in the  metal  drive  and  attach it.
  4. Connect the power cable to your new disk.
  5. Plug  the IDE cable into back of your disk.
  6. Reboot your machine.

and check  if  new  disk  is  add  with
fdisk  -l

Leave a Reply Cancel reply