Linux Interview Prep: Questions, Answers, Code Examples

Andrei Dumitrescu
Andrei Dumitrescu
hero image
Want a career in tech?

Take our career path quiz to find the best fit for you and get a personalized step-by-step roadmap 👇

Take The 3-Minute QuizTake The 3-Minute Quiz

Looking to ace your DevOps interview, or perhaps just brush up on your Linux knowledge?

Well then, you’re in the right place!

In this guide, I share some of the most commonly asked Linux interview questions for DevOps Engineers - covering everything from basic Linux components, file system management, process management, command-line tools, to system optimization.

Better still, I’ve broken this down into just 15 questions over 3 sections: Beginner, Intermediate, and Advanced, so you can see how you compare and how many you can answer correctly.

Just grab a coffee and a notepad, and let's dive in!

Sidenote: If you do find that you’re struggling with the questions in this guide, or perhaps feel that you could use some more training and want to build some more impressive projects for your portfolio, then check out my complete Linux DevOps / Sysadmin Course:

I guarantee you that this is the most comprehensive and up-to-date DevOps Bootcamp that you can find to learn and master Linux from scratch.

Not only do we cover the basics so you have a concrete foundation, but this course ensures that you’ll actually retain what you're learning by giving you the chance to apply Linux in real-world scenarios by configuring a Linux Server from scratch in the cloud!

This DevOps Bootcamp will take you from an absolute beginner in Linux to getting hired as a confident and effective Linux System Administrator.

With that out of the way, let’s get into the questions.

Beginner Linux Questions

#1. Can you explain what Linux is and its basic components? Also, what is LVM and why is it important?

Linux is an open-source operating system modeled on UNIX. It's essential for DevOps due to its stability, security, and flexibility.

The core components of Linux include:

  • Kernel. The core that interacts with hardware and manages resources

  • Shell. The user interface that interprets commands

  • Directory Structure. A hierarchical filesystem starting from the root ("/")

  • Daemons. Background processes for services like printing and networking

The LVM, or Logical Volume Manager, provides flexibility in managing disk space. It allows easier resizing and moving of file systems without service interruption, improved storage utilization, and easier backups.

This is particularly useful in dynamic environments where storage needs can change frequently.

Why would the interviewer ask you about this?

They want to assess your understanding of Linux's core components and the practical benefits of LVM before diving deeper.

2. What are inodes and what data do they store?

Inodes are fundamental to understanding how Linux manages files. An inode is a data structure that stores metadata about a file, excluding its name and data.

The fields in an inode include:

  • File type (regular, directory, link)

  • Permissions

  • Owner and group owner

  • File size

  • Access, change, and modification times

  • Hard links count

  • Pointers to data blocks

Inodes are used whenever the system needs to access file metadata, so understanding inodes helps in tasks like file recovery, performance tuning, and understanding filesystem limits.

Why would the interviewer ask you about this?

They want to gauge your understanding of the filesystem internals and your ability to troubleshoot related issues.

#3. How would you find where a particular file is located in a Linux system?

The two commands you'll reach for most are find and plocate.

find searches in real time, so the results are always current. For example, find / -name testfile searches the entire filesystem, while find . -name testfile narrows it to the current directory.

plocate is faster because it searches a pre-built index rather than scanning the filesystem live. The tradeoff is that the index needs to be updated regularly via updatedb, so very recently created files might not show up yet.

For most day-to-day tasks plocate is quicker, but when you need to be certain you're seeing the current state of the filesystem, find is the safer choice.

Why would the interviewer ask you about this?

They're checking that you know your tools and can pick the right one for the situation. Anyone can memorise a command, but understanding the tradeoffs between them is what they're actually listening for.

# 4. How would you delete empty files from a directory?

You can use the find command to locate and delete empty files in one go.

find /path -type f -empty -delete

The -type f flag makes sure you're only targeting files and not empty directories, and -delete removes them immediately. It's worth running the command without -delete first to preview what will be removed:

find /path -type f -empty

If deletion fails, the most likely cause is insufficient permissions. You can check with ls -l and either adjust the permissions or run the command as root.

Why would the interviewer ask you about this?

Filesystem maintenance is a routine part of sysadmin work. They want to see that you can use find confidently and that you think about things like permissions and previewing destructive commands before running them.

# 5. What is the purpose of the ps command in Linux, and how would you use it in system monitoring and process management?

The ps command shows you a snapshot of currently running processes, including their PIDs, CPU usage, and memory usage. It's one of the first tools you'll reach for when something feels off with system performance.

The most useful version is:

ps aux

This gives you a full view of every process running on the system, who owns it, and how much CPU and memory it's consuming. The columns break down like this:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1  22560  1234 ?        Ss   09:01   0:01 /sbin/init

If you want to find a specific process, you can combine it with grep:

ps aux | grep nginx

For a live, continuously updating view rather than a snapshot, top or htop are better choices. But for scripting or logging process state at a point in time, ps is the right tool.

Why would the interviewer ask you about this?

Process monitoring is a core sysadmin skill. They want to see that you know how to get a clear picture of what's running on a system and can track down a misbehaving process quickly.

Intermediate Linux Questions

#6. How do you manage services in Linux using systemd?

systemd is the default init system on most modern Linux distributions, including Ubuntu, Debian, and RHEL-based systems. It's responsible for starting and managing services, and systemctl is the primary command you'll use to interact with it.

The most common systemctl commands you'll need to know are:

systemctl start nginx        # start a service
systemctl stop nginx         # stop a service
systemctl restart nginx      # restart a service
systemctl status nginx       # check if a service is running
systemctl enable nginx       # start service automatically on boot
systemctl disable nginx      # remove it from startup

You can also use systemctl list-units --type=service to see all active services on the system.

Why would the interviewer ask you about this?

Managing services is a core day-to-day task for any sysadmin or DevOps Engineer. They want to confirm you're comfortable starting, stopping, and troubleshooting services without a GUI, and that you understand the difference between starting a service and enabling it to persist across reboots.

# 7. What are the different file and folder permissions in Linux, and how would you modify these permissions?

In Linux, every file and directory has three types of permission assigned to three different groups of users.

The permissions are:

  • Read (r). View the contents of a file or list a directory

  • Write (w). Modify a file or add/remove files in a directory

  • Execute (x). Run a file as a program, or enter a directory

And they apply to three groups:

  • User (u). The owner of the file

  • Group (g). Other users in the same group as the owner

  • Others (o). Everyone else on the system

To view permissions, use ls -l:

-rwxr-xr-- 1 dan staff 1234 Jun 1 09:00 script.sh

That string at the start breaks down as: owner has read/write/execute, group has read/execute, others have read only. To change permissions, use chmod.

For example

To give the owner full permissions use chmod u+rwx file.txt.

Or using numeric notation, which you'll see often in documentation chmod 755 file.txt, where 7 is full permissions for the owner, 5 is read/execute for group, and 5 is read/execute for others.

Why would the interviewer ask you about this?

Permissions are fundamental to Linux security. Misconfigured permissions are one of the most common causes of both security vulnerabilities and broken deployments, so they want to know you understand them properly rather than just guessing until something works.

# 8. How and why would you change ownership of a file?

Proper ownership management ensures security and proper access.

For example

You use the chown command to change file ownership like so:

chown user1 file.txt

You can also change the group ownership at the same time:

chown user1:group1 file.txt

Or change group ownership on its own using chgrp:

chgrp group1 file.txt

To change ownership recursively across an entire directory:

chown -R user1:group1 /var/www

That last one comes up a lot in web server setups where you need to make sure the web server process has the right ownership over its files.

Only the root user can change file ownership, which is an intentional security restriction. It prevents users from transferring ownership of files to avoid accountability or gain elevated access.

Why would the interviewer ask you about this?

Ownership and permissions go hand in hand. They want to see that you understand not just how to change ownership but why the restriction to root exists, and that you can apply it practically in real scenarios like web server configuration.

# 9. How would you differentiate between a process and a thread in a Linux environment, and why is this difference significant?

Processes and threads are fundamental concepts in Linux, crucial for performance and resource management.

  • A process is an independent block of instructions with its own memory space and environment settings. Think of it as a self-contained program running in isolation

  • A thread lives inside a process and shares its memory space, which makes threads much lighter and faster to spin up than full processes

The tradeoff is that shared memory cuts both ways. Threads are efficient, but a poorly written thread can bring down the entire process with it. Processes are more isolated, so a crash in one won't affect the others.

Why would the interviewer ask you about this?

They want to understand your grasp of system architecture and concurrent processing. It's a good signal of whether you understand how Linux actually manages resources under the hood, rather than just knowing which commands to run.

Advanced Linux Questions

# 10. As a DevOps Engineer, how would you manage resource allocation for different users and processes in a Linux system?

You can use the ulimit command to set user-level limits on system resources, such as maximum file size, CPU time, and memory usage.

For example, to limit a user to a maximum of 100 processes:

ulimit -u 100

Or to set a maximum file size of 512MB:

ulimit -f 524288

You can make these limits permanent by adding them to /etc/security/limits.conf:

username hard nproc 100
username hard fsize 524288

But for more granular control over groups of processes, Control Groups (cgroups) are the better tool. They let you limit, account for, and isolate resource usage at the process group level. For example, to limit a group of processes to 50% of one CPU core:

cgcreate -g cpu:/mygroup
echo 50000 > /sys/fs/cgroup/cpu/mygroup/cpu.cfs_quota_us
cgexec -g cpu:/mygroup ./myprocess

Why would the interviewer ask you about this?

Efficient resource management ensures optimal system performance and stability. They want to see that you know when to reach for ulimit for simple per-user limits, and when a more surgical approach with cgroups is the right call.

# 11. How might you use the nice and renice commands in managing process priorities in Linux?

In Linux, every process has a priority value that determines how much CPU time it gets. The nice command lets you start a process with a specified priority, and renice lets you change the priority of an already running process.

Priority values range from -20 (highest priority) to 19 (lowest priority), with 0 being the default. Only root can set negative values.

For example, to start a backup script at low priority so it doesn't interfere with other processes:

nice -n 19 ./backup.sh

Or to lower the priority of an already running process with PID 1234:

renice -n 10 -p 1234

You can check the current priority of running processes with:

ps -eo pid,ni,cmd

This is particularly useful in production environments where you need to make sure critical processes always get the CPU time they need, without having to kill or pause lower-priority tasks.

Why would the interviewer ask you about this?

They want to see your knowledge of process management and prioritization because in a real production environment, you need to know how to deprioritize a heavy background task without taking it down entirely.

#12. How do you set up SSH key-based authentication in Linux?

SSH key-based authentication is more secure than password authentication and is the standard approach for accessing remote Linux servers, particularly in DevOps environments.

The process involves generating a key pair on your local machine and copying the public key to the remote server:

ssh-keygen -t ed25519 -C "your_email@example.com"   # generate key pair
ssh-copy-id user@remote_server                        # copy public key to server
ssh user@remote_server                                # connect using key auth

This creates two files: a private key (~/.ssh/id_ed25519) which stays on your local machine, and a public key (~/.ssh/id_ed25519.pub) which gets added to ~/.ssh/authorized_keys on the remote server.

Once set up, you can disable password authentication entirely by setting PasswordAuthentication no in /etc/ssh/sshd_config, then restarting the SSH service:

systemctl restart sshd

Why would the interviewer ask you about this?

SSH access is how DevOps Engineers interact with remote servers daily. They want to confirm you understand not just how to connect, but why key-based auth is more secure than passwords, and how to configure the server to enforce it.

# 13. How do you configure IP addressing and set up a firewall in a Linux system?

These are two separate tasks, so let's take them one at a time.

IP addressing

For static IP assignment you use the ip command. For example, to assign the IP address 192.168.1.10 to the eth0 interface:

ip addr add 192.168.1.10/24 dev eth0

If you need dynamic assignment instead, you configure the interface to use DHCP and let the network handle it from there.

Firewall setup

The tool you reach for depends on which distro you're on, which trips a lot of people up in interviews.

On Ubuntu, ufw is the default. It's intentionally simple and human-readable, which makes it easy to get right without much overhead:

ufw allow 22/tcp
ufw enable

On RHEL-based systems like CentOS or Fedora, firewalld is the default. It's more feature-rich and uses the concept of zones to manage trust levels across different network interfaces:

firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload

Both tools sit on top of nftables under the hood, which became the default backend on most modern distros a few years ago. iptables still works and is worth knowing for legacy environments, but if you're working on anything modern you'll be using ufw or firewalld.

Why would the interviewer ask you about this?

They want to assess your ability to manage network settings and security, which is crucial for DevOps roles. Knowing which tool to reach for depending on the distro is exactly the kind of practical knowledge that separates someone who has actually managed Linux servers from someone who has just read about it.

# 14. How do you troubleshoot network connectivity issues in a Linux system?

Several tools are available for this, and the key is knowing which one to reach for at each stage of the diagnosis.

ping is always the starting point. It tells you quickly whether a host is reachable at all:

ping google.com

If that fails, traceroute helps you see exactly where packets are getting dropped along the route:

traceroute google.com

For inspecting open ports and active connections, ss is the modern replacement for the deprecated netstat:

ss -tuln

This lists all listening TCP and UDP ports, which is the same output you'd previously get from netstat -tuln, but faster and without needing the legacy net-tools package.

A logical troubleshooting flow might look like this. Start with ping to confirm basic connectivity. If that fails, use traceroute to identify where the connection is breaking down. Then use ss to check whether the service you're trying to reach is actually listening on the expected port. That three-step process will get you to the root of most network issues quickly.

Why would the interviewer ask you about this?

Troubleshooting network connectivity is something you'll do constantly as a sysadmin or DevOps Engineer. They want to see that you have a logical process for diagnosing issues, not just a list of commands you've memorised.

# 15. What is shell scripting, and how have you used it in your previous roles?

A shell script is simply a file containing a series of commands that the shell reads and executes in order. It's one of the most practical tools in a sysadmin's toolkit because it turns repetitive manual tasks into something you can run with a single command.

For example

A basic shell script looks like this:

#!/bin/bash
# Back up the /var/www directory every night
tar -czf /backups/www-$(date +%F).tar.gz /var/www
scp /backups/www-$(date +%F).tar.gz user@backupserver:/backups/
echo "Backup complete"

The #!/bin/bash at the top is called a shebang. It tells the system which shell to use to run the script. From there you can use variables, loops, conditionals, and any command you'd normally run in the terminal.

Shell scripting is particularly valuable for things like automated backups, log rotation, system monitoring, and deployment tasks. If you find yourself running the same commands every day, it's probably worth turning into a script.

Why would the interviewer ask you about this?

Automation is a core part of any DevOps or sysadmin role. They want to know you're not manually running the same commands every day, and that you can write scripts reliable enough to run unattended. Bonus points if you can talk about a specific task you've automated and why it mattered.

So what's next?

And there you have it, 15 of the most common Linux interview questions for DevOps Engineers.

Remember, though, the goal is not only to memorize these example answers but truly understand the concepts and how they apply in real-world scenarios. This way you’ll be able to share even more details and context and show you really know what you’re talking about.

P.S.

How did you do? Did you nail all 15 questions? If so, it might be time to move from studying to actively interviewing!

Didn't get them all? Don't worry because I'm here to help.

Like I said earlier, if you find that you’re struggling with the questions in this guide, or perhaps feel that you could use some more training and want to build some more impressive projects for your portfolio, then check out my complete Linux DevOps / Sysadmin Course.

Not only do I cover the basics so you have a concrete foundation, but this course ensures that you’ll actually retain what you're learning by letting you apply Linux in real-world scenarios.

You get hands-on experience by configuring a Linux Server from scratch in the cloud, as well as quizzes and challenges at the end of each section.

Plus, once you join, you'll have the opportunity to ask questions in our private Discord community from me, other students, and other working DevOps professionals, as well as access to every other course in our library!

If you join or not, I just want to wish you the best of luck with your interview. And if you are a member, let me know how it goes over in the DevOps channel!

Best articles. Best resources. Only for ZTM subscribers.

If you enjoyed this post and want to get more like it in the future, subscribe below. By joining the ZTM community of over 100,000 developers you’ll receive Web Developer Monthly (the fastest growing monthly newsletter for developers) and other exclusive ZTM posts, opportunities and offers.

No spam ever, unsubscribe anytime

You might like these courses

More from Zero To Mastery

How to Become a DevOps Engineer & Get Hired in 2026 preview
Popular
How to Become a DevOps Engineer & Get Hired in 2026
11 min read

Learn everything you need to know to become a DevOps Engineer in 2026 with this step-by-step guide!

4 Tips To Keep Your Tech Skills Up To Date preview
Popular
4 Tips To Keep Your Tech Skills Up To Date
14 min read

Tech moves at a crazy pace, and it's easy to be left behind. Here are 4 tried and tested tips to not only stay up to date but get ahead of the curve!

A Beginners Guide To Computer Networking preview
A Beginners Guide To Computer Networking
28 min read

Are you a budding DevOps Engineer or Cybersecurity Analyst? Learn the basics of networking, including key concepts like network topologies, OSI model, and more.