Part 3: Permissions & Processes - System Control
Table of Contents
Master file permissions, ownership, and process management on Linux Now that you can navigate and search, let’s learn to control the system: managing permissions and processes. When you run Permission meanings: Exercise 3.1: Symbolic method (easier to remember): Legend: Numeric method (faster when you know it): Calculate: Exercise 3.2: Common permission patterns: Requires sudo (root privileges): Exercise 3.3: See your groups: A process is a running program. Every command you run creates a process. Show running processes: Exercise 3.4: Understanding ps aux output: Interactive process monitor: Controls in Exercise 3.5: Common signals: Exercise 3.6: Exercise 3.7: Keep process running after logout: Uses a database (updated nightly): Exercise 3.8: Show disk usage: Exercise 3.9: Show directory sizes: Exercise 3.10: Ready to practice? Complete the hands-on challenge in the workshop repository: Challenge: Set up scripts with proper file permissions and create a system information script. The challenge includes: Clone the repository and give it a try:Navigation
Understanding File Permissions
ls -l, you see something like:
Permission Breakdown
-rw-r--r--
│││ │││ │││
│││ │││ └┴┴─ others: read only
│││ └┴┴──── group: read only
│└┴──────── owner: read + write
└────────── file type (- = file, d = directory, l = link)
r (read) = 4 w (write) = 2 x (execute) = 1
# Decode what you see!
Changing Permissions
chmod - Change Modeu = user (owner)g = groupo = othersa = all (ugo)+ = add permission- = remove permission= = set exactlyr=4, w=2, x=1, then add:755 = rwxr-xr-x = (4+2+1)(4+0+1)(4+0+1)644 = rw-r--r-- = (4+2+0)(4+0+0)(4+0+0)
# Create a script
# Try to run it
# Make it executable
# Make it read-only
# Try to edit it - you'll need sudo!
755 - Scripts, executables644 - Regular files (documents, configs)600 - Private files (SSH keys, passwords)700 - Private directorieschown - Change Owner
# This will likely fail (unless you're root):
# sudo chown root myfile.txt
# sudo chown $USER myfile.txt # Change back
chgrp - Change Group
Process Management
ps - Process Status |
|
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 16832 1234 ? Ss 10:00 0:01 /sbin/init
│ │ │ │ │ │ │ │ │ │ └─ command
│ │ │ │ │ │ │ │ │ └─ CPU time
│ │ │ │ │ │ │ │ └─ start time
│ │ │ │ │ │ │ └─ state (S=sleeping, R=running)
│ │ │ │ │ │ └─ terminal
│ │ │ │ │ └─ memory (KB)
│ │ │ │ └─ virtual memory
│ │ │ └─ % of RAM
│ │ └─ % of CPU
│ └─ Process ID
└─ User
top / htop - Live Process Viewertop:q - Quitk - Kill process (prompts for PID)M - Sort by memoryP - Sort by CPUh - Help
# Press 'M' to sort by memory
# Press 'q' to quit
kill - Terminate Process15 (SIGTERM) - Default, graceful shutdown9 (SIGKILL) - Force kill immediately1 (SIGHUP) - Reload config2 (SIGINT) - Interrupt (like Ctrl+C)# Start a long-running process in background
&
# Find it
|
# Kill it (replace 12345 with actual PID)
# Verify it's gone
|
Background Jobs
& # Run in background
# List background jobs
# Bring to foreground
# Resume in background
# Start in background
&
# List jobs
# Start another, then suspend it
# Press Ctrl+Z
# List jobs again
# Resume in background
# Kill all background jobs
nohup - No Hangup &
# Output goes to nohup.out
File Searching (Advanced)
locate - Fast File Search
which - Find Executable Location
whereis - Find Binary, Source, Manual
System Information
df - Disk Free
du - Disk Usage
|
free - Memory Usageuname - System InfoHands-On Challenge
Quick Reference Card
# Permissions
# Processes
# Background jobs
# System Info