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
- /etc: Configuration files.
- /var/log: Log files.
- /home: User directories.
- PID 1: systemd (the mother of all processes).
- chmod / chown: Manage permissions and ownership.
- env vars: Runtime configuration injected into processes.
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.