Linux Internals Questions

OS concepts, kernel, and shell scripting.

1. Load Average

Question: What does "load average" mean in the output of top or uptime?

It represents the average number of processes waiting for CPU time over the last 1, 5, and 15 minutes. A load average higher than the number of CPU cores indicates a bottleneck.

2. Inodes

Question: What is an inode?

An inode (index node) is a data structure in a Unix-style file system that describes a file-system object like a file or a directory. It stores attributes (permissions, owner, size) and disk block locations, but not the filename.

3. File Permissions

Question: Explain the output drwxr-xr-x and how to change permissions.

Breakdown: d (directory), rwx (Owner: read/write/execute), r-x (Group: read/execute), r-x (Others: read/execute).

Commands:

  • chmod 755 file: Sets permissions (7=rwx, 5=r-x).
  • chown user:group file: Changes ownership.

4. Process Management

Question: How do you find and kill a process consuming high CPU?

  1. Find: Run top or htop to see processes sorted by CPU usage. Or use ps aux | grep <name>.
  2. Identify: Note the PID (Process ID).
  3. Kill: Run kill <PID> (sends SIGTERM - polite kill). If it's stuck, use kill -9 <PID> (sends SIGKILL - forceful kill).

5. Networking Basics

Question: What commands would you use to troubleshoot connectivity issues?

  • ping google.com: Check if the host is reachable.
  • curl -v http://example.com: Check if the web server is responding and view headers.
  • netstat -tuln or ss -tuln: Check which ports are open and listening on your server.
  • nslookup or dig: Troubleshoot DNS resolution issues.