Top Linux Interview Questions


Here are the top 10 Linux interview questions

How can you see which kernel version a system is currently using?
Answer:- The answer is uname. uname prints out the system information. specifically with -aflag will give you all the system parameters. It will show you hostname, OS, kernel, release, kernel version.
#uname -a

How can you check system’s current IP address?

Answer:- This question can be asked in many other ways like, What is your IP for eth0 interface or what is your IPv6 address? So there’s generally two ways to know that. Old and the new way. The old way is: ifconfig interface. you can simply type ifconnfig to list network information for all the networking interfaces.
#ifconfig eth0
And the new way to do this is using IP command. you can type ip addr show and it will give you all the network specifications for all of your networking devices or you can add one more argument as device name in this command to show device specific information.
#ip addr show eth0

How do you check for free disk space?

Answere:- Other versions of this question are “How would you check how much disk space is left” or “What percentage of disk space are you using?” Don’t get tripped up by different ways of asking these. For this question the command df is your friend. To show all file systems in human readable form issue this command with –ah flags as shown below.
#df -ah

How do you manage services on a system?

Answer:- Managing services is a completely normal part of being a Linux sys-admin or working with Linux in general. Don’t be surprised if someone asks you how would you see if service is running or how would you start or stop a service or how would you reload a service. Most major Linux distributions have switched to systemd however in older system you would follow the structure given below.
#service servicename status
#service servicename start
#service servicename reload
#service servicenae stop
On a newer systemd system you would use systemctl  command.
#systemctl status servicename
#systemctl start servicename
#systemctl stop servicename
#systemctl restart servicename

How would you check the size of a directory’s contents on disk?

#du -sh /directory-name
This command will go ahead and telly up the disk usage for the given directory

How would you check for open ports on Linux machine?

Answer:- This question can be asked in couple of different ways such as “check network listing sockets” and “check for services that are listening on TCP/UDP ports or sockets”. So ff you hear the word “open ports” or “running services” start thinking about the command netstat. by default the netstat command will give you uselessly big output. It meant to be filtered down with other Linux or Unix tools.  Run the netstat command as show below with following arguments.
#netstat -tulpn
This command will filter the output. It will show you the local address that services are listening on along with the PID. Make sure to use this command with root privileges otherwise it won’t show the PID.

How would you check CPU usage for a given process?

#ps -aux | grep processname
We used pipe in this command if you are not familiar with this then we highly recommend to read some basic bash rules and properties. You can also use real-time resource monitor utility name top.

How would you mount new devices?

Answer:- Linux generally has directory called mnt in root file-system for mounting new storage devices but you can mount the new storage device wherever you like. we would use mount command in given structure.
#mount /dev/device-name /mountpoint
mount /dev/sda1 /mnt
Likewise checking for existing mounts you would just run the command mount with no arguments.

How do you look up something you don’t know?

Answer:- Finally the most important part. To look up some information on something you don’t know we would use the man  pages. using man pages is really easy. you just have to type “man<command name>” and this will show you the full manual of the command. You can quickly go through this and find your information.”
#man httpd
#man netstat
#man systemctl
If you are still confused about these simple Linux interview questions, You can also check out Linux Commands – cheat sheet to understand the basic of Linux system.

Post a Comment

Previous Post Next Post

translate