Welcome to Week 6! 🎉
What You'll Learn Today
- ✅ Edit files using GUI and Terminal
- ✅ Move and copy files efficiently
- ✅ Understand Linux users and groups
- ✅ Master file permissions for security
- ✅ Practice on Ubuntu and Kali Linux
Quick Setup Check
# Run these commands to check your setup
whoami
pwd
uname -a
ls ~
🖥️ GUI
Graphical User Interface
Point, click, drag & drop
Easy for beginners
⌨️ CLI
Command Line Interface
Type commands in Terminal
Fast & powerful
🐧 Linux
Open-source OS
Ubuntu & Kali Linux
Used by professionals
📝 Editing Files in Linux
Simple Explanation
Editing files is like writing in a notebook. Linux gives you two ways to do it:
- GUI Way: Use a text editor (like Notepad on Windows)
- Terminal Way: Use commands like
nanoorvim
Method 1: Using GUI (Ubuntu)
🎯 Exercise: Create Your First File
- Click "Show Applications" (bottom left)
- Search for "Text Editor"
- Type:
Hello, this is my first Linux file! - Click "Save As"
- Name it:
myfile.txt - Save to Documents folder
Method 2: Using Terminal (Ubuntu & Kali)
# Step 1: Go to Documents folder
cd ~/Documents
# Step 2: Create and open file with nano editor
nano myfile.txt
# Step 3: Type your text in nano
# "Hello from Terminal!"
# Step 4: Save and exit
# Press Ctrl + O (save)
# Press Enter (confirm)
# Press Ctrl + X (exit)
# Step 5: Read your file
cat myfile.txt
•
Ctrl + O → Save file•
Ctrl + X → Exit nano•
Ctrl + K → Cut line•
Ctrl + U → Paste line
Practice Exercise
✏️ Task: Create week6notes.txt
Create a file with your name and today's date using Terminal:
cd ~/Desktop
nano week6notes.txt
# Type this:
# Name: [Your Name]
# Date: November 17, 2025
# Topic: Linux File Management
cat week6notes.txt
🚚 Moving and Copying Files
What's the Difference?
| Action | What Happens | Like Windows |
|---|---|---|
| Move | File goes from A to B (original disappears) | Cut & Paste |
| Copy | File appears in B, stays in A (2 copies) | Copy & Paste |
Moving Files
# Check where you are
pwd
# Move file from Documents to Downloads
mv ~/Documents/myfile.txt ~/Downloads/
# Verify the move
ls ~/Downloads/
ls ~/Documents/
•
~ = Your home folder•
~/Documents = /home/yourname/Documents•
. = Current directory•
.. = Parent directory
Copying Files
# Copy file from Downloads to Documents with new name
cp ~/Downloads/myfile.txt ~/Documents/myfile_backup.txt
# Verify both files exist
ls ~/Downloads/
ls ~/Documents/
🎯 Challenge: Create, Move, and Backup
# Step 1: Create file on Desktop
cd ~/Desktop
echo "This is my test file" > testfile.txt
# Step 2: Move to Downloads
mv testfile.txt ~/Downloads/
# Step 3: Copy to Documents as backup
cp ~/Downloads/testfile.txt ~/Documents/testfile_backup.txt
# Step 4: Verify all locations
ls ~/Desktop/ # Should NOT have testfile.txt
ls ~/Downloads/ # Should have testfile.txt
ls ~/Documents/ # Should have testfile_backup.txt
👥 Users and Groups
Think of Linux Like a School
- Users = Students (each person has their own account)
- Groups = Classes (students can be in multiple classes)
- Permissions = Rules about who can access what
Key Concepts
| Term | What It Means | Example |
|---|---|---|
| UID | User ID (unique number) | User "john" = UID 1001 |
| GID | Group ID (unique number) | Group "students" = GID 2001 |
| Primary Group | Your default group | Created with your account |
| Secondary Group | Extra groups you join | Join "developers" for project |
Check Your User Info
# Who am I?
whoami
# Show my user ID and groups
id
# Show all my groups
groups
# Show my user account information
cat /etc/passwd | grep $(whoami)
Creating and Managing Groups
🎯 Exercise: Create a Project Team
# Step 1: Create a group called "projectteam"
sudo groupadd projectteam
# Step 2: Verify it was created
cat /etc/group | grep projectteam
# Step 3: Add yourself to the group
sudo usermod -aG projectteam $USER
# Step 4: Check your groups
groups $USER
sudo (admin privileges) to create groups and add users!
🔒 File Permissions
Understanding Permissions
Every file in Linux has three levels of access:
- Owner (you) - The person who created the file
- Group (your team) - People in the same group
- Others (everyone else) - All other users
For each level, there are three types of permissions:
- r = Read (can view the file)
- w = Write (can edit/delete the file)
- x = Execute (can run the file as a program)
Common Permission Patterns
| Permission | Notation | Use Case |
|---|---|---|
| 644 | rw-r--r-- | Regular files (documents) |
| 755 | rwxr-xr-x | Executable files (scripts) |
| 700 | rwx------ | Private files (only you) |
| 600 | rw------- | Secret files (passwords) |
| 777 | rwxrwxrwx | ⚠️ DANGEROUS - Never use! |
Viewing Permissions
# Create a test file
cd ~/Documents
echo "Test content" > permtest.txt
# View permissions
ls -l permtest.txt
# Example output:
-rw-rw-r-- 1 student student 13 Nov 17 10:30 permtest.txt
# │││││││││ │ │ │ │ └── filename
# │││││││││ │ │ │ └───── file size
# │││││││││ │ │ └───────────── group owner
# │││││││││ │ └─────────────────── user owner
# │││└└└└└└ └─────────────────────── number of links
# │││
# ││└─ Others: r-- (read only)
# │└── Group: rw- (read, write)
# └─── Owner: rw- (read, write)
Changing Permissions
Method 1: Using Numbers
# Give owner full access, group read/write, others read only
chmod 664 permtest.txt
# Check the change
ls -l permtest.txt
Method 2: Using Letters
# Add execute permission for owner
chmod u+x permtest.txt
# Remove write permission for group
chmod g-w permtest.txt
# Set others to read only
chmod o=r permtest.txt
# Check changes
ls -l permtest.txt
✅ Use 644 for regular files
✅ Use 755 for scripts
✅ Use 700 for private files
❌ NEVER use 777 (everyone can do everything - insecure!)
🎮 Complete Practice Scenario
Team Project Setup
Imagine you're working on a group project. Let's set everything up properly!
🎯 Final Challenge Exercise
Create a secure project environment following these requirements:
- Create directory ~/secure_project
- Create group 'developers'
- Create three files with different security levels
- Create executable script
- Set appropriate permissions for each
# Step 1: Create directory and navigate
mkdir ~/secure_project
cd ~/secure_project
# Step 2: Create group and add yourself
sudo groupadd developers
sudo usermod -aG developers $USER
# Step 3: Create files
echo "# Public Project Information" > public_readme.txt
echo "Team collaboration notes" > team_notes.txt
echo "My personal passwords" > my_secrets.txt
echo '#!/bin/bash
echo "Project initialized!"' > initialize.sh
# Step 4: Set permissions
chmod 644 public_readme.txt # Everyone can read
chmod 660 team_notes.txt # Group can read/write
chmod 600 my_secrets.txt # Only owner can access
chmod 700 initialize.sh # Only owner can execute
# Step 5: Set group ownership
sudo chgrp developers team_notes.txt
# Step 6: Verify everything
echo "=== Verification ==="
ls -l
# Step 7: Test the script
./initialize.sh
echo "=== Challenge Complete! ==="
✅ Learning Checklist
Check off each item as you complete it:
Quick Reference Card
File Operations
nano file.txt - Edit file
cat file.txt - View file
mv file dest/ - Move file
cp file copy - Copy file
User & Groups
whoami - Show username
id - Show user info
groups - Show groups
sudo groupadd - Create group
Permissions
ls -l - View permissions
chmod 755 - Change permissions
chown user - Change owner
chgrp group - Change group