🌙
☀️ Dark
PART 25

Linux

Filesystem, permissions, processes, systemd.

Intermediate 45 min read

Volume 25: Linux & Server Fundamentals

Medium: What does `chmod 755` mean?
7 is Read(4)+Write(2)+Execute(1) for the owner. 5 is Read(4)+Execute(1) for the group. The second 5 is Read(4)+Execute(1) for everyone else.
Hard: A process on port 8080 is hanging and you can't restart your app. How do you fix it?
Use lsof -i :8080 or ss -lptn 'sport = :8080' to find the PID of the process. Then run kill -15 <PID> to ask it to terminate gracefully. If it refuses, use kill -9 <PID>.
Senior: What is a zombie process, and how do you kill it?
A zombie process is a process that has completed execution but still has an entry in the process table because its parent hasn't read its exit status. You cannot `kill -9` a zombie because it is already dead. You must either kill its parent process or wait for the init system (PID 1) to reap it.

Engineering Challenge

Your server disk is 100% full, but when you run ls -la /, the files don't add up to the total disk space. Why?

Hint: A process is still holding a file descriptor open to a deleted file. The space won't be freed until the process is restarted. Find it using lsof | grep deleted.

Revision Sheet

Connections

Linux is the foundation. In the next chapters, you will see how Docker uses Linux namespaces and cgroups to create isolated containers, and how CI/CD pipelines are essentially automated Linux shell scripts.

PreviousVolume 24 🏠 Curriculum NextVolume 26
🏠 Curriculum NextVolume 2

Mini Project (20-30 min)

Implement a small feature related to this chapter.

▶ View Solution
Solution goes here.

Bigger Project (1-2 hours)

Apply all concepts from this volume to build a comprehensive feature.

▶ View Solution
typescript
// Example project code here

Interview Questions

Easy: What is the difference between an absolute and a relative path?
An absolute path starts from the root directory / (e.g., /var/www/app). A relative path starts from the current directory (e.g., ./app or ../config).
Medium: What does `chmod 755` mean?
7 is Read(4)+Write(2)+Execute(1) for the owner. 5 is Read(4)+Execute(1) for the group. The second 5 is Read(4)+Execute(1) for everyone else.
Hard: A process on port 8080 is hanging and you can't restart your app. How do you fix it?
Use lsof -i :8080 or ss -lptn 'sport = :8080' to find the PID of the process. Then run kill -15 <PID> to ask it to terminate gracefully. If it refuses, use kill -9 <PID>.
Senior: What is a zombie process, and how do you kill it?
A zombie process is a process that has completed execution but still has an entry in the process table because its parent hasn't read its exit status. You cannot `kill -9` a zombie because it is already dead. You must either kill its parent process or wait for the init system (PID 1) to reap it.