Linux Interview Questions and Answers

Linux Interview Questions and Answers

By - Amol Shende5/24/2025

Prepare with top Linux Interview Questions and Answers. Cover essential commands, scripting, system admin, and troubleshooting tips to ace your next interview!

 

1. What is pgrep in Linux?

The pgrep command helps identify running processes by name or attributes and returns their Process IDs (PIDs).

Examples:

  • Find PIDs of nginx:                                          pgrep nginx
  • List matching processes by name:               pgrep -l apache
  • Filter by user:                                                   pgrep -u amol

 

 

2. What is rsync, and how is it used?

rsync is a powerful tool used for syncing files between directories or systems, locally or over a network.

Basic Syntax:     rsync [options] source destination

Example:

rsync -av ~/Documents/ ~/Downloads/

Extended Use:

rsync -avz --delete ~/Documents/ ~/Downloads/

  • -a means archive mode—it copies everything while keeping file settings like permissions, links, and timestamps intact.
  • -v: Verbose output
  • -z: Compress data during transfer
  • --delete removes files from the destination if they don't exist in the source anymore, keeping both sides in sync.

 

3. Process vs Thread

Yes, a single process can have multiple threads—this is the essence of multithreading.

Thread Basics:

  • A thread is a small task inside a program that runs on its own.
  • Threads in one program use the same memory and tools to work together

Advantages of Threads:

  • Faster inter-thread communication
  • Efficient resource usage
  • Suitable for parallel tasks (e.g., web servers, GUI apps)

 

4. ulimit Command in Linux

ulimit sets or displays limits on system resources used by shell sessions.

Common Options:

  • ulimit -a                         -- Show all limits     
  • ulimit -n 1024               -- sets the limit for how many files a program can open
  • ulimit -c unlimited       -- allows full crash logs (core dumps) to be saved.
  • ulimit -f 5000                -- Limit file size in 512-byte blocks

 

Permanent Changes:

Edit /etc/security/limits.conf for persistent settings.

Explore Other Demanding Courses

No courses available for the selected domain.

5. What is /proc in Linux?

The /proc directory is a virtual filesystem providing kernel and process info in real-time.

Examples:

  • /proc/cpuinfo — CPU details
  • /proc/meminfo — RAM usage
  • /proc/[pid]/ — Info on specific processes
  • cat /proc/uptime — System uptime

 

6. What is strace?

Strace lets you see what a program is doing behind the scenes by tracking its system calls as they happen.

Example:

strace ls

This displays every syscall ls invokes, useful for debugging and reverse engineering.

 

7. What is PCP (Performance Co-Pilot)?

PCP is a tool that helps you track and study how well your Linux system is running by collecting performance data.

How to Start:

sudo dnf install pcp -y

sudo systemctl start pmcd

Use Tools Like:

  • pmrep — Live system stats
  • pmlogger — Data logging
  • grafana-pcp — Visual dashboards

 

 

8. Troubleshooting Linux Boot Issues

Steps to diagnose boot failures:

  1. Observe GRUB for errors.
  2. Boot into an older kernel if needed.
  3. Inspect /var/log/boot.log or dmesg.
  4. Revert recent system changes.
  5. Test hardware connections (RAM, drives).

 

 

9. sed Command in Linux

sed is used for stream editing, particularly replacing or modifying text.

Example:

sed 's/error/success/g' file.txt

Replaces all “error” with “success” in file.txt.

 

10. What is Network Bonding?

Network Bonding aggregates multiple NICs into a single logical interface, improving:

  • Redundancy
  • Throughput
  • Load balancing

Common Modes:

  • Mode 1: Active-Backup (failover)
  • Mode 4: LACP (IEEE 802.3ad)
  • Mode 0: Round-Robin

Configure (RHEL style):

sudo modprobe bonding

# Then edit /etc/sysconfig/network-scripts/ifcfg-bond0 and slave configs

 

11. What is netstat?

Netstat is a tool that shows who your computer is connected to, which ports are open, and how data is being routed.

Example:

netstat -tuln

Shows all TCP and UDP listening ports.

 

12. What are cgroups?

Control Groups (cgroups) are used to manage resource usage for processes.

Features:

  • Limit memory/CPU
  • Prioritize bandwidth
  • Monitor usage
  • Isolate workloads (used by containers like Docker)

Paths:

  • cgroup v1: /sys/fs/cgroup/
  • cgroup v2: /sys/fs/cgroup/unified/

Example:

mkdir /sys/fs/cgroup/memory/testgroup

echo 100000000 > memory.limit_in_bytes

echo <PID> > tasks

 

13. What are Kernel Modules?

Kernel modules are add-on parts of the Linux system that can be loaded or removed while it's running, letting you add drivers or features without restarting the computer.

Common Commands:

  • lsmod               # List loaded modules
  • modprobe loop                 # Load a module
  • rmmod loop                       # Remove a module
  • modinfo loop                     # Info about the module

 

Do visit our channel to learn more: SevenMentor

Author:-

Amol Shende

Get Free Consultation

Loading...

Call the Trainer and Book your free demo Class..... Call now!!!

| SevenMentor Pvt Ltd.

© Copyright 2025 | SevenMentor Pvt Ltd.

Share on FacebookShare on TwitterVisit InstagramShare on LinkedIn