DEV Community

Nikhil Soman Sahu
Nikhil Soman Sahu

Posted on

"Top Linux Interview Questions and Answers for Aspiring System Administrators"

Preparing for a Linux interview involves understanding various topics, ranging from basic commands to advanced system administration tasks. Here are some commonly asked Linux interview questions across different levels of expertise:

Basic Questions

  1. What is Linux and what are its advantages?

    • Linux is an open-source operating system based on Unix. Advantages include its security, flexibility, free cost, and strong community support.
  2. Explain the directory structure of Linux.

    • The Linux file system is hierarchical. Common directories include /, /bin, /etc, /home, /var, /tmp, /usr, /lib, /opt, and /root.
  3. What are the basic commands for file management?

    • ls, cp, mv, rm, mkdir, rmdir, touch, cat, more, less.
  4. How do you change file permissions in Linux?

    • Using the chmod command. For example, chmod 755 filename.
  5. What is the difference between a hard link and a soft link?

    • A hard link is a direct reference to the inode of a file, while a soft link (symlink) is a pointer to the pathname of the file.

Intermediate Questions

  1. How do you check the system load and memory usage?

    • Using commands like top, htop, vmstat, free, uptime.
  2. How do you find and kill a process?

    • Using ps, top, htop, and kill commands. For example, kill -9 PID.
  3. Explain the use of the grep command.

    • grep is used to search text using patterns. For example, grep "pattern" file.txt.
  4. What is a cron job and how do you set one up?

    • A cron job is a scheduled task using the cron daemon. Set up with crontab -e.
  5. How do you view and manage disk usage?

    • Using df and du commands. For example, df -h for disk space and du -sh * for directory sizes.

Advanced Questions

  1. Explain how you would troubleshoot a network issue in Linux.

    • Using tools like ping, traceroute, netstat, ss, ifconfig/ip, tcpdump.
  2. What is LVM and how do you manage it?

    • Logical Volume Manager (LVM) allows for flexible disk management. Commands include pvcreate, vgcreate, lvcreate, lvextend, lvreduce.
  3. How do you secure a Linux server?

    • Regular updates, configuring firewalls (iptables/firewalld), SSH hardening, using SELinux/AppArmor, setting up proper permissions, disabling unnecessary services.
  4. What is a kernel, and how do you upgrade it?

    • The kernel is the core of the OS managing system resources. Upgrade using package managers like apt, yum, or compiling from source.
  5. Explain the use of Docker in Linux.

    • Docker is used for containerization. Commands include docker run, docker build, docker ps, docker-compose.

Scripting and Automation

  1. Write a simple bash script to back up a directory.

    #!/bin/bash
    tar -czvf backup.tar.gz /path/to/directory
    
  2. How do you automate tasks in Linux?

    • Using shell scripts, cron jobs, and tools like Ansible, Puppet, or Chef.
  3. What are environment variables and how do you set them?

    • Variables that affect the behavior of processes. Set them using export VAR=value.
  4. Describe the use of awk and sed.

    • awk is used for pattern scanning and processing. sed is a stream editor for filtering and transforming text.
  5. How do you monitor log files in real-time?

    • Using tail -f /var/log/syslog or less +F /var/log/syslog.

Practical Scenario Questions

  1. How would you recover a deleted file in Linux?

    • Using tools like extundelete, testdisk, or from backups.
  2. What steps would you take to improve the performance of a Linux server?

    • Optimize applications, adjust kernel parameters, monitor resource usage, upgrade hardware, and use load balancing.
  3. How do you set up a simple web server on Linux?

    • Install and configure Apache (httpd), Nginx, or another web server.
  4. How would you configure a RAID array in Linux?

    • Using mdadm for software RAID.
  5. Describe the process of setting up a firewall in Linux.

    • Using iptables or firewalld to create rules for traffic filtering.

These questions cover a broad range of topics and are commonly asked in Linux interviews to assess a candidate's knowledge and problem-solving skills.

Top comments (0)