Home / Linux Interview Questions From Real Interviewer

Linux Interview Questions From Real Interviewer

interview questions

Before we start a technical side, I think the first step to winning an interview is to go through with few things that will help you succeed.

Analyzing The Position

It would be best if you began with a systematic review of the job description. Your objective is to collect as much information as possible about the job and what knowledge and competencies are needed to perform your future career.

Take a close look at the official job description. Consider the environment in which the job is going to be performed. Are there any special skills required? What tools and software do you need to know to perform this job.

Make a note of any tools used to perform the tasks of the job, For instance, with the kind of servers, storage protocols, and operating systems they are using, and familiarise yourself with all those tools before the interview.

You can also talk with those who have held the job in the past. If you don’t know anyone, try to find them through linkedin.com and scan their profiles for tools and skillsets they have used.

Check what competencies and skills contributed to their success? Did the lack of specific competencies or skills cause or contribute to difficulties they experienced on the job?

What you should have and what interviewers are looking for

Before they offer you the contract for a long-term relationship with you, they want to know what’s in it for them.

  • Problem-solving skills. It would be best if you had a couple of stories in which you solved the problem independently. Bring any certificate if you got any. 
  • Good people skills. The ability to foster good working relationships is a vital business skill. Discuss situations where you worked well with others. For instance, you can narrate your stories of helping co-workers under challenging conditions.
  • Getting Things Done Skills. The ability to get things done. Mention those times when your good judgment or ingenuity helped you close a deal.

So let’s start our main topic for which you are visiting this post.

Tell us about your experience with Linux and the projects you have accomplished?

In response to this question, you should tell your experiences, such as your current or previous job experiences and all the big/small projects you have done. Don’t trust your present memory, and please write it down and try to be fluent in these details.

What is the difference between Linux & Unix?

Unix: It is considered the mother of most operating systems. It is a Proprietary operating system and original code developed by AT & T. Originally the Bourne shell. Compatible with PA and Itanium machines, and it is also compatible with many command interpreters. AIX and BSD are the renowned flavors of UNIX.

Linux: The code developed by Linus Torvalds. By default, the shell is BASH (Bourne Again Shell) and can use multiple shells. Ubuntu, Debian, and centos are the different flavors of Linux.

What is the shell?

I think the simplest answer is “shell is a language to communicate with a computer.”

Bash or the Bourne-Again Shell is the most widely used shell among Linux admins.

What is the structure of the Linux filesystem?

All files on a Linux system are stored on file systems, which are inverted into a single inverted tree of directories, known as a file-system hierarchy. This tree is invented because the root of the tree is to be at the top of the hierarchy, and the branches of directories and subdirectories stretch below the root.

LOCATION PURPOSE
/ Is the root directory at the top of the file-system hierarchy.
/usr It contains installed software, shared libraries, includes files and read-only program data. Subdirectories include /usr/bin user commands, /usr/sbin/ system admin commands, /usr/local: locally customized software
/etc configuration files specific to this system
/var variable data specific to this system that should persist between boots. Files that dynamically change such as databases, cache directories, log files, and website content the most famous one
/run Runtime data for processes started since the last system boots.
/home Home directories are where regular users store their personal data and configuration files
/tmp This directory has a world-writable space. Any user can put files here, and within 30 days, the files will be deleted.
   

Which directory contains regular commands and utilities?

/usr includes regular commands and utilities.

What is the root account?

The root account is a system administrator account and has all the powers to give you complete control of the system. 

Here you can create and maintain user accounts, assigning different permissions for each account. It is the default account every time you install Linux.

How to ensure that newly created users have passwords that must be changed every 90 days?

You can set password policy from the file /etc/login.defs by changing the value “PASS_MAX_Days” to 90.

How you will configure the administrative rights for all members of the group named consultants that its members are able to execute any command as any user?

Create the new file /etc/sudoers.d/consultants and add the following content to it. You can use the sudo vim /etc/sudoers.d/consultants command to perform this step.

%consultants ALL=(ALL) ALL

What are symbolic links?

Symbolic links are files that act as pointers to other files.

If you lost your root password, can you change the root password, and how?

We can reset the root password, and you can look into this link for the details.

What is initialzation?

The term “init” is the program on a Unix-like system which spawns all other processes. It runs as a daemon and typically has a PID 1.

What is a pstree?

This is the command to check the running processes.

What will you do if you receive the alert that your partition is full?

First of all, check which files are the biggest ones on the affected partition. In most cases, log files are there which are causing the troubles, so in this case, you can zip the file after nullifying.

How can you find out that how much memory is being used by your server?

You can take the help of different tools to find the memory usage on your system.

free - m

vmstat

top

htop

What is a recommendation of the SWAP partition under a Linux system?

The recommended size for a swap partition is twice the amount of physical memory available on the system. However, if you cant put the double in size, you can set the same amount as memory in your system.

How to display IP address?

ip address show

How to display the Network performance Statistics?

ip -s link show ens3       #ens3 is your interface

How to display the Routing table?

ip route

How to Tracing Route Taken by Traffic?

tracepath access.seimaxim.com
tracepath options ICMP ( -I) TCP (-T)

*traceroute command not installed by default

Troubleshooting Ports and Services?

ss command is meant to replace netstat

ss -ta
-n show numbers insted of names for interfaces and ports
-t show TCP sockets
-u Show UDP sockets
-l show listening sockets
-a show all ( listening and establisted)

How to show the status of the network devices?

       nmcli dev status

How to show the connection status?

         nmcli con show

How to list active connections?

     nmcli con show --active

How to control network connections?

You must be able to demonstrate how to control your network connections.

nmcli con up static-ens3
nmcli dev dis ens3
nmcli con show static-ens3
nmcli con reload
nmcli con down "static-ens3"
nmcli con up "static-ens3"

How to remove a network connection?

nmcli con del static-ens3

What are nmcli commands?

nmcli dev status : show the networkManagaer stusus of all netwokr interfaces
nmcli con show : List all connections
nmcli con show NAME : list the current settings for the connection name
nmcli con add con-name name Add a new connection named name
nmcli con mod name modify the connectiuon anem
nmcli con up name enable it and make it up
nmcli dev dis devf disconnects it.
nmacli con del name Deletes

How to change the System hostname?

hostnameclt set-hostname host@example.com
hostnamectl status
hostname

How to test the DNS name resolution?

host classroom.example.com
host IP

How to configure the name resolution without the DNS server?

Command to check the hostname in CentOS is getent hosts hostname

If you don’t have a DNS server, you can configure it through /etc/hosts.

getent hosts hostname command can test the hostname resolution using the /etc/hosts file.

How to Manage SELinux?

Selinux is a security rule set that determines which process can access which files, directories, and ports.
Every file process directory and the port has a unique security label called an SELinux context.

By default, the policy does not allow any interaction.

SELinux has several contexts: user, role, type, and sensitivity.

How to find out the current SELinux policy?

[root@servera ~]# grep '^SELINUX' /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted

If you want to disable SELinux, then replace enforcing to disabled and reboot the server.

How to Change SELinux context?

This is how you can change the /virtual context

semanage fcontext -a -t httpd_sys_content_t '/virtual(/.*)?'
restorecon -RFvv /virtual

How to check the current context?

ls -zD /virtual OR ls -Zd /var/www

How are you troubleshooting SELinux issues?

You can check the logs from autdit.log

tail /var/log/audit/audit.log

And do,

less /var/log/messages and search like this / sealert and copy past sealert -l b1c9cc8f-a953-4625-b79b-82c4f4f1fee3

ausearch -m AVC -ts recent

-ts time based search

How to check if ports are open or not?

There are many ways to perform this activity, but a few famous are shown below:

by using /etc/services

# cat /etc/services | grep " 123/"
Diagnostic Steps
by using netstat
# netstat -tulpn | grep :123
udp 0 0 0.0.0.0:123 0.0.0.0:* 26868/chronyd
udp6 0 0 :::123 :::* 26868/chronyd

By using nmap  (nmap is a utility for network discovery and security auditing)

# nmap -p 123 <server-ip>
By default nmap would give details of TCP port 123. To get details of 123/udp port use below command :
Raw
# nmap -sU -p 123 <server-ip>

what is systemd?

systemd uses units to manage different types of objects.

What are service units?

service units have service extensions and represent system services, for example, web servers.

What are socket units?

socket units have a .socket extension and represent inter-process communication sockets that systemd should monitor.

What are path units?

Path units have .path extension and are used to delay service activation until a specific file system change occurs.

What is systemctl?

It is used to manage units. you can get more information with systemctl -t help

How to check all the services and their status?

systemctl list-units --type=service

How to view the status of the service in Linux?

systemctl status name.type

systemctl status sshd.service

systemctl status chronyd

How to verify the status of the service?

systemctl is-active sshd.service

How to check if service is enabled during boot?

systemctl is-enabled sshd.service

How to check if the service is failed during boot?

systemctl is-failed sshd.service

how to display to check all the services failed during boot?

systemctl is-failed –type=service

How do you define the booting process?

  • The server is powered on. The system firmware runs a POST  (UFFI or BIOS) and stats to initialize the hardware.
  • System firmware searches for a bootable device.
  • System firmware reads a boot loader from the disk and then passes control of the system to the boot loader.
  • In CentOS boot loader is GRand Unified bootloader version 2 (GRUB2) which loads configuration from this file ( /boot/groub2/grub.cfg).
  • Now, you will have the option to select the kernel, and once you choose the kernel, the boot loader loads the kernel and Initramfs from the disk.
  • boot loader hands over the kernel to check the location of the intramfs in the memory. Here kernel initiates all the hardware by finding out the drivers.
  • systemd instance from intiramfs executes all units for the initrd.target.

What are the system Targets modes

systemd targets are represented by targets units, but in earlier versions, before CentOS 7, the system was coming with SysV runlevels.

How to check the default target?

systemctl get-default

How to view the target units?

systemctl list-units --type target --all

How to change the default target?

systemctl get-default

systemctl set-default multi-user.target

reboot

How to boot in the rescue mode?

systemctl rescue

How to check the available subscription?

subscription-manager list --available | less

How to attach the subscription?

subscription-manager attach --auto

The most essential yum command

yum help
yum list 'http*'
yum search all 'web server'
yum info httpd
yum provides /var/www/html
yum list kernel
yum remove httpd

yum group list
yum group "RPM Development Tools"


At what location system save your repo files?

/etc/yum.repos.d/errata.repo

How to check which repos are attached to the system? 

yum repolist all

Leave a Reply