Top 30 Linux System Interview Questions & Answers In this article we will discuss top 30 linux system interview questions with the answers for experience professionals. Below mentioned questions may help the readers to clear Linux interviews. If you like these questions , please don’t hesitate to share on Facebook, google+ and Twitter. Q:1 Why LVM is required ? Ans: LVM stands for Logical Volume Manager , to resize filesystem’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:2 How To check Memory stats and U 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 U utilization & other stats. Q:3 What does Sar provides and at which location Sar logs are stored ? Ans: Sar Collect, report, or save system activity information. The default version of the sar command (U utilization report) might be one of the first facilities the runs to begin system activity investigation, because it monitors major system resources. If U utilization is near 100 percent ( + nice + system), the workload sampled is U-bound. By default log files of Sar command is located at /var/log/sa/sadd file, where the dd parameter indicates the current day. Q:4 How to increase the size of LVM partition ? Ans: Below are the Logical Steps : – Use the lvextend command (lvextend -L +100M /dev/
, in this example we are extending the size by 100MB. – resize2fs /dev/
– check the size of partition using ‘df -h’ command Q:5 How to reduce or shrink the size of LVM partition ? Ans: Below are the logical Steps to reduce size of LVM partition : -Umount the filesystem using umount command, -use resize2fs command , e.g resiz2fs /dev/mapper/myvg-mylv 10G -Now use the lvreduce command , e.g lvreduce -L 10G /dev/mapper/myvg-mylv Above Command will shrink the size & will make the filesystem size 10GB.
Q:6 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:7 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:8 What is umask ? Ans: umask stands for ‘ file creation mask’, which determines the settings of a mask that controls which file permissions are set for files and directories when they are created. Q:9 How to set the umask permanently for a ? Ans: To set this value permanently for a , it has to be put in the appropriate profile file which depends on the default shell of the . Q:10 How to change the default run level in linux ? Ans: To change the run level we have to edit the file “/etc/inittab” and change initdefault entry ( id:5:initdefault:). Using ‘init’ command we change the run level temporary like ‘init 3’ , this command will move the system in runlevl 3. Q:11 How to share a directory using nfs ? Ans: To share a directory using nfs , first edit the configuration file ‘/etc/exportfs’ , add a entry like ‘/
(Options)’ and then restart the nfs service. Q:12 How to check and mount nfs share ? Ans: Using ‘showmount’ command we can see what directories are shared via nfs e.g ‘showmount -e
’.Using mount command we can mount the nfs share on linux machine. Q:13 What are the default ports used for SMTP,DNS,FTP,DH,SSH and squid ? Ans: Service Port SMTP 25 DNS 53 FTP 20 (data transfer) , 21 ( Connection established)
DH SSH Squid
67/UDP(dh server) , 68/UDP(dh client) 22 3128
Q:14 What is Network Bonding ? Ans: Network bonding is the aggregation of multiple Lan cards into a single bonded interface to provide fault tolerance and high performance. Network bonding is also known as NIC Teaming. Q:15 What are the different modes of Network bonding in Linux ? Ans: Below are list of modes used in Network Bonding : balance-rr or 0 – round-robin mode for fault tolerance and load balancing. active-backup or 1 – Sets active-backup mode for fault tolerance. balance-xor or 2 – Sets an XOR (exclusive-or) mode for fault tolerance and load balancing. broadcast or 3 – Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces. 802.3ad or 4 – Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings. balance-tlb or 5 – Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing. balance-alb or 6 – Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing. Q:16 How to check and the status the bond interface. Ans: Using the command ‘cat /proc/net/bonding/bond0’ , we can check which mode is enabled and what lan cards are used in this bond. In this example we have one only one bond interface but we can have multiple bond interface like bond1,bond2 and so on. Q:17 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:18 How to check which ports are listening in my Linux Server ? Ans: Use the Command ‘netstat –listen’ and ‘lsof -i’ Q:19 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:20 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:21 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 kenel can make your linux box in a unbootable state. Q:22 How To scan newly asssigned luns on linux box without rebooting ? Ans: There are two ways to scan newly assigned luns : Method:1 if sg3 rpm is installed , then run the command ‘rescan-scsi-bus.sh’ Method:2 Run the Command , echo ” – – – ” > /sys/class/scsi_host/hostX/scan Q:23 How to find WWN numbers of HBA cards in Linux Server ? Ans: We can find the WWN numbers of HBA cards using the command ‘systool -c fc_host -v | grep port_name’ Q:24 How to add & change the Kernel parameters ? Ans: To Set the kernel parameters in linux , first edit the file ‘/etc/sysctl.conf’ after making the changes save the file and run the command ‘sysctl -p’ , this command will make the changes permanently without rebooting the machine. Q:25 What is Puppet Server ? Ans: Puppet is an open-source & enterprise software for configuration management toll in UNIX like operating system. Puppet is a IT automation software used to push configuration to its clients (puppet agents) using code. Puppet code can do a variety of tasks from installing new software, to check file permissions, or updating s & lots of other tasks. Q:26 What are manifests in Puppet ? Ans: Manifests in Puppet are the files in which the client configuration is specified. Q:27 Which Command is used to sign requested certificates in Puppet Server ? Ans: ‘puppetca –sign hostname-of-agent’ in (2.X) & ‘puppet ca sign hostname-ofagent’ in (3.X) Q:28 At which location Puppet Master Stores Certificates ? Ans: /var/lib/puppet/ssl/ca/signed Q:29 How to find all the regular files in a directory ?
Ans: using the command ‘find /
Interview Questions for Systems s The role of the systems is strong and the job’s outlook is healthy, with the Bureau of Labor Statistics predicting growth of about 11.7 percent between 2012 and 2022. That should create approximately 42,900 new positions. What makes one sys stand out from others? Curiousity, according to “Ski” Kacoroski, who services more than 3,000 s as assistant systems for the Northshore School District in Bothell, Wash. He also serves as vice president for LOPSA, the League of Professional Systems s. Click here to find systems jobs. Curiosity begets in-depth troubleshooting, a deep understanding of network architecture and proactive problem resolution, he says. “You’ll encounter more problems if you settle for a quick fix like rebooting the server,” Kacoroski explains. “You need curiosity to discover the root cause of problems and optimize network performance by preventing further issues.” During interviews, Kacoroski asks these questions to identify system s with deep knowledge of operating systems and inquiring minds. What happens when I type this at a shell prompt: “telnet www.wikipedia.org?”
What Most People Say: “You’ll connect to the Wikipedia server through port 80.” What You Should Say: “How much time do I have to answer? Fifteen minutes? Great. I’ll walk you through every step and connection in the process.” Why You Should Say It: A systems must be able to troubleshoot the entire stack because you never know where the source of a problem lies, says Kacoroski. You need to prove that you know where to look for problems to distinguish yourself during an interview.
A stakeholder gives you a six-hour task that must be completed today. Later, another gives you a six-hour project with the same deadline. Neither will budge. What do you do?
What Most People Say: “I’d prioritize the most high profile project or the request from the well-connected stakeholder.” Or, “I’d stay until I finish both projects.”
What You Should Say: “I’d come up with a few solutions and run them by my manager.” Why You Should Say It: Systems s make recommendations, not decisions, notes Kacoroski. Inexperienced professionals don’t understand their role, so they’ll mistakenly try to complete both projects. “Systems s don’t understand all the political ramifications, cost constraints or technical challenges that impact decisions,” Kacoroski says. “It’s better to play a ing role and let your manager make the tough calls.”
An HTTP monitor says the website is down. You can telnet to the port. What do you do?
What Most People Say: “I’d check to see if the Web page is up. If it is, I’d assume there was something wrong with the monitor and alert the hardware guys.” What You Should Say: “If the Web page is up when I telnet to the port, I’d ask how long the monitor has been down. Then, I’d check to see if the outage was due to flapping, a system outage or a system overload that occurred during back-up. I’ll modify the monitor, once I identify the issue. Should I describe my troubleshooting process?” Why You Should Say It: The best systems s want to understand why a problem occurred to keep it from cropping up again. Be ready to walk the interviewer through your troubleshooting process even if they ask you to fix a simulated problem on a virtual machine.
How have you used your knowledge of operating systems to optimize the network?
What Most People Say: “I’ve connected s to the underlying hardware and used the operating system as a resource manager.” What You Should Say: “I’ve used an operating systems to track files, manage data input and output on multiple devices and allocate resources such as U, RAM, disk, network, video and sound to various processes. Beyond the basics, I’ve used my knowledge of various operating systems to improve system design and architecture and run apps more efficiently. May I share an example?” Why You Should Say It: Systems s do more than troubleshoot: They’re responsible for optimizing the processing environment. The more you know about how an operating system works, the better you’ll be at planning and deg a stable and efficient network and ensuring that all components work effectively together.
Name three characteristics of a systems that you possess.
What Most People Say: “I’m a good communicator with great troubleshooting skills. I can’t think of a third.” What You Should Say: “I like helping people. I’m curious about how systems work and I’m ionate about fixing things right.” Why You Should Say It: Understanding the traits that lead to success is critical. Other desirable traits for systems s include risk aversion, persistence and the ability to get things done.
What do you do when your initial solution to a problem fails?
What Most People Say: “I keep trying different things until the problem is fixed.”
What You Should Say: “I always have a Plan B and a Plan C in case my initial solutions fails. Here’s an example.” Why You Should Say It: Systems s can’t be afraid to fail, Kacoroski believes. “You always need a back-up plan because the first fix rarely works,” he says. “Top candidates can articulate their problem-solving progression and what they’ve learned from their mistakes.”
[⬆] General Questions:
What did you learn yesterday/this week? Talk about your preferred development/istration environment. (OS, Editor, Browsers, Tools etc.) Tell me about the last major Linux project you finished. Tell me about the biggest mistake you've made in [some recent time period] and how you would do it differently today. What did you learn from this experience? Why we must choose you? What function does DNS play on a network? What is HTTP? What is an HTTP proxy and how does it work? Describe briefly how HTTPS works. What is SMTP? Give the basic scenario of how a mail message is delivered via SMTP. What is RAID? What is RAID0, RAID1, RAID5, RAID10? What is a level 0 backup? What is an incremental backup? Describe the general file system hierarchy of a Linux system.
[⬆] Simple Linux Questions:
What is the name and the UID of the ? How to list all files, including hidden one, in a directory? What is the Unix/Linux command to remove a directory and its contents? Which command will show you free/used memory? Does free memory exist on Linux? How to search for the string "my konfi is the best" in files of a directory recursively? How to connect to a remote server or what is SSH? How to get all environment variables and how can you use them? I get "command not found" when I run ifconfig -a. What can be wrong? What happens if I type TAB-TAB? What command will show the available disk space on the Unix/Linux system? What commands do you know that can be used to check DNS records? What Unix/Linux commands will alter a files ownership, files permissions? What does chmod +x FILENAMEdo? What does the permission 0750 on a file mean? What does the permission 0750 on a directory mean? How to add a new system without permissions? How to add/remove a group from a ? What is a bash alias? How do you set the mail address of the root/a ? What does CTRL-c do? What is in /etc/services?
How to redirect STDOUT and STDERR in bash? (> /dev/null 2>&1) What is the difference between UNIX and Linux. What is the difference between Telnet and SSH? Explain the three load averages and what do they indicate.
[⬆] Medium Linux Questions:
What do the following commands do and how would you use them? o tee o awk o tr o cut o tac o curl o wget o watch o head o tail What does a & after a command do? What does & disown after a command do? What is a packet filter and how does it work? What is Virtual Memory? What is swap and what is it used for? What is an A record, an NS record, a PTR record, a CNAME record, an MX record? Are there any other RRs and what are they used for? What is a Split-Horizon DNS? What is the sticky bit? What does the immutable bit to a file? What is the difference between hardlinks and symlinks? What happens when you remove the source to a symlink/hardlink? What is an inode and what fields are stored in an inode? Howto force/trigger a file system check on next reboot? What is SNMP and what is it used for? What is a runlevel and how to get the current runlevel? What is SSH port forwarding? What is the difference between local and remote port forwarding? What are the steps to add a to a system without using add/add? What is MAJOR and MINOR numbers of special files? Describe a scenario when you get a "filesystem is full" error, but 'df' shows there is free space. Describe a scenario when deleting a file, but 'df' not showing the space being freed. Describe how 'ps' works. What happens to a child process that dies and has no parent process to wait for it and what’s bad about this? Explain briefly each one of the process states. How to know which process listens on a specific port? What is a zombie process and what could be the cause of it? You run a bash script and you want to see its output on your terminal and save it to a file at the same time. How could you do it? Explain what echo "1" > /proc/sys/net/ipv4/ip_forward does. Describe briefly the steps you need to take in order to create and install a valid certificate for the site https://foo.example.com. Can you have several HTTPS virtual hosts sharing the same IP? What is a wildcard certificate?
Which Linux file types do you know? What is the difference between a process and a thread? And parent and child processes after a fork system call? What is the difference between exec and fork? What is "nohup" used for? What is the difference between these two commands? o myvar=hello o export myvar=hello How many NTP servers would you configure in your local ntp.conf? What does the column 'reach' mean in ntpq -p output? You need to upgrade kernel at 100-1000 servers, how you would do this? How can you get Host, Channel, ID, LUN of SCSI disk? How can you limit process memory usage?
[⬆] Hard Linux Questions:
What is a tunnel and how you can by a http proxy? What is the difference between IDS and IPS? What shortcuts do you use on a regular basis? What is the Linux Standard Base? What is an atomic operation? Your freshly configured http server is not running after a restart, what can you do? What kind of keys are in ~/.ssh/authorized_keys and what it is this file used for? I've added my public ssh key into authorized_keys but I'm still getting a prompt, what can be wrong? Did you ever create RPM's, DEB's or solaris pkg's? What does :(){ :|:& };: do on your system? How do you catch a Linux signal on a script? Can you catch a SIGKILL? What's happening when the Linux kernel is starting the OOM killer and how does it choose which process to kill first? Describe the linux boot process with as much detail as possible, starting from when the system is powered on and ending when you get a prompt. What's a chroot jail? When trying to umount a directory it says it's busy, how to find out which PID holds the directory? What's LD_PRELOAD and when it's used? You ran a binary and nothing happened. How would you debug this? What are cgroups? Can you specify a scenario where you could use them?
[⬆] Expert Linux Questions:
A running process gets EAGAIN: Resource temporarily unavailable on reading a socket. How can you close this bad socket/file descriptor without killing the process?
[⬆] Networking Questions:
What is localhost and why would ping localhost fail? What is the similarity between "ping" & "traceroute" ? How is traceroute able to find the hops. What is the command used to show all open ports and/or socket connections on a machine? Is 300.168.0.123 a valid IPv4 address? Which IP ranges/subnets are "private" or "non-routable" (RFC 1918)?
What is a VLAN? What is ARP and what is it used for? What is the difference between T and UDP? What is the purpose of a default gateway? What is command used to show the routing table on a Linux box? A T connection on a network can be uniquely defined by 4 things. What are those things? When a client running a web browser connects to a web server, what is the source port and what is the destination port of the connection? How do you add an IPv6 address to a specific interface? You have added an IPv4 and IPv6 address to interface eth0. A ping to the v4 address is working but a ping to the v6 address gives yout the response sendmsg: operation not permitted. What could be wrong? What is SNAT and when should be used? Explain how could you ssh into a Linux system that DROPs all new incomming packets using a SSH tunnel. How do you stop a DDoS? How can you see content of ip packet?
[⬆] MySQL questions:
How do you create a ? How do you provide privileges to a ? What is the difference between a "left" and a "right" ? Explain briefly the differences between InnoDB and MyISAM. Describe briefly the steps you need to follow in order to create a simple master/slave cluster. Why should you run "mysql_secure_installation" after installing MySQL? How do you check which jobs are running?
[⬆] DevOps Questions:
Can you describe your workflow when you create a script? What is GIT? What is a dynamically/statically linked file? What does "configure && make && make install" do? What is puppet/chef/ansible used for? How do you create a new postgres ? What is a virtual IP address? What is a cluster? How do you print all strings of printable characters present in a file? How do you find shared library dependencies? What is Automake and Autoconf? ./configure shows an error that libfoobar is missing on your system, how could you fix this, what could be wrong? What are the Advantages/disadvantages of script vs compiled program? What's the relationship between continuous delivery and DevOps? What are the important aspects of a system of continous integration and deployment?
[⬆] Fun Questions:
A careless sys executes the following command: chmod 444 /bin/chmod - what do you do to fix this? I've lost my root , what can I do?
I've rebooted a remote server but after 10 minutes I'm still not able to ssh into it, what can be wrong? If you were stuck on a desert island with only 5 command-line utilities, which would you choose? You come across a random computer and it appears to be a command console for the universe. What is the first thing you type? Tell me about a creative way that you've used SSH? You have deleted by error a running script, what could you do to restore it?
[⬆] Demo Time:
Unpack test.tar.gz without man pages or google. Remove all "*.pyc" files from testdir recursively? Search for "my konfu is the best" in all *.py files. Replace the occurrence of "my konfu is the best" with "I'm a linux jedi master" in all *.txt files. Test if port 443 on a machine with IP address X.X.X.X is reachable. Get http://myinternal.webserver.local/test.html via telnet. How to send an email without a mail client, just on the command line? Write a get_prim method in python/perl/bash/pseudo. Find all files which have been accessed within the last 30 days. Explain the following command (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log Write a script to list all the differences between two directories. In a log file with contents as <TIME> : [MESSAGE] : [ERROR_NO] - Human readable text display summary/count of specific error numbers that occured every hour or a specific hour.
++++++++++++++++++++++++++++++ So what does nohup do? Imagine you are logged on to another computer remotely using ssh and you want to run a command that takes a long time and then exit the ssh session but leave the command running even though you are no longer connected then nohup lets you do just that. To use nohup all I have to type is nohup followed by the command as follows: nohup wget http://mirror.is.co.za/mirrors/linuxmint.com/iso//stable/17.1/linuxmint-17.1cinnamon-64bit.iso & wget How To: Read URL’s from a file You can store number of URL’s in text file and them with -i option. Below we have created tmp.txt under wget directory where we put series of URL’s to .
# wget -i /wget/tmp.txt Resume uncompleted In case of big file , it may happen sometime to stop in that case we can resume the same file where it was left off with -c option. But when you start file without specifying -c option wget will add .1 extension at the end of file, considering as a fresh . So, it’s good practice to add -c switch when you big files. # wget -c http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64LiveDVD.iso
files in background With -b option you can send in background immediately after start and logs are written in /wget/log.txt file. # wget -b /wget/log.txt ftp://ftp.iinet.net.au/debian/debian-cd/6.0.5/i386/iso-dvd/debian6.0.5-i386-DVD-1.iso
Restrict speed limits With Option –limit-rate=100k, the speed limit is restricted to 100k and the logs will be created under /wget/log.txt as shown below. # wget -c --limit-rate=100k /wget/log.txt ftp://ftp.iinet.net.au/debian/debiancd/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso
Restricted FTP and HTTP s with name and With Options –http-=name, –http-= & –ftp-=name, –ftp-=, you can restricted HTTP or FTP sites as shown below. # wget --http-=narad --http-= http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso # wget --ftp-=narad --ftp-= ftp://ftp.iinet.net.au/debian/debiancd/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso