Linux is the foundation of many modern IT environments, powering servers, cloud platforms, and embedded devices. For roles such as system administrator, DevOps engineer, or backend developer, strong Linux skills are essential and often tested in interviews.
This guide presents the top fifty Linux questions organised by topic and difficulty, complete with clear explanations and example commands. You will find it easiest to work through each question in your own Linux environment, attempt an answer before reading the solution, and revisit any areas where you feel less confident.
Who Should Read This Guide?
This guide is designed for professionals and aspiring technologists who need to demonstrate strong Linux proficiency in interviews. You are most likely to benefit if you fall into one of the following categories:
- System Administrators seeking to validate your skills in managing Linux servers and services
- DevOps Engineers who build, deploy and monitor applications on Linux‑based infrastructures
- Backend Developers working with Linux environments for application hosting and scripting
- IT Support Specialists responsible for troubleshooting and maintaining Linux workstations
- Students and Graduates preparing for entry‑level roles that require foundational Linux knowledge
If you plan to work directly with Linux systems or support teams that rely on Linux, this guide will help you target the most common interview topics and practise real‑world tasks.
Basic Commands and Navigation Questions
1. What is the Linux filesystem hierarchy and where are key configuration files stored?
Answer:
- Linux uses a single‑tree filesystem that begins at the root directory
/
. - Common top‑level directories include:
/etc
– System‑wide configuration files/bin
and/usr/bin
– Essential user commands and binaries/sbin
and/usr/sbin
– System administration binaries/var
– Variable data files such as logs (/var/log
) and mail/home
– Personal directories for users/dev
– Device files/proc
– Virtual filesystem providing process and kernel information
- Configuration files for services (for example, SSH or Apache) live in
/etc
.
2. How do you list all files and directories, including hidden ones?
Answer:
Use the ls
command with the -a
option:
ls -a
-a
shows all entries, including those beginning with a dot (.
).- To get more detail (permissions, ownership, size), add
-l
:
ls -la
3. How do you display the current working directory in the shell?
Answer:
Use the pwd
(print working directory) command:
pwd
This prints the full path of your current directory, for example:
/home/anandita/projects
4. Which commands allow you to change directories and to create or remove folders?
Answer:
- Change directory: bashCopyEdit
cd /path/to/directory
- Create a directory: bashCopyEdit
mkdir new_folder
- Remove an empty directory: bashCopyEdit
rmdir old_folder
- Remove a directory and its contents recursively (use with caution): bashCopyEdit
rm -r unwanted_folder
5. How can you search for files by name across a directory tree?
Answer:
Use the find
command. For example, to find all files named report.txt
under /home
:
find /home -type f -name report.txt
-type f
restricts to regular files.-name
allows shell‑pattern matching (case‑sensitive).- To perform a case‑insensitive search, use
-iname
:
find /home -type f -iname '*.txt'
File Permissions and Ownership Questions and Answers
6. What are Linux file permissions and what do the symbols r, w and x mean?
Answer:
- Linux permissions control who can read, write or execute a file.
- Each file has three sets of permissions for:
- Owner (user who owns the file)
- Group (users in the file’s group)
- Others (all other users)
- The symbols represent:
r
(read) – Permission to view file contents or list directory contentsw
(write) – Permission to modify file or directory contentsx
(execute) – Permission to run a file as a program or enter a directory
File permissions are displayed as a 10‑character string, for example:
-rwxr‑r‑‑r--
Here the owner has read, write and execute; group has read only; others have read only.
7. How do you change permissions with chmod
?
Answer:
- Symbolic notation: bashCopyEdit
chmod u=rw,g=r,o= file.txt
u
= user (owner),g
= group,o
= others=
sets exact permissions;+
adds and-
removes- Example: grant execute to owner only: bashCopyEdit
chmod u+x file.txt
- Octal notation: bashCopyEdit
chmod 750 script.sh
- Each digit represents owner, group and others in turn:
7
=rwx
(4+2+1)5
=r-x
(4+0+1)0
=---
- Each digit represents owner, group and others in turn:
8. How do you change file ownership with chown
and chgrp
?
Answer:
chown
changes owner and optionally group: bashCopyEditchown alice file.txt chown alice:developers file.txt
chgrp
changes only the group: bashCopyEditchgrp developers file.txt
- To change ownership recursively in a directory: bashCopyEdit
chown -R alice:developers /var/www chgrp -R developers /var/www
9. What is umask
and how does it affect new files?
Answer:
umask
defines default permission bits that are removed when a new file or directory is created.- It is a three‑digit octal value. For example,
umask 022
means:- Owner gets full permissions
- Group loses write (
w
) - Others lose write (
w
)
- New file default permission is
666
minus umask bits:666 - 022 = 644
→rw‑r‑‑r--
- New directory default is
777
minus umask bits:777 - 022 = 755
→rwxr‑xr‑x
- To view current umask: bashCopyEdit
umask
- To set umask for the session: bashCopyEdit
umask 027
10. How can you set default ACLs on a directory?
Answer:
- ACL (Access Control List) allows more fine‑grained permissions than the basic owner/group/others model.
- Install the ACL tools (
acl
package) and ensure the filesystem is mounted with ACL support. - Set a default ACL so that new files and directories inherit specified permissions: bashCopyEdit
setfacl -d -m u:alice:rwx /project setfacl -d -m g:developers:rx /project
-d
= default ACL that new items inherit-m
= modify ACL
- View ACLs on a file or directory: bashCopyEdit
getfacl /project
Process and Job Management Questions and Answers
11. How do you view running processes and their resource usage?
Answer:
ps
command shows a snapshot of processes:ps aux
a
– show processes for all usersu
– display in user-oriented format (with CPU, MEM%)x
– include processes without controlling ttys
top
provides a dynamic, real‑time view:top
- Press
q
to quit; useP
to sort by CPU,M
to sort by memory.
- Press
htop
(if installed) is an enhanced, interactive version oftop
:htop
12. How do you terminate or kill a process gracefully and forcefully?
Answer:
- First find the process ID (PID), for example with
ps
orpgrep
:pgrep -f apache2
- Graceful termination uses
SIGTERM
(signal 15):kill <PID>
- Forceful kill uses
SIGKILL
(signal 9):kill -9 <PID>
- You can send signals by name:
kill -TERM <PID> kill -KILL <PID>
13. What is the difference between foreground and background jobs, and how do you manage them?
Answer:
- Foreground job occupies the terminal until it finishes.
sleep 60
- Background job runs while you regain the prompt by appending
&
:sleep 60 &
- Manage jobs within a shell session:
- List jobs:
jobs
- Bring a job to foreground:
fg %[job_number]
- Send a foreground job to background (pause first with Ctrl+Z):
bg %[job_number]
- List jobs:
14. How do you schedule recurring tasks with cron
?
Answer:
- Edit your user’s crontab with:
crontab -e
- Cron entries follow the format:
* * * * * /path/to/command arg1 arg2 │ │ │ │ │ │ │ │ │ └─ Day of week (0–7, both 0 and 7 = Sunday) │ │ │ └── Month (1–12) │ │ └─── Day of month (1–31) │ └──── Hour (0–23) └───── Minute (0–59)
- Example: run a backup script every day at 2 AM:
0 2 * * * /usr/local/bin/backup.sh
- View current crontab entries:
crontab -l
15. What are nice
and renice
, and how do they influence process priority?
Answer:
nice
launches a command with a modified scheduling priority (“niceness”):nice -n 10 long_running_task.sh
- The niceness value ranges from
-20
(highest priority) to19
(lowest). - Default niceness is
0
.
- The niceness value ranges from
renice
changes the niceness of an existing process by PID: bashCopyEditrenice +5 <PID> renice -5 <PID>
- Lower nice values give more CPU time; higher values yield CPU time to other processes.
User and Group Management Questions and Answers
16. Add, modify and delete user accounts
- Add a user with home directory and default shell:
sudo useradd -m -s /bin/bash alice
- Set or change the user’s password:
sudo passwd alice
- Modify home directory or shell:
sudo usermod -d /new/home/alice -s /bin/zsh alice
- Delete the user (and optionally their home):
sudo userdel alice
orsudo userdel -r alice
17. Add a user to a supplementary group
- Append a group without removing existing ones:
sudo usermod -aG developers bob
- Verify membership:
groups bob
18. Contents of /etc/passwd
and /etc/shadow
/etc/passwd
lists each user’s:- Username, UID, GID
- Home directory and login shell
/etc/shadow
stores secured data:- Hashed passwords
- Password‑age settings (last change, expiry, warnings)
- Only root can read
/etc/shadow
, ensuring password hashes remain protected.
19. Lock and unlock a user account
- Lock (disable login):
sudo usermod -L carol
- Unlock (re‑enable login):
sudo usermod -U carol
20. Enforce password complexity and expiry
- Complexity via PAM module (e.g.,
pam_pwquality
):- Configure minimum length and character classes in
/etc/pam.d/common-password
.
- Configure minimum length and character classes in
- Expiry settings:
- Global defaults in
/etc/login.defs
(e.g.,PASS_MAX_DAYS 90
). - Per user with
chage
(e.g.,sudo chage -M 60 -W 7 dave
to require change every 60 days with a 7‑day warning).
- Global defaults in
Networking Commands & Configuration Questions and Answers
21. Display active network interfaces and IP addresses
Use ip addr
or the legacy ifconfig
:
ip addr show
ifconfig -a
22. Test network connectivity and latency
- Ping a host:
ping example.com
- Traceroute to see path and delays:
traceroute example.com
(ortracert
on some systems)
23. List open ports and listening processes
- With
ss
:ss -tuln
- Or with
netstat
(if installed):netstat -tuln
24. Configure a static IP address
Edit the network configuration file for your distribution (for example /etc/network/interfaces
on Debian‑based systems or a .network
file under /etc/systemd/network/
), specifying address, gateway and DNS. Then restart the network service:
- Debian/Ubuntu (example):
iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8
25. Set up SSH key‑based authentication
- Generate a key pair (if you do not already have one):
ssh-keygen
- Copy the public key to the server:
ssh-copy-id user@server
- Confirm you can log in without a password:
ssh user@server
6. Service and Daemon Management (Questions 26–30)
26. Manage services with systemctl
- Start a service:
sudo systemctl start nginx
- Stop a service:
sudo systemctl stop nginx
- Check status:
systemctl status nginx
27. Difference between SysV init and systemd
- SysV init:
- Uses runlevels and shell scripts in
/etc/init.d/
- Sequential start/stop, no dependency tracking
- Uses runlevels and shell scripts in
- systemd:
- Uses unit files with dependency management
- Parallel startup for faster boot, unified logging
28. Enable, disable and restart a service
- Enable at boot:
sudo systemctl enable nginx
- Disable at boot:
sudo systemctl disable nginx
- Restart immediately:
sudo systemctl restart nginx
29. View and follow journal logs for a service
- View recent logs:
journalctl -u nginx
- Follow logs in real time:
journalctl -u nginx -f
30. Create a custom systemd service unit
- Create
/etc/systemd/system/myapp.service
with minimal content:[Unit] Description=My App Service [Service] ExecStart=/usr/local/bin/myapp [Install] WantedBy=multi-user.target
- Reload daemon and enable:
sudo systemctl daemon-reload
sudo systemctl enable myapp
- Start the new service:
sudo systemctl start myapp
Package Management and Software Installation Questions and Answers
31. How do you install, update and remove packages on Debian‑based systems?
- Install:
sudo apt-get install <package>
- Update package lists:
sudo apt-get update
- Upgrade installed packages:
sudo apt-get upgrade
- Remove a package:
sudo apt-get remove <package>
32. How do you install, update and remove packages on Red Hat‑based systems?
- Install:
sudo dnf install <package>
(oryum install <package>
) - Update all packages:
sudo dnf upgrade
- Remove a package:
sudo dnf remove <package>
33. How do you search for available packages?
- Debian/Ubuntu:
apt-cache search <keyword>
orapt search <keyword>
- Red Hat/CentOS:
dnf search <keyword>
(oryum search <keyword>
)
34. How do you manage software repositories?
- Debian‑based: use
add-apt-repository
or edit/etc/apt/sources.list.d/*.list
, thensudo apt-get update
- Red Hat‑based: place or edit
.repo
files under/etc/yum.repos.d/
, thensudo dnf makecache
35. How do you build and install software from source?
- Download and extract the source archive (e.g., tarball).
- Configure build options: run
./configure
if provided. - Compile: run
make
. - Install: run
sudo make install
.
Shell Scripting and Automation Questions and Answers
36. How do you write and execute a basic shell script?
- Create a file starting with
#!/bin/bash
- Make it executable:
chmod +x script.sh
- Run:
./script.sh
37. How do you declare and use variables in bash?
- Declare:
MY_VAR="Hello"
- Use:
echo "$MY_VAR"
38. How do you implement loops and conditionals?
- For loop:
for item in a b c; do echo "$item" done
- If statement:
if [ -f file.txt ]; then echo "Exists" fi
39. How do you accept and parse command‑line arguments?
- Positional parameters:
$1
,$2
, … - Using
getopts
for flags:while getopts "ab:c" opt; do case $opt in a) echo "Option a";; b) echo "Option b with $OPTARG";; esac done
40. How do you debug a script with set -x
?
- Enable debugging at script start or before a section: bashCopyEdit
set -x
- Disable:
set +x
System Monitoring and Troubleshooting Questions and Answers
41. Monitor CPU, memory and disk I/O in real time
- CPU & memory: use
top
orhtop
- Disk I/O: use
iostat
(fromsysstat
package) oriotop
42. Check disk usage and identify large files
- Overall usage:
df -h
- Directory sizes:
du -sh /path/to/dir/*
- Find large files:
find / -type f -size +100M
43. Analyse and rotate log files
- View logs:
tail -n 100 /var/log/syslog
orjournalctl
- Rotate logs: configure
/etc/logrotate.d/
and test withlogrotate --debug /etc/logrotate.conf
44. Use strace
to debug system calls
- Trace a command:
strace ls
- Trace a running process:
strace -p <PID>
- Log to file:
strace -o trace.log <command>
45. Recover from a full root filesystem
- Identify large files: use
du
orncdu
- Clean package cache:
sudo apt-get clean
orsudo dnf clean all
- Rotate or remove old logs: truncate with
: > /var/log/old.log
- Expand filesystem or add storage if cleanup is insufficient
Virtualization, Containers and Advanced Topics Questions and Ansewers
46. Difference between a container and a virtual machine
- VM: full OS with its own kernel; heavier resources
- Container: shares host kernel; lightweight and faster startup
47. Install and run a Docker container on Linux
- Install Docker from your distribution’s repository or Docker’s official script
- Run a container:
docker run --name mynginx -d nginx
- List containers:
docker ps
48. Manage VMs with KVM and virsh
- List VMs:
virsh list --all
- Start/stop:
virsh start vmname
/virsh shutdown vmname
- Connect console:
virsh console vmname
49. Configure and use LVM for logical volumes
- Create physical volume:
pvcreate /dev/sdb
- Create volume group:
vgcreate vg01 /dev/sdb
- Create logical volume:
lvcreate -L 10G -n lv01 vg01
- Format & mount:
mkfs.ext4 /dev/vg01/lv01
thenmount /mnt
50. Check and change SELinux mode
- Check status:
sestatus
- Temporarily change:
sudo setenforce 0
(permissive) or1
(enforcing) - Permanently change: edit
SELINUX=
in/etc/selinux/config
Conclusion
Mastering the fundamentals and advanced aspects of Linux is essential for success in technical interviews for system administration, DevOps and backend development roles. By working through these fifty questions in your own environment—attempting answers before reviewing solutions and practising commands until they become second nature—you will build both confidence and competence.
Continue to deepen your understanding by consulting official documentation, experimenting with different distributions and exploring additional topics such as networking, security hardening and high‑availability configurations. Regular hands‑on practice, combined with this structured question‑and‑answer guide, will ensure you are well prepared to demonstrate your Linux expertise in any interview scenario.