DevOps and CloudOps | 54 questions | 2026
Linux Interview Questions and Answers
Linux interview questions for freshers 27
Q1FresherMost askedAnswerHideWhich Linux commands do you use to check CPU, memory and disk use, find heavy processes, and kill a process?
I start with top or htop for live CPU and memory, then use targeted commands.
top # live CPU/memory per process (press M or P to sort)
ps aux --sort=-%cpu | head # top CPU consumers
free -h # memory and swap
df -h # disk usage per filesystem
du -sh /var/log/* # folder sizes
uptime # load average
kill <PID> # polite stop (SIGTERM)
kill -9 <PID> # force kill (SIGKILL), last resort
Find a process by name with pgrep -a nginx or ps aux | grep nginx. Check logs with journalctl -u <service>. For storage problems, df -h shows which filesystem is full and du pinpoints the folder.
What they are checking: Whether you have day-to-day Linux troubleshooting habits
Q2FresherMost askedAnswerHideHow do Linux octal file permissions work, and what do modes like 755, 644, 664 and 777 mean?
Each file has permissions for three classes: owner, group and others. Each class gets read (4), write (2) and execute (1), added together.
| Mode | Owner | Group | Others | Typical use |
|---|---|---|---|---|
| 755 | rwx | r-x | r-x | Scripts, directories |
| 644 | rw- | r-- | r-- | Normal files |
| 664 | rw- | rw- | r-- | Files shared with a group |
| 777 | rwx | rwx | rwx | Everyone can do everything, avoid |
chmod 755 deploy.sh
chmod u+x,g-w file
chown appuser:appgroup file
ls -l file
chmod changes permissions and chown changes owner and group. 777 is a security risk because any user can modify or replace the file. Use the least permission that works.
What they are checking: Whether you can read and set permissions and avoid dangerous defaults
Q3FresherMost askedAnswerHideHow do you give developers SSH access to a Linux instance?
Create a user for each developer and add their public key to that user's authorized_keys. Never share one private key.
sudo adduser alice
sudo mkdir -p /home/alice/.ssh
echo "ssh-ed25519 AAAA... alice@laptop" | sudo tee -a /home/alice/.ssh/authorized_keys
sudo chmod 700 /home/alice/.ssh
sudo chmod 600 /home/alice/.ssh/authorized_keys
sudo chown -R alice:alice /home/alice/.ssh
sudo usermod -aG sudo alice # only if needed
The developer generates the pair with ssh-keygen -t ed25519 and sends only the public key. Open port 22 only from trusted IPs. For many users, use SSM Session Manager, EC2 Instance Connect, or central user management (LDAP/SSO). Remove keys when people leave.
What they are checking: Whether you handle SSH access securely and per user
Q4FresherMost askedAnswerHideWhich Linux commands show disk space, folder sizes, block devices, open ports and the process behind a port?
A short set covers most cases:
df -h # filesystem usage
du -sh /var/* # size of folders
du -ah . | sort -rh | head # biggest items
lsblk # block devices and volumes (EBS disks)
sudo ss -tulpn # listening ports + process
sudo lsof -i :8080 # who uses port 8080
sudo netstat -tulpn # older alternative
To then manage the process found: ps -p <PID> -o pid,cmd and kill <PID>. lsblk shows attached EBS volumes and their size even if they are not mounted yet. df -h shows only mounted filesystems.
What they are checking: Whether you can quickly find disk, port and process information
Q5FresherMost askedAnswerHideHow does SSH key authentication work?
SSH key authentication uses a key pair: the private key stays with the user and the public key is placed on the server. The user proves they own the key without sending the private key.
- Client connects and the server verifies its host key (known_hosts).
- Client says it wants to use a public key. The server checks
~/.ssh/authorized_keys. - The server sends a challenge; the client signs it with the private key.
- The server verifies the signature with the public key and allows login.
ssh-keygen -t ed25519
ssh-copy-id user@server
ssh -i ~/.ssh/id_ed25519 user@server
Private key permissions must be 600. Disable password login (PasswordAuthentication no in /etc/ssh/sshd_config) for better security.
What they are checking: Whether you understand asymmetric keys in practice
Q6FresherMost askedAnswerHideHow do you access a private Linux machine or EC2 instance over SSH?
A private instance has no public IP. So you connect through a bastion/jump host, a VPN, or AWS Systems Manager.
# via bastion with ProxyJump
ssh -J ec2-user@<bastion-public-ip> [email protected]
# via SSM, no open port 22 needed
aws ssm start-session --target i-0123456789abcdef0
- The private instance's security group allows port 22 only from the bastion's security group (or VPN range).
- To log in, you need the key pair used at launch (
-i key.pem, permission400) or a user added with your own public key. - With SSM the instance needs the SSM agent and an IAM role with
AmazonSSMManagedInstanceCore.
What they are checking: Whether you know the secure ways into private servers
Q7FresherMost askedAnswerHideHow do you stop or kill a process cleanly? How do you find it by name or port?
First find the PID. Then send SIGTERM so the process can clean up. Use SIGKILL only if it does not stop.
pgrep -a nginx # find by name
sudo ss -tulpn | grep :8080 # find by port
sudo lsof -i :8080
kill <PID> # SIGTERM (15), graceful
kill -9 <PID> # SIGKILL (9), forced, no cleanup
pkill -f myapp # by name pattern
For services managed by systemd prefer systemctl stop <service>, otherwise it may restart automatically. A process stuck in state D (uninterruptible I/O) may not die even with -9.
What they are checking: Whether you know graceful versus forced termination
Q8FresherMost askedAnswerHideWhat Linux fundamentals and basic commands should a DevOps engineer know?
A DevOps engineer should be comfortable with the shell, files, users, processes, networking and services.
ls, cd, pwd, cp, mv, rm, mkdir, cat, less, tail -f # files
grep, find, sed, awk, cut, sort, uniq # text search and processing
chmod, chown, sudo, useradd # permissions and users
ps, top, kill, systemctl, journalctl # processes and services
df, du, free, lsblk # resources
ip a, ss -tulpn, curl, ping, dig # networking
ssh, scp, rsync, tar # remote and archives
apt / yum # packages (Ubuntu / RHEL)
Also know the filesystem layout (/etc config, /var/log logs, /home, /tmp). Know how to edit files with vim or nano. Know basic bash scripting with variables, loops and conditions.
What they are checking: Whether you have a working command-line foundation
Q9FresherFree with sign-inAnswerHideWhat port does SSH use? How does it differ from Telnet? Where are public keys stored on the server?
SSH uses TCP port 22 and encrypts all traffic. Telnet (port 23) sends everything, including passwords, as plain text.
Q10FresherFree with sign-inAnswerHideHow comfortable are you with Bash and Python scripting, and what have you automated with them?
Structure for the answer: level, 2 or 3 concrete examples, impact, and how you keep scripts safe.
Q11FresherFree with sign-inAnswerHideWhat is the difference between a hard link and a soft (symbolic) link in Linux?
A hard link is another name for the same inode. A soft link is a small file that stores the path to another file.
Q12FresherFree with sign-inAnswerHideHow do you search for text in files, and for files by name, in Linux (grep, find, awk, sed)?
Use grep for text, find for files, and awk or sed for transforming lines.
Q13FresherFree with sign-inAnswerHideWhat are pipes and redirection in Linux, and what are stdin, stdout and stderr?
Pipes send the output of one command into the next command. Redirection sends a stream to or from a file.
Every process has three streams: stdin (0), stdout (1) and stderr (2).
Q14FresherFree with sign-inAnswerHideExplain the cron schedule syntax. How would you run a job every day at 2 AM and every 15 minutes?
A crontab line has five time fields followed by the command: minute, hour, day of month, month, day of week.
Q15FresherFree with sign-inAnswerHideWhat is systemd and which systemctl commands do you use to manage a service?
systemd is the init system (PID 1) on most modern Linux distributions. It starts services, manages dependencies and collects logs.
Q16FresherFree with sign-inAnswerHideWhere do you look for logs on a Linux server, and how do you follow them live?
Traditional logs are text files under /var/log, and systemd services also log to the journal.
Q17FresherFree with sign-inAnswerHideWhich commands do you use to troubleshoot network connectivity from a Linux server?
Work from the bottom up: interface, route, DNS, then the port.
Q18FresherFree with sign-inAnswerHideHow do you automate database backups with a bash script and cron?
Write a script that dumps the database, compresses it, uploads it, and removes old copies. Then schedule it with cron.
Q19FresherFree with sign-inAnswerHideWhat are daemon services in Linux?
A daemon is a background process that starts at boot (or on demand). It gives a service without a user screen, such as sshd, nginx or cron. Their names often end in d.
Q20FresherFree with sign-inAnswerHideCompare Windows Batch scripting with Bash scripting. Where are they used for automation?
Batch (.bat / .cmd) runs in the Windows command prompt. Bash runs on Linux and macOS (and on Windows through WSL or Git Bash).
Q21FresherFree with sign-inAnswerHideWhat is a zombie process and how do you deal with it?
A zombie is a process that has finished running. It still has an entry in the process table because its parent has not read its exit status.
Q22FresherFree with sign-inAnswerHideHow do chmod, chown and umask work together to control file access?
chmod changes who can read, write or execute. chown changes the owner and group. umask sets the default permissions for new files.
Q23FresherFree with sign-inAnswerHideHow do you install, update and remove software on Ubuntu and on RHEL/CentOS?
Ubuntu and Debian use apt, RHEL, CentOS, Rocky and Amazon Linux use dnf (or yum).
Q24FresherFree with sign-inAnswerHideDescribe the Linux filesystem hierarchy. What are /etc, /var, /tmp, /home and /usr used for?
Everything hangs off a single root /, and each top-level directory has a conventional purpose.
Q25FresherFree with sign-inAnswerHideWhat is the difference between sudo and su, and why avoid working as root?
su switches to another user with that user's password. sudo runs a single command with extra rights, using your own password and a policy.
Q26FresherFree with sign-inAnswerHideWhat are environment variables in Linux, and what is PATH?
Environment variables are named values that a process gets from its parent. PATH is the list of directories searched when you type a command.
Q27FresherFree with sign-inAnswerHideHow do you read the output of top and what does load average mean?
top shows live processes. The three load average numbers are the average count of running plus waiting tasks over the last 1, 5 and 15 minutes.
Linux interview questions for experienced 13
Q28ExperiencedMost askedAnswerHideWhat does execute permission on a directory mean? What do read and execute allow when you list or enter a directory?
On a directory, execute (x) means you can traverse it: cd into it and access items inside by name. Read (r) means you can list its names.
- r only (e.g.
chmod 400 dir):ls dirshows names. But you cannotcdinto it, read file details, or open files inside. - x only: you can
cdand open a file if you know its exact name, but cannot list. - r + x: the normal read-only access (
r-x): list and enter. - w + x: needed to create, delete or rename files in it.
So to cd into a folder you need x on it and on every parent directory. Read permission alone is not enough to enter or properly list contents.
What they are checking: Whether you understand that directory permissions differ from file permissions
Q29ExperiencedMost askedAnswerHideHow do you give a user or group read-only access to a folder? How do you give one team write access while another team can only read?
Use groups and standard permissions first, and ACLs when the simple owner/group/others model is not enough.
# group-based: team A writes, team B reads
groupadd teama; groupadd teamb
chown -R deploy:teama /srv/app
chmod -R 2775 /srv/app # setgid keeps the group on new files
setfacl -R -m g:teamb:rX /srv/app # B: read + traverse
setfacl -R -d -m g:teamb:rX /srv/app # default ACL for new files
# single user, read-only
setfacl -m u:alice:rX /srv/data
getfacl /srv/data
Capital X gives execute only on directories. So the user can enter the folder and read files, but cannot change them. Without execute on the directory, the user could not enter it even with read permission. Mind the ACL mask and parent directory traverse rights.
What they are checking: Whether you know groups, setgid and ACLs for multi-team access
Q30ExperiencedFree with sign-inAnswerHideWhat does set -e do in a bash script? How do you handle unset variables and pipeline errors?
set -e makes the script exit at once when a command fails (non-zero status). So errors are not ignored quietly.
Q31ExperiencedFree with sign-inAnswerHideHow do you write a systemd unit file for a custom application?
Create a .service file under /etc/systemd/system/ with [Unit], [Service] and [Install] sections, then reload and enable it.
Q32ExperiencedFree with sign-inAnswerHideHow do you make a PM2-managed Node.js application survive server reboots?
Start the app under PM2 and save the process list. Then make the startup script, so systemd starts PM2 at boot.
Q33ExperiencedFree with sign-inAnswerHideWhat does the 's' bit mean in Linux file permissions?
The s is the setuid or setgid bit. The program runs with the permissions of its file owner (setuid) or group (setgid), not the user who starts it.
Q34ExperiencedFree with sign-inAnswerHideWhich file sets the DNS name servers on a Linux machine? How do you point a domain name to a local machine?
DNS servers are set in /etc/resolv.conf (on modern Ubuntu it is managed by systemd-resolved, check with resolvectl status). Local name overrides go in /etc/hosts.
Q35ExperiencedFree with sign-inAnswerHideWhat is the difference between load average and CPU use? Why can load be high while CPU is low?
CPU use is the share of time the cores are busy. Load average counts tasks that are running or waiting to run. On Linux it also counts tasks stuck in uninterruptible IO wait.
Q36ExperiencedFree with sign-inAnswerHideHow do you configure a basic Linux firewall with ufw, firewalld or iptables?
Deny inbound traffic by default. Then open only the ports you need. Prefer the tool your distro ships with.
Q37ExperiencedFree with sign-inAnswerHideWhich tools do you use to debug a running process (strace, lsof, perf, tcpdump)?
Use strace for system calls, lsof for open files and sockets, perf for CPU profiling, and tcpdump for network packets.
Q38ExperiencedFree with sign-inAnswerHideWhat are shell scripting best practices for reliable automation scripts?
Fail fast, quote everything, validate input and clean up after yourself.
Q39ExperiencedFree with sign-inAnswerHideHow do you raise the open file limit for a service, and what are ulimit and sysctl used for?
ulimit sets per-process limits such as open files. sysctl tunes kernel settings. For services, set the limit in the systemd unit.
Q40ExperiencedFree with sign-inAnswerHideWhat are SELinux and AppArmor, and how do you handle a denial instead of disabling them?
Both are access control systems that limit what a process can do, even if it runs as root. SELinux is the default on RHEL-family distributions and AppArmor on Ubuntu and SUSE.
Scenario based Linux interview questions 14
Q41ExperiencedScenarioFree with sign-inAnswerHideA server reports 100% disk usage but df and du show different numbers. How do you find what is using the space?
The usual cause is a deleted file that a running process still holds open. The space is not freed until the process closes it.
Q42ExperiencedScenarioFree with sign-inAnswerHideA production server is very slow and the load average is high. How do you troubleshoot it?
Find out which resource is saturated first: CPU, memory, disk IO or network, then which process is responsible.
Q43ExperiencedScenarioFree with sign-inAnswerHideA systemd service fails to start after a deployment. How do you diagnose it?
Read the unit status and the journal. Then check the command, user, paths and environment the unit uses.
Q44ExperiencedScenarioFree with sign-inAnswerHideYou get Permission denied (publickey) when connecting over SSH. How do you troubleshoot?
Run the client in verbose mode to see which key is offered. Then check the key, the permissions and the server logs.
Q45ExperiencedScenarioFree with sign-inAnswerHideHow would you keep the same files synchronised across multiple web servers in an Auto Scaling Group?
Avoid storing changing state on the instances, and pick a shared or build-time approach.
Q46ExperiencedScenarioFree with sign-inAnswerHideHow do you manage SSH keys across many servers? How do you get access back if a key is lost?
Manage access in one place instead of copying keys by hand. Keep a second way in, so a lost key does not lock you out.
Q47ExperiencedScenarioFree with sign-inAnswerHideA process was killed unexpectedly and the application keeps disappearing. How do you confirm and handle an OOM kill?
Check the kernel log for the out-of-memory killer, then fix the memory demand or limits.
Q48ExperiencedScenarioFree with sign-inAnswerHideWrites fail with 'No space left on device' but df -h shows free space. What do you check?
Check inode exhaustion: a filesystem can run out of inodes (file entries) before it runs out of bytes.
Q49ExperiencedScenarioFree with sign-inAnswerHideYou start a service and it fails with 'Address already in use'. How do you find and fix the conflict?
Another process is already listening on that port. Find it, then decide whether to stop it or change the port.
Q50ExperiencedScenarioFree with sign-inAnswerHideA cron job does not run, or runs but does not do what it does manually. How do you debug it?
Cron runs with a very small environment and no terminal. So most failures are path, permission or environment problems.
Q51ExperiencedScenarioFree with sign-inAnswerHideSomeone ran chmod -R 777 on an application directory (or removed all permissions). How do you recover safely?
First stop the damage and check what changed. Then restore the right modes from a known good source, instead of guessing.
Q52ExperiencedScenarioFree with sign-inAnswerHideUsers complain of slow disk operations and top shows high iowait. How do you find the cause?
High wa means the CPUs are idle and waiting for storage. Find the device, then the process, then the reason.
Q53ExperiencedScenarioFree with sign-inAnswerHideApplication logs are filling the disk. How do you set up log rotation and clean up safely?
Use logrotate to rotate, compress and expire logs automatically, and handle the live file correctly.
Q54ExperiencedScenarioFree with sign-inAnswerHideHow would you extend a filesystem on an EBS or LVM volume without downtime?
Grow the block device first, then the partition or logical volume, then the filesystem. You can do all this while it is mounted.