Skip to content

Latest commit

 

History

History
380 lines (256 loc) · 9.18 KB

File metadata and controls

380 lines (256 loc) · 9.18 KB

TODO:

  • real life story
  • concrete full steps to reproduce

[Topic Name]

A friendly introduction explaining what this topic is and why you'd want to learn it. Think of this as answering "What problem does this solve for me?"

![Optional descriptive image or diagram]

What You Need to Know

Let's start with the basics. [Topic] is essentially [simple explanation in everyday terms].

Key Terms (The Essentials)

Before we dive in, here are the terms you'll encounter:

Term What It Actually Means
Term 1 Plain English explanation with context
Term 2 What this means in practice
Term 3 Why this matters to you

The Big Picture

Think of [topic] like [relatable analogy]. Just as [analogy continues], [topic] works by [simple explanation].

Here's what's happening behind the scenes:

When you use [topic], your system basically:

  1. Takes your input
  2. Processes it in a specific way
  3. Gives you the result you want

Getting Your Hands Dirty

Now let's actually use this stuff. Don't worry - we'll start simple and work our way up.

Your First Command

The most basic thing you can do is:

simple_command filename

What just happened?

This command told your system to [explain in simple terms]. You'll see something like:

Typical output you'd see

The output means [explanation of what the user is seeing].

Common Things You'll Want to Do

Task 1: [Everyday Task Name]

The situation: You need to [describe real scenario].

The solution:

command --helpful-option filename

Why this works:

  • --helpful-option tells the command to [explain benefit]
  • filename is obviously the file you want to work with

Pro tip: If you see an error like "permission denied," try adding sudo at the beginning.

Task 2: [Another Common Need]

When you'd use this: [Real-world scenario]

another_command input_file output_file

Made a mistake? No worries - you can quickly fix it:

# Oops, wrong output name
^output_file^correct_name

This reruns your command with the correction. Much faster than retyping everything!

Level Up: More Powerful Techniques

Once you're comfortable with the basics, here are some tricks that'll save you time:

Combining Commands Like a Pro

Instead of running commands one by one:

# The tedious way
first_command input.txt
second_command processed.txt
third_command final.txt

You can chain them together:

# The smart way
first_command input.txt | second_command | third_command > final.txt

What's happening here:

  • The | (pipe) passes output from one command to the next
  • > saves the final result to a file
  • Your system does all three steps automatically

Setting Things Up

Configuration Files (Don't Panic!)

Most of the time, the default settings work fine. But if you want to customize things, here's where to look:

System-wide settings: /etc/[topic]/config Your personal settings: ~/.config/[topic]/config

Quick example - changing a basic setting:

# Open your config file
nano ~/.config/[topic]/config

# Add this line to change [setting]
preferred_option=your_value

Save the file (Ctrl+X, then Y, then Enter if using nano), and you're done!

Making Life Easier with Aliases

Tired of typing long commands? Create shortcuts:

# Instead of typing this every time:
alias myshortcut='long_complicated_command --with --many --options'

# Now you can just type:
myshortcut

Making it permanent:

Add your aliases to ~/.bashrc so they survive reboots:

echo "alias myshortcut='long_complicated_command --with --many --options'" >> ~/.bashrc
source ~/.bashrc

When Things Go Wrong (And They Will)

Don't worry - everyone runs into problems. Here's how to fix the most common issues:

"Command not found"

What you see:

bash: mysterious_command: command not found

What this means: The command isn't installed or isn't in your PATH.

Quick fixes to try:

  1. Check if it's installed: which mysterious_command
  2. Install it: sudo apt install package-name (Ubuntu/Debian) or sudo yum install package-name (RedHat/CentOS)
  3. Check your PATH: echo $PATH

"Permission denied"

The situation: You're trying to access or modify something you don't own.

Quick fix: Add sudo to the beginning:

# This fails:
echo "new content" > /etc/important-file

# This works:
sudo echo "new content" > /etc/important-file

But wait! Sometimes even sudo won't work with redirects. In that case:

echo "new content" | sudo tee /etc/important-file

"File or directory not found"

Usually means: You're in the wrong directory or the file doesn't exist.

Debug it:

# Where am I?
pwd

# What's here?
ls -la

# Is the file really where I think it is?
find . -name "filename*"

Real-World Examples

Let's look at some actual scenarios where you'd use this.

Scenario: Daily Backup Task

The problem: You want to backup your important files every day without thinking about it.

The solution:

# Create a simple backup script
#!/bin/bash
tar -czf backup-$(date +%Y%m%d).tar.gz ~/Documents ~/Pictures

# Make it executable
chmod +x backup.sh

# Run it automatically every day at 2 AM
echo "0 2 * * * /path/to/backup.sh" | crontab -

What's happening:

  • tar creates a compressed archive
  • $(date +%Y%m%d) adds today's date to the filename
  • crontab schedules it to run automatically

Scenario: Finding That File You Lost

The problem: You know you have a file with "budget" in the name, but where is it?

The solution:

# Search everywhere for files with "budget" in the name
find / -name "*budget*" 2>/dev/null

# Too many results? Be more specific:
find ~/Documents -name "*budget*.xlsx" -mtime -30

Translation:

  • find / searches everywhere (starting from root)
  • 2>/dev/null hides permission error messages
  • -mtime -30 finds files modified in the last 30 days

Quick Reference

Commands You'll Use Daily

What You Want to Do Command Example
List files ls ls -la (detailed list)
Copy files cp cp source.txt backup.txt
Move/rename mv mv oldname.txt newname.txt
Delete files rm rm unwanted.txt
Create directory mkdir mkdir new_folder

Useful Shortcuts

Shortcut What It Does
Ctrl+C Stop whatever's running
Ctrl+L Clear the screen
Tab Auto-complete filenames
Previous command
!! Repeat last command

Practice Makes Perfect

Start Here (Beginner)

  1. Get comfortable with navigation:

    • Use ls to see what's in your current directory
    • Use cd to move around
    • Try pwd to see where you are
  2. Practice with files:

    • Create a test file: touch test.txt
    • Copy it: cp test.txt test_copy.txt
    • Delete the copy: rm test_copy.txt

Next Level (Intermediate)

  1. Combine commands:

    • List all .txt files: ls *.txt
    • Count them: ls *.txt | wc -l
    • Find the biggest one: ls -la *.txt | sort -k5 -n | tail -1
  2. Create a useful script:

    • Make a script that shows disk usage and current time
    • Make it executable and run it

Advanced Challenges

  1. Automate something annoying:

    • Set up automatic file organization
    • Create a custom backup solution
    • Build a monitoring script for system resources
  2. Troubleshooting practice:

    • Intentionally break something (in a safe environment)
    • Practice diagnosing and fixing the issue
    • Document what you learned

Solutions and Hints

Don't peek until you've tried!

Click for hints and solutions

Challenge 1 hints:

  • Remember: ls shows files, cd dirname enters a directory
  • If you get lost, cd ~ takes you home

Challenge 3 solution:

# Count .txt files
ls *.txt | wc -l

# Find biggest file (size is in column 5)
ls -la *.txt | sort -k5 -n | tail -1

Challenge 4 example script:

#!/bin/bash
echo "=== System Status ==="
echo "Current time: $(date)"
echo "Disk usage:"
df -h
echo "Memory usage:"
free -h

What's Next?

Once you're comfortable with [current topic], you might want to explore:

Helpful Resources

When You Need Help

  • Quick help: man command_name (built-in manual)
  • Friendly explanations: command_name --help
  • Online communities: Stack Overflow, Reddit's r/linux4noobs

Keep Learning


What's next? Try Next Topic to build on what you've learned here.

Need to review? Go back to Previous Topic if something wasn't clear.