Skip to content

Lesson 1: Linux Primitives & Permissions

🧠 The Concept (Explain Like I'm 5)

Imagine your computer is a massive office building. In Linux, "Everything is a file." A text document is a file, your keyboard is a file, and a network connection is a file. If you want to change how the system works, you simply edit a text file.

Here is how the architecture looks:

flowchart TD
    User((πŸ‘¨β€πŸ’» You)) -->|Types 'cat file.txt'| Shell["The Shell / Bash<br/>The Receptionist"]
    Shell -->|Translates to System Call| Kernel{"The Linux Kernel<br/>The Building Manager"}
    Kernel -->|Checks Permissions| Security[Permissions Check]
    Security -->|Approved| Hardware[(Hardware / Disk)]
    Hardware --> Kernel
    Kernel --> Shell
    Shell --> User

🏒 The Enterprise Context (Why Architects Care)

You might think, "I'm going to be deploying advanced cloud infrastructure, why do I care about basic Linux commands?"

Here is the architect reality: When you deploy a Docker container to a Kubernetes cluster, that container is just an isolated Linux process. If you do not deeply understand Linux permissions, your enterprise applications will fail because: 1. A web server pod won't have permission to read its SSL certificate. 2. A database container will fail to write data to its attached storage volume. 3. You will accidentally run containers as the root user, creating a massive security vulnerability.

πŸ’» The Syntax & Cheatsheet

1. Understanding Permissions (chmod & chown)

When you type ls -la, you will see something like this on the left side: -rwxr-xr--

Here is the visual breakdown of what that means:

  [Type]   [ Owner ]   [ Group ]   [ Everyone Else ]
    ↓          ↓           ↓               ↓
    -         rwx         r-x             r--

          Read: Yes    Read: Yes       Read: Yes
         Write: Yes   Write: NO       Write: NO
       Execute: Yes Execute: Yes    Execute: NO

Changing Permissions (chmod): We use numbers to set permissions fast. (Read=4, Write=2, Execute=1). * chmod 777 file.txt -> 7 (4+2+1) for everyone. VERY DANGEROUS! Anyone on the server can do anything to this file. * chmod 600 key.pem -> 6 (4+2) Owner can read/write. Group and Others get 0 (Nothing). This is required for SSH keys!

2. Navigation & Inspection

  • pwd (Print Working Directory): "Where am I right now?"
  • ls -la: List all files, including hidden files (which start with .), and show their exact permissions.
  • cat <filename>: Print the contents of a file to the screen.

3. Process Management

  • top / htop: See what processes are eating up your CPU/Memory.
  • ps aux | grep nginx: Find the specific Process ID (PID) of the NGINX web server.
  • kill -9 <PID>: Forcefully murder a stuck or rogue process.

πŸ“ Knowledge Check

Think about these before you proceed to the lab. The answers separate beginners from engineers:

Question 1

If you download an AWS SSH key (my-key.pem), why will AWS actively block you from using it if its permissions are 777?

Question 2

You run an application, but it crashes saying "Permission denied" when trying to write to /var/log/app.log. What command do you run to see who currently owns that file?

Ready? Head back to the Phase 0 index to complete The Linux Web Server Script lab!