Fundamentals 67 min read

Essential Linux Interview Guide: 100+ Questions on Basics, Commands, Security, Scripting & More

This comprehensive guide compiles over 100 essential Linux interview questions, covering fundamentals, system architecture, command-line tools, security practices, scripting, file management, networking, and performance tuning for job interviews.

ITPUB
ITPUB
ITPUB
Essential Linux Interview Guide: 100+ Questions on Basics, Commands, Security, Scripting & More

1. Linux Overview

Linux is a free, open‑source Unix‑like operating system based on POSIX. It supports multi‑user, multitasking, multithreading, and runs on both 32‑bit and 64‑bit hardware. It inherits the network‑centric design of Unix and provides stable performance.

1.1 What is Linux?

Linux is a free, open‑source operating system that implements the Unix philosophy, supporting multiple users, multitasking, threads, and a wide range of hardware.

1.2 Differences between Unix and Linux

Open source : Linux is open source and free; Unix is proprietary and requires a paid license.

Cross‑platform : Linux runs on many hardware platforms; Unix has limited portability.

GUI : Linux provides both command‑line and graphical interfaces; traditional Unix is command‑line only.

Hardware requirements : Linux runs on modest hardware; Unix often requires specialized hardware.

User base : Linux is used by individuals and enterprises; Unix is mainly used by large enterprises with high security needs.

1.3 What is the Linux kernel?

The kernel controls all hardware and software resources, handling memory management, process management, device management, and the file system.

1.4 Basic components of Linux

Linux consists of the kernel, shell (command interpreter), GUI, system utilities, and applications.

1.5 Linux architecture

The architecture is divided into user space and kernel space.

Linux architecture diagram
Linux architecture diagram

User Space includes user applications and the C library. Kernel Space includes the system call interface, the kernel itself, and architecture‑dependent code. The separation improves security and stability.

2. Disk, Directory, and File

In Linux, everything is treated as a file, including devices, sockets, and pipes.

2.1 Simple Linux file system

Linux supports five file types: regular files, directories, character devices, block devices, and symbolic links.

2.2 Directory structure

The root directory (/) is the top of the hierarchy. Common directories include /bin, /etc, /home, /usr, /proc, /root, /sbin, /dev, /mnt, /boot, /lib, /tmp, /var, and /lost+found.

Linux directory tree
Linux directory tree

2.3 Inode

An inode stores metadata about a file, such as size, owner, permissions, timestamps, and pointers to data blocks. The file name is stored separately in directory entries.

2.4 Hard link vs. soft link

Hard link : Directly points to the same inode; cannot span file systems; cannot link directories; deletion of one link does not affect the file.

Soft link (symbolic link) : A special file that contains a path to another file; can cross file systems; can link directories; becomes dangling if the target is moved or deleted.

3. Security

3.1 Basic hardening steps after installation

Add a regular user and disable root SSH login; change the default SSH port.

Use key‑based SSH authentication and disable password login.

Enable the firewall and disable SELinux if not needed.

Install fail2ban to block brute‑force attacks.

Restrict SSH access to specific IP ranges.

Configure application‑level firewalls (e.g., nginx_waf) and run services under non‑privileged users.

3.2 Common attacks

CC (Challenge Collapsar) attack : Exhausts server resources by repeatedly requesting a page.

DDOS attack : Distributed denial‑of‑service attack using many compromised hosts.

3.3 SQL injection

Improper input validation allows attackers to inject malicious SQL statements. Use prepared statements, parameterized queries, or a web application firewall (e.g., nginx_waf) to mitigate.

4. Shell Scripting

4.1 What is a shell script?

A text file containing a sequence of commands that can be executed by a shell interpreter (e.g., /bin/bash).

4.2 Changing the default login shell

# chsh username -s /bin/sh

4.3 Comments

# This is a comment

4.4 Variables

System‑defined variables are uppercase; user‑defined variables are created by assignment.

4.5 Exit status ( $? )

# ls /usr/bin/shar
# echo $?
# 0   # success
# ls /usr/bin/share
# echo $?
# 2   # failure

4.6 Control structures

Examples of if, case, for, while, and do‑while loops are provided.

4.7 Functions

diskusage() { df -h; }

4.8 Reading input

read -p "Input file name: " FILENAME

4.9 Example tasks

Copy character devices to /dev if they exist.

Create a group and add 30 users with names std01std30.

Delete 50 accounts named stud1stud50.

Use sed to delete empty lines and insert AAA before and BBB after the string 11111.

5. Practical Operations

5.1 Choosing a Linux distribution

Desktop: Ubuntu.

Server: RHEL, CentOS (most common), or Debian for higher security.

Specialized needs: SUSE for advanced services, Fedora for cutting‑edge features.

5.2 Planning a Linux host

Determine the purpose (web, DB, game server), select the OS, plan partitioning, configure users, and tune performance.

5.3 Handling a slow website

Check bandwidth, server load ( uptime, top), database performance, and application code.

Use monitoring tools, optimize queries, add caching (e.g., Redis), or deploy a CDN.

5.4 Linux performance tuning methods

Disable unnecessary daemons.

Turn off the GUI.

Adjust kernel parameters.

Tune CPU, memory, file‑system, and network subsystems.

6. File Management Commands

6.1 cat

Concatenates and displays file contents. Options -n (line numbers) and -b (non‑empty line numbers) are common.

6.2 chmod

Changes file permissions. Symbolic mode (e.g., a+x) and numeric mode (e.g., 751) are supported.

6.3 chown

Changes file owner and group.

6.4 cp

Copies files or directories. Options -i (prompt), -r (recursive), and -a (preserve attributes) are typical.

6.5 find

Searches for files matching criteria such as name, type, size, permissions, or modification time.

6.6 head and tail

Display the beginning or end of a file. tail -f follows a growing file (useful for logs).

6.7 less and more

Pagers for viewing long output with navigation commands.

6.8 ln

Creates hard links ( ln) or symbolic links ( ln -s).

6.9 locate , whereis , which

Fast file location utilities using a pre‑built database.

7. Text Processing Commands

7.1 grep

Searches files for patterns using regular expressions. Common options: -i (ignore case), -r (recursive), -n (line numbers), -c (count), -l (list matching files).

7.2 wc

Counts lines, words, and bytes. Options -l, -w, -c, -m.

7.3 sed

Stream editor for in‑place text transformations, such as deleting empty lines or inserting text.

7.4 awk (not shown but often paired with grep )

Powerful pattern‑scanning and processing language.

8. Disk Management Commands

8.1 df

Shows filesystem disk space usage. Use -h for human‑readable output.

8.2 du

Displays disk usage of files and directories. Options -h, -s, --max-depth help summarize.

8.3 ls

Lists directory contents. Common options: -a, -l, -h, -t, -S, -r.

8.4 mkdir and rmdir

Create and remove directories. mkdir -p creates parent directories as needed.

8.5 pwd

Prints the current working directory.

9. Network Communication Commands

9.1 ifconfig / ip

Displays and configures network interfaces.

9.2 iptables

Manages firewall rules. Example: iptables -A INPUT -p tcp --dport 80 -j ACCEPT.

9.3 netstat

Shows network connections, routing tables, and interface statistics.

9.4 ping

Tests reachability of a host.

9.5 telnet

Connects to remote services for testing.

10. System Management Commands

10.1 date

Displays or sets the system date and time. Supports formatting with + specifiers.

10.2 free

Shows memory usage. Options -m, -g, -t for totals.

10.3 kill

Sends signals to processes (e.g., kill -9 PID).

10.4 ps

Lists running processes. Common options: -ef, -aux.

10.5 top

Interactive real‑time process monitor. Press c to toggle full command line, P to sort by CPU, M to sort by memory.

10.6 yum

Package manager for RPM‑based distributions. Commands include yum install, yum update, yum remove, yum search, and cache cleaning.

11. Backup and Compression Commands

11.1 bzip2 and gzip

Compress and decompress files ( .bz2, .gz).

11.2 tar

Archives files; combined with -z (gzip) or -j (bzip2) for compression. Example: tar -zcvf backup.tar.gz /etc.

11.3 unzip

Extracts .zip archives.

12. Vim Editor

Vim is an enhanced version of vi with syntax highlighting, code completion, and multiple modes (command, insert, and last‑line).

Vim mode diagram
Vim mode diagram

Use i to enter insert mode, Esc to return to command mode, and : to enter command‑line mode.

13. Miscellaneous Commands

chmod

, chown, ln, locate, whereis, which – file and command location utilities. pwd -P – shows the physical directory without following symlinks. rmdir -p – removes a directory and its empty parents.

This guide provides a solid foundation for anyone preparing for Linux‑related interview questions, covering core concepts, essential commands, scripting techniques, security best practices, and system administration tasks.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linux
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.