Monday, April 13, 2026
Cohort 3 | Project CloudIgnite Topics: Linux File Management Duration: ~3 hours
📌 CLF-C02 Relevance Notice Most of this lecture covers Linux OS fundamentals (file system, permissions, CLI commands), which are not directly tested on the AWS Certified Cloud Practitioner (CLF-C02) exam. However, two areas are relevant:
- File permissions (
chmod) — understanding permission models is foundational to AWS IAM concepts (least privilege, resource access control).- SSH key management (
chmod 400) — directly used when connecting to Amazon EC2 instances, which is tested on CLF-C02 under compute services. See the CLF-C02 Exam Guide for full domain coverage.
Key Takeaways
- Linux file system: everything is a file (processes in
/proc, hardware in/dev) - File permissions:
rwxfor owner/group/others;chmod 400for SSH keys on EC2 - Core commands:
ls,cat,less,head,tail,cp,mv,rm,mkdir,touch - Search:
findlocates files by name/attributes;grepsearches text inside files - Hard links point to inode (survive deletion); symbolic links point to path (break on deletion)
- Lab 233: Practical exercises on EC2 via SSH — create dirs, files, copy/move/delete
Table of Contents
- Knowledge Check Review — Vim Text Editor
- Linux File System Fundamentals
- File Permissions
- Linux Directory Structure
- File Viewing Commands
- File & Directory Management Commands
- Navigating the File System
- Advanced File Operations
- Links — Hard Links & Symbolic Links
- Lab 233 Summary — Practical Exercises
- Quick Reference Cheat Sheet
1. Knowledge Check Review — Vim Text Editor
Vim is the default terminal-based text editor for virtually all Linux distributions.
| Action | Key/Command |
|---|---|
| Enter Insert mode | i |
| Return to Command mode | Esc |
| Save file | :w |
| Quit editor | :q |
| Save and quit | :wq |
| Quit without saving | :q! |
| Delete a single character | x |
Other text editors mentioned:
nano— simpler terminal editorgedit— GUI-based editor (GNOME desktop only, e.g., GNOME, Xfce)vi— older predecessor to Vim
2. Linux File System Fundamentals
"Everything is a File" Philosophy
A core Linux principle: almost everything in Linux is represented as a file, including:
- Regular files and folders
- Running processes (found under
/proc/<PID>) - Physical hardware devices (found under
/dev)
Example: To see Zoom's process ID, navigate to /proc and locate the Zoom directory — the folder name is the process ID.
File Naming Rules
- Linux filenames are case-sensitive (
File.txt≠file.txt) - Avoid spaces in filenames
- Avoid forward slashes
/in filenames - File extensions are optional — a file can exist without one (defaults to plain text)
3. File Permissions
Permission String Format
When you run ls -l, you see something like:
drwxrwxrwx
| Position | Character | Meaning |
|---|---|---|
| 1st | d | Directory (folder) |
| 1st | - | Regular file |
| 2nd–4th | rwx | Owner (current user) permissions |
| 5th–7th | rwx | Group permissions |
| 8th–10th | rwx | Others (all other users) permissions |
Each permission: r = read, w = write, x = execute
Numeric (Octal) Permission Values
Permissions are represented in binary, then converted to a single digit:
| Binary | Decimal | Meaning |
|---|---|---|
000 | 0 | No permission |
100 | 4 | Read only |
110 | 6 | Read + Write |
111 | 7 | Read + Write + Execute (full) |
Format: Three digits — [owner][group][others]
| Command | Permission Set | Meaning |
|---|---|---|
chmod 400 file | r-------- | Owner read-only (used for SSH keys) |
chmod 600 file | rw------- | Owner read + write |
chmod 777 file | rwxrwxrwx | Full permission for everyone |
⚠️ CLF-C02 Relevance:
chmod 400 labsuser.pemis the exact command used to secure your EC2 SSH key before connecting — a real-world AWS task.
4. Linux Directory Structure
Starting from / (root — the top of the entire filesystem):
| Directory | Purpose |
|---|---|
/ | Root — top of the entire file system |
/boot | Boot files and Linux kernel |
/dev | Device files (hardware represented as files) |
/etc | System-wide configuration files |
/home | Personal workspace for each user (/home/username) |
/media | Removable media (USB drives, pen drives) |
/mnt | Network drives / mount points |
/proc | Running processes (dynamically generated) |
/root | Home directory for the root (admin) user only |
/var | Variable files — log files, activity logs |
Tip: /home is where users store personal files. /root is only for the superuser and should not be used for general file storage.
5. File Viewing Commands
ls — List Directory Contents
| Option | Effect |
|---|---|
ls | List files in current directory |
ls -l | Long format (permissions, owner, size, date) |
ls -h | Human-readable file sizes (KB, MB) |
ls -a | Show all files, including hidden files (prefixed with .) |
ls -R | Recursively list subdirectories |
ls -lh filename | Long format + human-readable size for one file |
ls -laR | Combined: long, all hidden, recursive |
cat — Display File Contents
Prints the full content of a file to the terminal.
cat file.txt
more — Paginated File View
- Loads the entire file into RAM at once
- Use for small files only
- Allows forward scrolling
less — Efficient Paginated View
- Loads content page by page (memory-efficient)
- Use for large files
- Supports both forward and backward scrolling
-Nflag: show line numbers-Xflag: clear screen before loading-Fflag: watch mode — shows live updates as file changes
Rule of thumb: Use
lessfor large files,morefor small ones.lessworks well for both.
head — View Beginning of File
- Shows the first 10 lines by default
-n <number>: specify how many lines to show
head -n 20 file.txt
tail — View End of File
- Shows the last 10 lines by default
-n <number>: specify lines-f: follow/monitor mode — live updates as file changes (useful for log monitoring)
tail -f /var/log/syslog
6. File & Directory Management Commands
cp — Copy Files
cp source destination
cp file.txt /home/user/backup/
| Option | Meaning |
|---|---|
-i | Interactive — ask before overwriting |
-f | Force — no prompts |
-n | Do not overwrite existing files |
-R | Recursively copy a directory |
-v | Verbose — show what's happening |
mv — Move or Rename Files
mv oldname.txt newname.txt # Rename
mv file.txt /home/user/folder/ # Move
Same -i, -f, -v options as cp.
rm — Remove (Delete) Files
rm file.txt # Delete a file
rm -R directory/ # Delete a non-empty directory
rmdir directory/ # Delete an EMPTY directory only
| Option | Meaning |
|---|---|
-R or -r | Recursively delete directory and contents |
-f | Force delete, no prompts |
-i | Ask confirmation before each delete |
-v | Verbose — show deleted files |
-d | Delete only if directory is empty |
⚠️ Warning:
rmin terminal is permanent. There is no Recycle Bin from the CLI. GUI deletion moves to trash; terminal deletion does not.
mkdir — Create Directory
mkdir foldername
mkdir -p parent/child/grandchild # Create nested directories in one command
mkdir -m 755 foldername # Create with specific permissions
touch — Create Empty File
touch filename.txt
touch file1.csv file2.csv # Create multiple files at once
rmdir — Remove Empty Directory
rmdir foldername
Only works if the folder is completely empty.
7. Navigating the File System
pwd — Print Working Directory
Shows your current location in the file system.
pwd
# Output: /home/ec2-user/companyA
cd — Change Directory
| Command | Action |
|---|---|
cd foldername | Navigate into a folder |
cd .. | Go one level up (parent directory) |
cd ../.. | Go two levels up |
cd ../finance | Go up one level, then into finance |
cd ~ | Go to your home directory |
cd /absolute/path | Navigate using absolute path |
Absolute vs Relative Paths
| Type | Description | Example |
|---|---|---|
| Absolute | Full path from root /; works from anywhere | /home/ec2-user/companyA/HR |
| Relative | Path relative to current location | ../finance or HR/employees |
Shortcut: ~ is an alias for /home/username (your home directory).
Combining Commands
cd companyA && mkdir finance # Second command runs ONLY if first succeeds
cd companyA ; mkdir finance # Both commands run independently
8. Advanced File Operations
hash — Recently Used Commands
Displays a table of recently executed commands, their file locations, and how many times they've been run.
hash
Most standard Linux commands (like ls, mv, cp) are actually executable files stored in /usr/bin/.
Checksum — File Integrity Verification (CRC)
Used to verify a downloaded file has not been corrupted or tampered with.
- Website provides a checksum file alongside the download
- After downloading, generate the checksum of your file and compare it to the provided value
- If they match → file is intact
find — Search for Files
find /path -name "filename.txt" # Find by exact name
find . -iname "filename.txt" # Case-insensitive search
find . -name "*.csv" # Find all CSV files (wildcard)
find . -user ec2-user # Find files owned by a user
find . -type f -name "*.jpg" # Find by file type
find . -mtime -7 # Modified within last 7 days
| Option | Meaning |
|---|---|
-name | Search by filename (case-sensitive) |
-iname | Search by filename (case-insensitive) |
-user | Search by file owner |
-type | Search by type (f=file, d=directory) |
-mtime | Search by last modification time |
-fprint | Write results to a file |
-exec | Execute a command on found files |
-delete | Delete found files |
grep — Search Inside File Contents
grep "search_term" file.txt # Basic search
grep -i "search_term" file.txt # Case-insensitive
grep -n "search_term" file.txt # Show line numbers
grep -c "search_term" file.txt # Count matching lines
grep -l "search_term" *.txt # Show only filenames with match
cat file.txt | grep "search_term" # Piped usage
find vs grep:
findlocates files by name/attributes.grepsearches for text content inside files.
diff — Compare Two Files
diff file1.txt file2.txt
Shows the lines that differ between two files. Output shows exact position of differences.
9. Links — Hard Links & Symbolic Links
inode — The Actual File
- In Linux, every file has an inode: a data structure storing the file's metadata
- File type, size, owner, permissions
- Exact physical location on disk
- The inode number is the system's internal identifier for the file
Hard Link
- A human-readable filename that points to an inode
- Every filename you see (e.g.,
file.txt) is actually a hard link - Multiple hard links can point to the same inode (same file, multiple names)
- The file is only truly deleted when ALL hard links to its inode are removed
ln file.txt backup.txt # Create a hard link
ls -i # View inode numbers (same number = same file)
Key behaviour: Changing content through one hard link updates all others — they share the same inode.
Symbolic Link (Soft Link)
- Similar to a Windows shortcut
- Stores the path/location of another file — not the data itself
- If the original file is deleted, the symbolic link breaks
ln -s /path/to/original linkname
| Feature | Hard Link | Symbolic Link |
|---|---|---|
| Points to | inode (actual data) | File path |
| Cross-filesystem | No | Yes |
| Breaks if original deleted | No (data survives) | Yes |
| Windows equivalent | N/A | Shortcut |
10. Lab 233 Summary — Practical Exercises
Lab Goal: Practice Linux file management on an EC2 instance via SSH.
Connection Steps (Windows)
# 1. Navigate to Downloads folder
cd Downloads
# 2. Delete old key file (if exists)
rm labsuser.pem
# 3. Download new labsuser.pem from lab environment
# 4. Set correct permission on key
chmod 400 labsuser.pem
# 5. Connect via SSH
ssh -i labsuser.pem ec2-user@<Public-IP>
If you get "Permission denied (publickey)": You likely have an old key file conflicting. Delete all old
.pemfiles in your home directory and retry.
Lab Tasks Practiced
-
Create folder structure:
mkdir companyA cd companyA mkdir finance HR management -
Create files inside directories:
cd HR touch assessment.csv "trial period.csv" cd ../finance touch salary.csv "profit and loss statement.csv" -
Create files without navigating into directory:
touch management/budget.csv management/headcount.csv -
View directory tree:
ls -laR # Long format, all hidden files, recursive -
Copy, move, rename, and delete:
cp -R finance HR/ # Copy folder into another mv assessment.csv employees/ # Move file mv wrongname.csv correctname.csv # Rename rm salary.csv # Delete file rm -R finance/ # Delete folder
11. Quick Reference Cheat Sheet
NAVIGATION
pwd → Show current directory
cd <dir> → Change directory
cd .. → Go up one level
cd ~ → Go to home directory
LISTING
ls → List files
ls -l → Long format
ls -a → Show hidden files
ls -lh → Human-readable sizes
FILE OPERATIONS
touch <file> → Create empty file
cat <file> → Show file contents
less <file> → Page through large file
head -n N <file> → Show first N lines
tail -n N <file> → Show last N lines
tail -f <file> → Monitor live changes
COPY / MOVE / DELETE
cp <src> <dst> → Copy file
cp -R <dir> <dst> → Copy directory
mv <src> <dst> → Move or rename
rm <file> → Delete file
rm -R <dir> → Delete directory
rmdir <dir> → Delete EMPTY directory
mkdir <dir> → Create directory
mkdir -p a/b/c → Create nested directories
PERMISSIONS
chmod 400 <file> → Owner read-only (SSH keys)
chmod 600 <file> → Owner read+write
chmod 755 <file> → Standard executable
chmod 777 <file> → Full access for all (avoid!)
SEARCH
find . -name "*.txt" → Find files by name
grep "term" file.txt → Search inside file
diff file1 file2 → Compare two files
LINKS
ln <src> <link> → Hard link
ln -s <src> <link> → Symbolic (soft) link
ls -i → Show inode numbers
MISC
hash → Recently used commands
Notes compiled from live lecture — April 13, 2026 AWS/Restart Program | Cohort 3: Project CloudIgnite