DevOps.Academy
CoursesCurriculumInterview prepPricing
◔My learningSign in
DevOps.Academy

Free, hands-on DevOps lessons. Made with care in India.

System status

Learn

All coursesLinux roadmapCurriculumInterview questionsCheat sheetsMy learning

Academy

PricingCertificates

Legal

PrivacyTermsContact

devops.rajeev.pro

Linux & Bash for DevOps · interview practice

Linux & Bash interview questions

Answer each one out loud first, then tap it to check yourself against a model answer and the lesson behind it.

Navigation basics 2Editing files 2Shell basics 2Working with files 2Text processing 2Server review 2Process management 2Users & groups 2Services with systemd 2Package management 2Disks & filesystems 2Booting Linux 1Networking 1Shell scripting 1Troubleshooting 1Containers on Linux 1

Navigation basics

Q1You open a terminal and need to confirm which machine and directory you are on. What do you check?junior

I run hostnamectl or hostname to identify the machine, then pwd to print the current directory. If I need context about the shell, I check the prompt and the account with whoami.

Read the lesson: The shell and the filesystem →
Q2How would you move to your home directory regardless of your current location?junior

I run cd with no argument, or cd ~. Both take me to the current user's home directory. I confirm the result with pwd before running commands that change files.

Read the lesson: The shell and the filesystem →

Editing files

Q3You need to change one setting in a server config over SSH. How do you avoid losing the original?junior

I inspect the file first and make a backup before editing. I use nano or vim, change only the intended setting, then review the diff or reread the file before asking the service to reload.

Read the lesson: Editing files: nano, vim, and changing a server safely →
Q4In Vim, what is the difference between normal mode and insert mode?junior

Normal mode interprets keys as editor commands, while insert mode puts typed characters into the file. I press Esc to return to normal mode before saving or moving around with Vim commands.

Read the lesson: Editing files: nano, vim, and changing a server safely →

Shell basics

Q5A command works when you give its full path but not by name. What do you check first?junior

I check whether the command's directory is in PATH with printf or echo, and inspect the value with command -v. If I changed PATH, I check whether that change is in the right shell startup file.

Read the lesson: Shell basics: PATH, variables, streams and sudo →
Q6What happens to the output in command > run.log 2>&1?junior

The shell redirects standard output to run.log, then sends standard error to the same destination as standard output. The order matters: 2>&1 copies the current stdout destination.

Read the lesson: Shell basics: PATH, variables, streams and sudo →

Working with files

Q7How would you find files named nginx.conf beneath /etc without searching the whole machine?junior

I use find /etc -name nginx.conf, limiting the traversal to the relevant tree. If permissions hide paths, I decide whether sudo is appropriate rather than suppressing errors blindly.

Read the lesson: Working with files: permissions, archives and links →
Q8What does mode 640 allow for the owner, group and everyone else?junior

The owner can read and write, the group can read, and everyone else has no permissions. I use this for a file that should be editable by its owner but readable by a trusted group only.

Read the lesson: Working with files: permissions, archives and links →

Text processing

Q9A log is large and you need only lines containing “error”, regardless of case. What do you run?junior

I pipe the file through grep -i error. For a live log I can use tail -f and filter its output, while keeping in mind that a pipeline can hide the original command's exit status without pipefail.

Read the lesson: Text processing: get answers out of logs →
Q10When would you use awk instead of grep?junior

I use grep to select lines by a text pattern. I use awk when I need fields, conditions or a small record-by-record transformation, such as printing the first column from matching rows.

Read the lesson: Text processing: get answers out of logs →

Server review

Q11A service is slow. How do you distinguish CPU pressure from a disk or memory problem?mid

I compare uptime load with nproc, then inspect memory with free and disk capacity with df. Load above the CPU count is not proof of CPU saturation because tasks waiting on storage also count.

Read the lesson: Server review: a five-minute health check →
Q12What does a Linux load average tell you, and what should you compare it with?mid

It is the average number of runnable or uninterruptible tasks over one, five and fifteen minutes. I compare it with the number of CPU cores and look at the trend; it is not a CPU percentage.

Read the lesson: Server review: a five-minute health check →

Process management

Q13A process is no longer responding. What is your safe escalation path before using SIGKILL?mid

I confirm the process and PID, send the default SIGTERM with kill, then wait and check whether it exited. I use SIGKILL only as a last resort because the process cannot clean up or save its state.

Read the lesson: Processes: see them, control them, stop them →
Q14What is a zombie process, and why does sending it another signal not remove it?mid

A zombie has already exited; its parent has not yet collected the exit status. The process itself is gone, so I investigate or restart a faulty parent rather than repeatedly trying to kill it.

Read the lesson: Processes: see them, control them, stop them →

Users & groups

Q15A teammate needs read access to a shared deployment directory but should not own the files. How do you model that?mid

I create or use a team group, add the teammate to it, set the directory's group and grant only the required group permissions. I verify the effective identity and access rather than making it world-writable.

Read the lesson: Users and groups: who can do what →
Q16Why should a service run as a dedicated account instead of root?mid

A dedicated service account limits what a compromised process can read or change. I give it only the file and group permissions the service needs, and avoid granting an interactive shell when it is unnecessary.

Read the lesson: Users and groups: who can do what →

Services with systemd

Q17A systemd service is active but requests fail. What do you inspect before restarting it?mid

I read systemctl status for the unit and recent journal output, then inspect the service's configuration and dependencies. That gives me evidence about the failure and avoids restarting blindly.

Read the lesson: Services with systemd: run, restart, read the logs →
Q18What is the difference between starting a service and enabling it?mid

systemctl start runs the service now. systemctl enable configures it to start during the relevant boot target; enabling does not itself mean the service is currently running.

Read the lesson: Services with systemd: run, restart, read the logs →

Package management

Q19What does apt update do, and why is it not the same as upgrading packages?mid

apt update refreshes the local package indexes from configured repositories. apt upgrade uses those indexes to install newer package versions, so I review the proposed changes before upgrading a production host.

Read the lesson: Packages: install, update and trust software →
Q20How do you check which package owns a file before replacing or deleting it?mid

I query the package database with dpkg -S on Debian-family systems. That tells me whether the file is package-managed, so I can use the package manager rather than create configuration drift manually.

Read the lesson: Packages: install, update and trust software →

Disks & filesystems

Q21A newly attached disk must survive reboots. What is the safe sequence to make it available?senior

I identify the correct device with lsblk, create a filesystem only after confirming it is the intended empty disk, and mount it at the target path. I add its UUID to /etc/fstab and verify the entry with a test mount before rebooting.

Read the lesson: Disks and filesystems: add, mount, grow and repair →
Q22Why is a UUID usually safer than a device name in /etc/fstab?senior

Device names such as /dev/sdb can change when discovery order changes. A filesystem UUID identifies the filesystem itself, so the mount is less likely to target the wrong disk after a reboot or hardware change.

Read the lesson: Disks and filesystems: add, mount, grow and repair →

Booting Linux

Q23A Linux host stops during boot after a kernel update. How do you narrow down where it failed?senior

I identify whether firmware, GRUB, the kernel or systemd was the last working stage, then inspect the available boot messages and journal. If the new kernel is the likely cause, I use the boot menu to try the previous kernel and compare evidence.

Read the lesson: How Linux boots, and what to do when it does not →

Networking

Q24A hostname resolves but the web request times out. What layers do you check, in order?senior

I check DNS with dig, confirm the route and local address with ip, then test reachability and the destination port. I distinguish a network timeout from a refused connection and check the service and firewall after confirming the path.

Read the lesson: Networking: addresses, DNS, routes and SSH →

Shell scripting

Q25A scheduled backup script works interactively but fails from cron. What differences do you check?senior

I check the script's shebang, executable bit, absolute paths, PATH and environment because cron starts with a smaller environment. I capture logs and exit status, then test the exact command under the same account.

Read the lesson: Shell scripting: automate it once, run it forever →

Troubleshooting

Q26A TCP service is reachable from one network but not another. How do you use packet and path tools to isolate it?senior

I compare DNS, route and port reachability from both locations, then use traceroute or mtr to see where paths diverge. If the evidence still points at the host, I capture the relevant traffic with tcpdump and check firewall rules.

Read the lesson: Troubleshooting the network: from "it is down" to the cause →

Containers on Linux

Q27A container can see more host processes than expected. Which isolation boundary do you inspect?senior

I check whether it runs in a separate PID namespace and review the runtime configuration. Namespaces control what the process can see, while cgroups control resource use; neither replaces host-level security controls.

Read the lesson: Containers are Linux: namespaces, cgroups and Docker →
← Back to the Linux & Bash course