-- Task 6: Navigating the File System
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Understand how to navigate the Linux file system hierarchy using the command line.

---

## 📖 Core Concept

The Linux file system is a tree-like structure starting from the root directory (`/`). Unlike Windows, there are no drive letters (C:, D:). Everything is a file or a directory under root.

### Key Directories
- `/`: The Root directory.
- `/home`: Contains user personal directories (like `My Documents`).
- `/bin`: Essential user binaries (programs like ls, cp).
- `/etc`: Configuration files.
- `/var`: Variable files (logs, web files).

---

## 💻 Common Commands

### 1. `pwd` (Print Working Directory)
Shows you exactly where you are in the system.

```bash
baris@linux:~$ pwd
/home/baris
```

### 2. `ls` (List)
Lists files in the current directory.

```bash
ls          # Simple list
ls -l       # List with details (permissions, size)
ls -a       # List all (including hidden files starting with .)
ls -la      # Combine flags: detailed + hidden
```

### 3. `cd` (Change Directory)
Moves you to a different folder.

```bash
cd /var/log    # Go to absolute path
cd ..          # Go up one level
cd ~           # Go to your home directory
cd -           # Go to previous directory
```

---

## ⚡ Pro Tip
Use the **Tab** key to auto-complete file and directory names. It saves time and prevents typos!
'
WHERE task_id = 6;

-- Task 7: File Manipulation
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Learn how to create, copy, move, and delete files and directories.

---

## 📖 Core Concept

In Linux, you perform file operations using specific commands rather than drag-and-drop.

---

## 💻 Common Commands

### 1. Creating Files & Directories
- `touch`: Creates an empty file.
- `mkdir`: Creates a new directory.

```bash
touch notes.txt
mkdir project_files
```

### 2. Copying (`cp`)
Duplicate files or directories.

```bash
cp source.txt destination.txt   # Copy a file
cp -r folder1 folder2           # Copy a directory (recursive)
```

### 3. Moving & Renaming (`mv`)
Move a file to a new location OR rename it.

```bash
mv file.txt /tmp/           # Move to /tmp
mv oldname.txt newname.txt  # Rename file
```

### 4. Removing (`rm`)
Delete files permanently. **Warning: There is no Recycle Bin!**

```bash
rm file.txt       # Delete a file
rm -r foldername  # Delete a folder (recursive)
rm -rf /tmp/junk  # Force delete (careful!)
```

---

## ⚡ Pro Tip
Always double-check before running `rm -rf`. It allows you to delete system files if run as root, which can destroy the OS.
'
WHERE task_id = 7;

-- Task 8: Understanding Permissions
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Understand Linux file permissions and how to modify them to secure your system.

---

## 📖 Core Concept

Every file in Linux has permissions for three categories of users:
1. **User (u)**: The owner of the file.
2. **Group (g)**: Users in the file''s group.
3. **Others (o)**: Everyone else.

Permissions are:
- **Read (r)**: View contents.
- **Write (w)**: Modify contents.
- **Execute (x)**: Run as a program.

### Viewing Permissions (`ls -l`)
```bash
-rwxr-xr-- 1 baris developers 4096 Dec 25 10:00 script.sh
```
- `rwx`: Owner can Read, Write, Execute.
- `r-x`: Group can Read, Execute.
- `r--`: Others can only Read.

---

## 💻 Common Commands

### 1. Changing Permissions (`chmod`)
You can use numbers (Octal) or symbols.

**Numeric Mode:**
- 4 = Read
- 2 = Write
- 1 = Execute

```bash
chmod 777 file.sh   # Everyone can do everything (Insecure!)
chmod 755 file.sh   # Owner: rwx, Group/Other: r-x
chmod 600 file.txt  # Owner: rw, Group/Other: none (Secure)
```

**Symbolic Mode:**
```bash
chmod +x script.sh  # Add execute permission
chmod u+w file.txt  # Add write permission for User
```

### 2. Changing Owner (`chown`)
```bash
chown user:group file.txt
chown root:root /etc/secret.conf
```
'
WHERE task_id = 8;

-- Task 9: Searching and Finding Files
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Master the tools to locate files hidden deep within the file system.

---

## 📖 Core Concept

Finding specific configuration files or logs is a daily task in cybersecurity. Linux provides powerful tools to search by name, size, type, or modified date.

---

## 💻 Common Commands

### 1. `find`
The most powerful search tool. Searches the disk in real-time.

```bash
# Find by name
find / -name "password.txt"

# Find by type (f=file, d=directory)
find /var -type d -name "logs"

# Find files modified in the last 24 hours
find /home -mtime -1

# Find files larger than 100MB
find / -size +100M
```

### 2. `locate`
Uses a pre-built database index. It''s faster than `find` but might not show recently created files.

```bash
locate python
```
*Note: Run `updatedb` to update the index.*

### 3. `which`
Finds the location of a command/executable.

```bash
which python3
# Output: /usr/bin/python3
```
'
WHERE task_id = 9;

-- Task 10: Text Manipulation with grep
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Learn to view file contents and filter text to find specific information like errors or indicators of compromise.

---

## 📖 Core Concept

In security, you often need to sift through massive log files. Text manipulation tools verify the contents of files quickly.

---

## 💻 Common Commands

### 1. Viewing Files
- `cat`: Output the entire file.
- `head`: View the first 10 lines.
- `tail`: View the last 10 lines.

```bash
cat /etc/passwd
head -n 5 /var/log/syslog
tail -f /var/log/auth.log   # Follow new lines in real-time
```

### 2. `grep` (Global Regular Expression Print)
Search for specific text within files.

```bash
# Search for "error" in syslog
grep "error" /var/log/syslog

# Search recursively in a directory
grep -r "192.168.1.5" /var/log/

# Case insensitive search
grep -i "failed" auth.log
```

---

## ⚡ Pro Tip
Combine commands using the pipe `|`.
```bash
cat large_log.txt | grep "Critical" | head -n 5
```
'
WHERE task_id = 10;

-- Task 11: Process Management
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Understand how to monitor running applications and terminate unresponsive or malicious processes.

---

## 📖 Core Concept

Every program running on Linux is a **process** identified by a Process ID (**PID**). Malware often tries to hide as a legitimate process.

---

## 💻 Common Commands

### 1. Listing Processes
- `ps`: Snapshot of current processes.
- `ps aux`: Detailed list of all processes for all users.

```bash
ps aux | grep apache
```

### 2. Real-time Monitoring
- `top`: Classic task manager. Shows CPU/RAM usage.
- `htop`: More colorful, interactive version (if installed).

### 3. Killing Processes
Stop a process using its PID.

```bash
# Terminate gracefully (SIGTERM)
kill 1234

# Force kill (SIGKILL) - use if frozen
kill -9 1234
```

---

## ⚡ Security Context
If you see a process with high CPU usage or a strange name (like `netcat` or `cryptominer`) running under a system user, investigate it immediately!
'
WHERE task_id = 11;

-- Task 12: Package Management
UPDATE lesson_content 
SET content = '## 🎯 Learning Objective

Learn how to install, update, and remove software packages.

---

## 📖 Core Concept

Linux distributions (like Ubuntu/Debian) use repositories to manage software. You don''t typically download `.exe` files from websites. Instead, you use a package manager like `apt`.

---

## 💻 Common Commands

### 1. Updating Repositories
Always do this before installing new software to get the latest versions.

```bash
sudo apt update
```

### 2. Installing Software
```bash
sudo apt install nmap
```

### 3. Removing Software
```bash
sudo apt remove nmap
```

### 4. Upgrading System
Updates all installed packages to their newest versions.
```bash
sudo apt upgrade
```
'
WHERE task_id = 12;
