Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Interview Questions & Answers Complete Guide for Linux

Table of Contents

Linux


What is your experience with Linux?

Explain what each of the following commands does and give an example on how to use it:

Explain each field in the output of ls -l command

What are hidden files/directories? How to list them?

Explain what each of the following commands does and give an example on how to use it:

  • sed
  • grep
  • cut
  • awk

What each of the following commands does?

  • pwd
  • cd
  • find
  • ls

What each of the following commands does?

  • cd /
  • cd ~
  • cd
  • cd ..
  • cd .
  • cd –

How to rename the name of a file or a directory?

Specify which command would you use (and how) for each of the following scenarios

Remove a directory with files

Display the content of a file

Provides access to the file /tmp/x for everyone

Change working directory to user home directory

Replace every occurrence of the word “good” with “great” in the file /tmp/y

How can you check what is the path of a certain command?

Explain redirection

Explain piping. How do you perform piping?

Fix the following commands:

  • sed “s/1/2/g’ /tmp/myFile
    = find . -iname *.yaml -exec sed -i “s/1/2/g” {} ;

Linux FHS


In Linux FHS (Filesystem Hierarchy Standard) what is the /?

What is stored in each of the following paths?

  • /bin, /sbin, /usr/bin and /usr/sbin
  • /etc
  • /home
  • /var
  • /tmp

What is special about the /tmp directory when compared to other directories?

What kind of information one can find in /proc?

Can you create files in /proc?

In which path can you find the system devices (e.g. block storage)?

Running the command df you get “command not found”. What could be wrong and how to fix it?

How do you schedule tasks periodically?

How to check which commands you executed in the past?

Linux Permissions


How to change the permissions of a file?

What does the following permissions mean?:

  • 777
  • 644
  • 750

What this command does? chmod +x some_file

Explain what is setgid and setuid

What is the purpose of sticky bit?

What the following commands do?

  • chmod
  • chown
  • chgrp

What is sudo? How do you set it up?

True or False? In order to install packages on the system one must be the root user or use the sudo command

Explain what are ACLs. For what use cases would you recommend to use them?

You try to create a file but it fails. Name at least three different reason as to why it could happen

Linux Shell Scripting


What this line in scripts mean?: #!/bin/bash

True or False?: when a certain command/line fails, the script, by default, will exit and will no keep running

Explain what would be the result of each command:

  • echo $0
  • echo $?
  • echo $$
  • echo $@
  • echo $#

How do you debug shell scripts?

How do you get input from the user in shell scripts?

Explain continue and break. When do you use them if at all?

How to store the output of a command in a variable?

How do you check variable length?

Can you give an example to some Bash best practices?

What is the ternary operator? How do you use it in bash?

What does the following code do and when would you use it?

diff <(ls /tmp) <(ls /var/tmp)

Linux systemd


What is systemd?

On a system which uses systemd, how would you display the logs?

Describe how to make a certain process/app a service

Linux Debugging


Where system logs are located?

How to follow file’s content as it being appended without opening the file every time?

What are you using for troubleshooting and debugging network issues?

What are you using for troubleshooting and debugging disk & file system issues?

What are you using for troubleshooting and debugging process issues?

What are you using for debugging CPU related issues?

You get a call from someone claiming “my system is SLOW”. What do you do?

Explain iostat output

How to debug binaries?

What is the difference between CPU load and utilization?

How you measure time execution of a program?

Linux Kernel


What is a kernel, and what does it do?

How do you find out which Kernel version your system is using?

What is a Linux kernel module and how do you load a new module?

Explain user space vs. kernel space

What are system calls? What system calls are you familiar with?

Linux Virtualization


What virtualization solutions are available for Linux?

What is KVM?

Linux SSH


What is SSH? How to check if a Linux server is running SSH?

Why SSH is considered better than telnet?

What is stored in ~/.ssh/known_hosts?

What is the difference between SSH and SSL?

What ssh-keygen is used for?

What is SSH port forwarding?

Linux – Globbing, Wildcards


What is Globbing?

What are wildcards? Can you give an example of how to use them?

Explain what will ls [XYZ] match

Explain what will ls [^XYZ] match

Explain what will ls [0-5] match

What each of the following matches

  • ?
  • *

What do we grep for in each of the following commands?:

  • grep ‘[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}’ some_file
  • grep -E “error|failure” some_file
  • grep ‘[0-9]$’ some_file

Which line numbers will be printed when running grep '\baaa\b' on the following content:

  • aaa bbb ccc.aaa aaaaaa

What is the difference single and double quotes?

What is escaping? What escape character is used for escaping?

What is an exit code? What exit codes are you familiar with?

Linux Boot Process


Tell me everything you know about the Linux boot process

What is GRUB2?

What is Secure Boot?

What can you find in /boot?

Linux Disk & Filesystem


What’s an inode?

Which of the following is not included in inode:

  • Link count
  • File size
  • File name
  • File timestamp

How to check which disks are currently mounted?

You run the mount command but you get no output. How would you check what mounts you have on your system?

What is the difference between a soft link and hard link?

True or False? You can create an hard link for a directory

True or False? You can create a soft link between different filesystems

What happens when you delete the original file in case of soft link and hard link?

Can you check what type of filesystem is used in /home?

What is a swap partition? What is it used for?

How to create a new empty file

How would you check what is the size of a certain directory?

What is LVM?

Explain the following in regards to LVM:

  • PV
  • VG
  • LV

What is NFS? What is it used for?

What RAID is used for? Can you explain the differences between RAID 0, 1, 5 and 10?

Describe the process of extending a filesystem disk space

What is lazy umount?

What is tmpfs?

What is stored in each of the following logs?

  • /var/log/messages
  • /var/log/boot.log

Linux Performance Analysis


How to check what is the current load average?

You know how to see the load average, great. but what each part of it means? for example 1.43, 2.34, 2.78

How to check process usage?

How to check disk I/O?

How to check how much free memory a system has? How to check memory consumption by each process?

How to check TCP stats?

Linux Processes


how to list all the processes running in your system?

How to run a process in the background and why to do that in the first place?

How can you find how much memory a specific process consumes?

What signal is used by default when you run ‘kill process id‘?

What signals are you familiar with?

What kill 0 does?

What kill -0 does?

What is a trap?

Every couple of days, a certain process stops running. How can you look into why it’s happening?

What happens when you press ctrl + c?

What is a Daemon in Linux?

What are the possible states of a process in Linux?

How do you kill a process in D state?

What is a zombie process?

How to get rid of zombie processes?

How to find all the

Processes executed/owned by a certain user

Process which are Java processes

Zombie Processes

What is the init process?

Can you describe how processes are being created?

How to change the priority of a process? Why would you want to do that?

Can you explain how network process/connection is established and how it’s terminated?>

What strace does? What about ltrace?

Find all the files which end with ‘.yml’ and replace the number 1 in 2 in each file

You run ls and you get “/lib/ld-linux-armhf.so.3 no such file or directory”. What is the problem?

How would you split a 50 lines file into 2 files of 25 lines each?

What is a file descriptor? What file descriptors are you familiar with?

What is NTP? What is it used for?

Explain Kernel OOM

Linux Security


What is chroot? In what scenarios would you consider using it?

What is SELiunx?

What is Kerberos?

What is nftables?

What firewalld daemon is responsible for?

Do you have experience with hardening servers? Can you describe the process?

Linux Networking


How to list all the interfaces?

What is the loopback (lo) interface?

What the following commands are used for?

  • ip addr
  • ip route
  • ip link
  • ping
  • netstat
  • traceroute

What is a network namespace? What is it used for?

How to check if a certain port is being used?

How can you turn your Linux server into a router?

What is a virtual IP? In what situation would you use it?

True or False? The MAC address of an interface is assigned/set by the OS

Can you have more than one default gateway in a given system?

Which port is used in each of the following protocols?:

  • SSH
  • SMTP
  • HTTP
  • DNS
  • HTTPS

What is telnet and why is it a bad idea to use it in production? (or at all)

What is the routing table? How do you view it?

How can you send an HTTP request from your shell?

What are packet sniffers? Have you used one in the past? If yes, which packet sniffers have you used and for what purpose?

How to list active connections?

How to trigger neighbor discovery in IPv6?

What is network interface bonding and do you know how it’s performed in Linux?

What network bonding modes are there?

What is a bridge? How it’s added in Linux OS?

Linux DNS


How to check what is the hostname of the system?

What the file /etc/resolv.conf is used for? What does it include?

What commands are you using for performing DNS queries (or troubleshoot DNS related issues)?

Linux Packaging


Do you have experience with packaging? (as in building packages) Can you explain how does it works?

How packages installation/removal is performed on the distribution you are using?

RPM: explain the spec format (what it should and can include)

How do you list the content of a package without actually installing it?

How to know to which package a file on the system belongs to? Is it a problem if it doesn’t belongs to any package?

Where repositories are stored? (based on the distribution you are using)

What is an archive? How do you create one in Linux?

How to extract the content of an archive?

Why do we need package managers? Why not simply creating archives and publish them?

Linux DNF


How to look for a package that provides the command /usr/bin/git? (the package isn’t necessarily installed)

Linux Applications and Services

What can you find in /etc/services?

How to make sure a Service starts automatically after a reboot or crash?

You run ssh 127.0.0.1 but it fails with “connection refused”. What could be the problem?

How to print the shared libraries required by a certain program? What is it useful for?

What is CUPS?

What types of web servers are you familiar with?

Linux Users and Groups


What is a “superuser” (or root user)? How is it different from regular users?

How do you create users? Where user information is stored?

Which file stores information about groups?

How do you change/set the password of a user?

Which file stores users passwords? Is it visible for everyone?

Do you know how to create a new user without using adduser/useradd command?

What information is stored in /etc/passwd? explain each field

How to add a new user to the system without providing him the ability to log-in into the system?

How to switch to another user? How to switch to the root user?

What is the UID the root user? What about a regular user?

What can you do if you lost/forogt the root password?

What is /etc/skel?

How to see a list of who logged-in to the system?

Explain what each of the following commands does:

  • useradd
  • usermod
  • whoami
  • id

Linux Hardware


Where can you find information on the processor?

How can you print information on the BIOS, motherboard, processor and RAM?

How can you print all the information on connected block devices in your system?

Linux – Random


Give 5 commands which are two letters long

What ways are there for creating a new empty file?

How cd - works? How does it knows the previous location?

List three ways to print all the files in the current directory

How to count the number of lines in a file? What about words?

You define x=2 in /etc/bashrc and x=6 ~/.bashrc you then login to the system. What would be the value of x?

What is the difference between man and info?

Explain “environment variables”. How do you list all environment variables?

How to create your own environment variables?

What a double dash (–) mean?

Linux – AWK


What the awk command does? Have you used it? What for?

How to print the 4th column in a file?

How to print every line that is longer than 79 characters?

What the lsof command does? Have you used it? What for?

What is the difference between find and locate?

System Calls


Explain the fork() system call

Explain the exec() system call

What system call is used for listing files?

What system call is used for creating a new process?

What are the differences between exec() and fork()?

Why do we need the wait system call?

What execve() does?

What is the return value of malloc?

Explain the pipe() system call. What does it used for?

What happens when you execute ls -l?

What happens when you execute ls -l *.log?

What readdir() system call does?

What exactly the command alias x=y does?

Linux Filesystem & Files


How to create a file of a certain size?

What does the following block do?:

open(“/my/file”) = 5

read(5, “file content”)

Describe three different ways to remove a file (or its content)

What is the difference between a process and a thread?

What is context switch?

You found there is a server with high CPU load but you didn’t find a process with high CPU. How is that possible?

Linux Advanced – Networking


When you run ip a you see there is a device called ‘lo’. What is it and why do we need it?

What the traceroute command does? How does it works?

What is network bonding? What types are you familiar with?

How to link two separate network namespaces so you can ping an interface on one namespace from the second one?

What are cgroups?

Explain Process Descriptor and Task Structure

What are the differences between threads and processes?

Explain Kernel Threads

What happens when socket system call is used?

You executed a script and while still running, it got accidentally removed. Is it possible to restore the script while it’s still running?

Linux Memory


What is the difference between MemFree and MemAvailable in /proc/meminfo?

What is the difference between paging and swapping?

Explain what is OOM killer

Distribution


What is a Linux distribution?

What Linux distributions are you familiar with?

What are the components of a Linux distribution?

Linux Misc


Wildcards are implemented on user or kernel space?

If I plug a new device into a Linux machine, where on the system, a new device entry/file will be created?

Why there are different sections in man? What is the difference between the sections?

What is User-mode Linux?

Linux Nerds

Under which license Linux is distributed?

Linux Master Application

A completely free application for testing your knowledge on Linux

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)