By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Stay ahead by continuously learning and advancing your career.. Learn More
Skilr BlogSkilr Blog
  • Home
  • Blog
  • Tutorial
Reading: Top 50 Linux interview Questions and Answers
Share
Font ResizerAa
Skilr BlogSkilr Blog
Font ResizerAa
Search
  • Categories
  • Bookmarks
  • More Foxiz
    • Sitemap
Follow US
  • Advertise
© 2024 Skilr.com. All Rights Reserved.
Skilr Blog > Uncategorized > Top 50 Linux interview Questions and Answers
Uncategorized

Top 50 Linux interview Questions and Answers

Last updated: 2025/07/22 at 11:56 AM
Anandita Doda
Share
Top 50 Linux interview Questions and Answers
SHARE

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.

Contents
Who Should Read This Guide?Basic Commands and Navigation QuestionsFile Permissions and Ownership Questions  and AnswersProcess and Job Management Questions and AnswersUser and Group Management Questions  and AnswersNetworking Commands & Configuration Questions and Answers6. Service and Daemon Management (Questions 26–30)Package Management and Software Installation Questions and AnswersShell Scripting and Automation Questions and AnswersSystem Monitoring and Troubleshooting Questions  and AnswersVirtualization, Containers and Advanced Topics Questions and AnsewersConclusion

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: bashCopyEditcd /path/to/directory
  • Create a directory: bashCopyEditmkdir new_folder
  • Remove an empty directory: bashCopyEditrmdir old_folder
  • Remove a directory and its contents recursively (use with caution): bashCopyEditrm -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:
    1. Owner (user who owns the file)
    2. Group (users in the file’s group)
    3. Others (all other users)
  • The symbols represent:
    • r (read) – Permission to view file contents or list directory contents
    • w (write) – Permission to modify file or directory contents
    • x (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: bashCopyEditchmod 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: bashCopyEditchmod u+x file.txt
  • Octal notation: bashCopyEditchmod 750 script.sh
    • Each digit represents owner, group and others in turn:
      • 7 = rwx (4+2+1)
      • 5 = r-x (4+0+1)
      • 0 = ---

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: bashCopyEditchown -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: bashCopyEditumask
  • To set umask for the session: bashCopyEditumask 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: bashCopyEditsetfacl -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: bashCopyEditgetfacl /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 users
    • u – 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; use P to sort by CPU, M to sort by memory.
  • htop (if installed) is an enhanced, interactive version of top: htop

12. How do you terminate or kill a process gracefully and forcefully?

Answer:

  • First find the process ID (PID), for example with ps or pgrep: 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]

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) to 19 (lowest).
    • Default niceness is 0.
  • 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
    or
    sudo 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.
  • 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).

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 (or tracert 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

  1. Generate a key pair (if you do not already have one):
    ssh-keygen
  2. Copy the public key to the server:
    ssh-copy-id user@server
  3. 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
  • 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

  1. 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
  2. Reload daemon and enable:
    sudo systemctl daemon-reload
    sudo systemctl enable myapp
  3. 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> (or yum 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> or apt search <keyword>
  • Red Hat/CentOS: dnf search <keyword> (or yum search <keyword>)

34. How do you manage software repositories?

  • Debian‑based: use add-apt-repository or edit /etc/apt/sources.list.d/*.list, then sudo apt-get update
  • Red Hat‑based: place or edit .repo files under /etc/yum.repos.d/, then sudo dnf makecache

35. How do you build and install software from source?

  1. Download and extract the source archive (e.g., tarball).
  2. Configure build options: run ./configure if provided.
  3. Compile: run make.
  4. 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: bashCopyEditset -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 or htop
  • Disk I/O: use iostat (from sysstat package) or iotop

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 or journalctl
  • Rotate logs: configure /etc/logrotate.d/ and test with logrotate --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

  1. Identify large files: use du or ncdu
  2. Clean package cache: sudo apt-get clean or sudo dnf clean all
  3. Rotate or remove old logs: truncate with : > /var/log/old.log
  4. 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

  1. Install Docker from your distribution’s repository or Docker’s official script
  2. Run a container: docker run --name mynginx -d nginx
  3. 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

  1. Create physical volume: pvcreate /dev/sdb
  2. Create volume group: vgcreate vg01 /dev/sdb
  3. Create logical volume: lvcreate -L 10G -n lv01 vg01
  4. Format & mount: mkfs.ext4 /dev/vg01/lv01 then mount /mnt

50. Check and change SELinux mode

  • Check status: sestatus
  • Temporarily change: sudo setenforce 0 (permissive) or 1 (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.

Top 50 Linux interview Questions and Answers banner

You Might Also Like

Top 50 Top Java Interview Questions and Answers

Top 50 Devops Interview Questions and Answers

Top 50 Selenium Interview Questions and Answers

Top 50 Javascript Interview Questions and Answers

Top 50 Spring Boot Interview Questions and Answers | How to Answer Them

TAGGED: 32 most asked linux interview questions and answers, inux interview questions and answers, linux admin interview questions and answers, linux interview questions and answers, linux interview questions and answers for beginners, linux interview questions and answers for devops, linux interview questions and answers for experienced, linux interview questions and answers for freshers, linux interviw questions and answers, linux questions and answers for interview, top 50 linux interview questions
Anandita Doda July 22, 2025 July 22, 2025
Share This Article
Facebook Twitter Copy Link Print
Share
Previous Article Top 50 Devops Interview Questions and Answers Top 50 Devops Interview Questions and Answers
Next Article Top 50 Java Interview Questions and Answers Top 50 Top Java Interview Questions and Answers

Linux Management Exam

Learn More
Take Free Test

Categories

  • AWS
  • Cloud Computing
  • Competitive Exams
  • CompTIA
  • Cybersecurity
  • DevOps
  • Google
  • Google Cloud
  • Machine Learning
  • Microsoft
  • Microsoft Azure
  • Networking
  • PRINCE2
  • Project Management
  • Salesforce
  • Server
  • Study Abroad
  • Uncategorized

Disclaimer:
Oracle and Java are registered trademarks of Oracle and/or its affiliates
Skilr material do not contain actual actual Oracle Exam Questions or material.
Skilr doesn’t offer Real Microsoft Exam Questions.
Microsoft®, Azure®, Windows®, Windows Vista®, and the Windows logo are registered trademarks of Microsoft Corporation
Skilr Materials do not contain actual questions and answers from Cisco’s Certification Exams. The brand Cisco is a registered trademark of CISCO, Inc
Skilr Materials do not contain actual questions and answers from CompTIA’s Certification Exams. The brand CompTIA is a registered trademark of CompTIA, Inc
CFA Institute does not endorse, promote or warrant the accuracy or quality of these questions. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute

Skilr.com does not offer exam dumps or questions from actual exams. We offer learning material and practice tests created by subject matter experts to assist and help learners prepare for those exams. All certification brands used on the website are owned by the respective brand owners. Skilr does not own or claim any ownership on any of the brands.

Follow US
© 2023 Skilr.com. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Lost your password?