The Ultimate Linux Command Line Review – Week 1

The CyberSec Guru

Linux 101 - The Ultimate Linux Command Line Review - Week 1

If you like this post, then please share it:

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Why your support matters: Zero paywalls: Keep the content 100% free for learners worldwide, Writeup Access: Get complete writeup access within 12 hours of machine drop along with scripts and commands.

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

You’ve survived your first week on the Linux command line.

Take a moment and appreciate that. Just seven days ago, you were staring at a blinking cursor in a black box, a complete alien in a new world. Now, you have a vocabulary. You can move, you can see, you can create, and you can destroy. You’ve unlocked the first level of a superpower.

But with all new powers, there’s a catch: command-line amnesia.

It’s the feeling you get when you sit back down at the terminal and think, “Wait… was it rm or rmdir? How do I save in that nano thing again? What did all those columns in ls -l mean?”

Learning is easy. Retention is hard. The bridge between knowing a command and understanding a command is practice. Today is not about learning anything new. It’s about forging the new pathways in your brain into permanent, hardened steel. Today, we’re going to the gym.

This post is your ultimate Week 1 review. We are going to do an exhaustive, 10,000-word deep dive into every single command we’ve touched on, exploring all their most critical options, use cases, and gotchas. This will be your “all-in-one” reference guide.

Then, to cap it all off, we’ll run the Week 1 Gauntlet Challenge—a practical, hands-on exercise where you’ll use all these commands together to build and tear down a project, just like you would in a real-world scenario.

This is the most important day of the week. Let’s cement your knowledge.

The Ultimate Week 1 Command Review

We’re going to review our 11 foundational commands. We’re not just listing them; we’re breaking them down completely. By the end of this section, you’ll be an expert on each one.

ls – Your Eyes in the Terminal

The ls command (for “list”) is your single most-used command. It is your sense of sight. Without it, you are blind, fumbling in the dark.

Basic Syntax: ls [OPTIONS] [FILE/DIRECTORY]...

  • If you type ls with no arguments, it lists the contents of your current directory.
  • If you provide a directory name, it lists the contents of that directory.
  • If you provide a file name, it just… lists that file name.

Core Use Cases:

  • ls: “What’s in here?”
  • ls /etc: “What’s in the /etc directory?”
  • ls /etc /home: “What’s in /etc and what’s in /home?”

ls‘s Exhaustive Command-Line Options

This is where ls goes from a simple tool to a powerful diagnostic instrument.

  • -l (Long Listing): This is the most important option. ls -l changes the output from just a list of names to a detailed, multi-column report.
Ls -l Command Explanation
Ls -l Command Explanation
  • Let’s break down that output, because it’s the key to understanding Linux: drwxr-xr-x 2 user group 4096 Oct 31 18:00 Project
  • -a (All): By default, lshides files and directories that start with a . (dot). These are considered “hidden” files, often used for configuration (e.g., .bashrc, .nanorc). ls -a reveals everything. You will always see two special entries:
    • . (dot): A link that points to the current directory.
    • .. (dot-dot): A link that points to the parent directory (one level up).
  • -A (Almost All): This is often more useful than -a. It shows all hidden files except for the . and .. entries, giving you a cleaner list of just the “real” hidden files.
  • -h (Human-Readable): Remember that 4096 size from -l? That’s not very helpful. The -h flag must be used with -l. It converts sizes into human-readable format. ls -lh Now, 4096 becomes 4.0K. 1234567 becomes 1.2M. 9876543210 becomes 9.3G. It’s an absolute must. Pro-Tip: Your most common ls command will be ls -lAh (long, almost-all, human-readable).
  • -R (Recursive): This command “recursively” lists the contents of all subdirectories. If you have a Project folder with src and docs inside, ls -R will show you:./Project: README.md docs src ./Project/docs: INSTRUCTIONS.md ./Project/src: main.py This is amazing for getting a quick map of a whole project.
  • -t (Time Sort): Sorts the output by modification time, with the newest files first. Incredibly useful for finding the log file that was just written to.
  • -r (Reverse): Reverses the sorting order. When combined with -t (ls -ltr), it sorts by time with the oldest files first.

pwd – Your “You Are Here” Map

pwd (for “print working directory”) is the simplest command with the most profound job. It answers the question, “Where am I?”

It has no real options. You just type it.

Command: pwd

Output: /home/user/Project/src

It prints the absolute path (the full path from the root /) of your current location. When you get lost in the filesystem, pwd is your anchor.

cd – The Teleporter

cd (for “change directory”) is your “locomotion.” It’s how you move.

Basic Syntax: cd [DIRECTORY]

Core Use Cases (The “Big 5”):

  1. cd /path/to/directory (Absolute Path): This is like giving a full street address. It works from anywhere. cd /var/log/nginx
  2. cd relative/path (Relative Path): This is like giving directions: “go into the docs folder from here.” If you are in /home/user/Project (which contains docs), you can just type: cd docs And you will be in /home/user/Project/docs.
  3. cd .. (Go Up One Level): This uses that special .. directory (the “parent”) to move up one level. If you are in /home/user/Project/docs, cd .. takes you to /home/user/Project. You can chain them: cd ../.. (go up two levels).
  4. cd or cd ~ (Go Home): Typing cd with no arguments at all is a shortcut that instantly takes you back to your home directory (e.g., /home/user). cd ~ does the same thing (~ is a shortcut for “my home directory”).
  5. cd - (Go Back): This is the “back button” for your terminal. It takes you to the previous directory you were in. If you were in /home/user and cd‘d to /var/log, typing cd - would take you right back to /home/user.
Directory Structure in Linux
Directory Structure in Linux

mkdir – The Architect

mkdir (for “make directory”) is how you build your file system’s structure.

Basic Syntax: mkdir [OPTIONS] [DIRECTORY_NAME]...

Core Use Cases:

  • mkdir new_folder: Creates a single directory named new_folder.
  • mkdir docs src images: You can create multiple directories at the same time.

The One Option You Must Know:

  • -p (Parents): This is the single most useful option. What if you want to create /home/user/Project/src/utils? If the Project and src directories don’t exist, mkdir will fail. mkdir -p Project/src/utils The -p flag tells it: “Create any parent directories that you need along the way.” It will create Project, then src inside it, then utils inside that. It makes complex directory creation a one-line command. It also won’t error if the directory already exists.

touch – The Creator (and Time-Traveler)

touch is a simple command with a surprisingly deep function.

Basic Syntax: touch [OPTIONS] [FILE]...

Core Use Cases:

  1. Creating Empty Files: This is what you’ll use it for 99% of the time. touch new_file.txt If new_file.txt doesn’t exist, it is created. It’s an empty, 0-byte file. touch README.md main.py config.ini Like mkdir, you can create multiple files at once.
  2. Updating Timestamps: This is touch‘s actual original purpose. If new_file.txt already exists, running touch new_file.txt will update its “last modified” timestamp to the current time. This is useful for build scripts and other automation that rely on file times.

In Linux, files have three timestamps:

  • mtime: Modification Time (content changed). This is what ls -l shows.
  • atime: Access Time (file was read).
  • ctime: Change Time (metadata changed, like permissions).

By default, touch updates all three!

cp – The Photocopier

cp (for “copy”) is how you duplicate files and directories.

Basic Syntax: There are two “forms” of this command:

  1. cp [OPTIONS] SOURCE_FILE DESTINATION_FILE
  2. cp [OPTIONS] SOURCE_FILE... DESTINATION_DIRECTORY/

Core Use Cases:

  • cp main.py main.py.bak (Form 1: File to File): This copies main.py and creates a new file named main.py.bak in the same directory. This is a great way to make a quick backup before you edit something.
  • cp main.py ../ (Form 2: File to Directory): This copies main.py into the parent directory ( .. ). The copy will also be named main.py.
  • cp file1.txt file2.txt /home/user/backup/ (Form 2: Multiple Files): This copies both file1.txt and file2.txt into the /home/user/backup directory.

cp‘s Exhaustive Command-Line Options

  • -r (Recursive): This is the most critical cp flag. By default, cp only copies files. If you try to copy a directory, it will fail. cp Project/ /home/user/backup/ The -r (recursive) flag tells cp: “Copy this directory, and all files and subdirectories inside it.” This is how you copy an entire project.
  • -i (Interactive): “Ask me before you overwrite anything.” If you try to copy file.txt to a directory that already has a file.txt, cp -i will stop and ask: cp: overwrite 'file.txt'? You must press y or n. This is a lifesaver.
  • -v (Verbose): “Show me what you’re doing.” By default, cp is silent. cp -v will print a line for every single file it copies. 'file1.txt' -> '/backup/file1.txt' This is great for peace of mind when copying large directories.
  • -a (Archive): This is a “super-copy” flag. cp -a is the same as cp -rdP (and more). It means “recursive” (-r), “preserve permissions, ownership, and timestamps” (-p… we didn’t cover this, but it’s vital for backups), and “don’t follow symbolic links” (-d). Rule of Thumb: When you are making a true backup of a project, use cp -a (or cp -r).

mv – The Mover (and Renamer)

mv (for “move”) is the sister command to cp. But where cp copies, mv moves (the original is gone). It’s also, confusingly, how you rename files.

Basic Syntax: The syntax is identical to cp.

  1. mv [OPTIONS] SOURCE_FILE DESTINATION_FILE
  2. mv [OPTIONS] SOURCE_FILE... DESTINATION_DIRECTORY/

Core Use Cases:

  • mv old_name.txt new_name.txt (Form 1: Renaming): This is the only way to rename a file on the command line. You “move” it from old_name.txt to new_name.txt in the same directory. The original old_name.txt is gone.
Renaming Files in Linux
Renaming Files in Linux
  • mv main.py src/ (Form 2: Moving): This moves main.py from the current directory into the src/ directory. main.py will no longer exist in the current directory.
  • mv file1.txt file2.txt /home/user/temp/ (Form 2: Moving Multiple): Moves both files into the /home/user/temp/ directory.

mv‘s Exhaustive Command-Line Options

The options are very similar to cp.

  • -i (Interactive): “Ask me before you overwrite.” Just like with cp, this is a lifesaver. If you try to move file.txt into a directory that already has a file.txt, mv -i will ask you before overwriting.
  • -v (Verbose): “Show me what you’re doing.” mv -v will print what it’s moving and renaming. 'old_name.txt' -> 'new_name.txt'
  • -n (No Clobber): “Never overwrite.” This is even safer than -i. It just… won’t. If a file exists, it will silently not move the new file.

rm – The Destroyer

rm (for “remove”) is the most dangerous and powerful command you’ve learned. It deletes files. It does not have a “Trash Bin.” There is no “Undo.” When you rm a file, it is gone forever.

Basic Syntax: rm [OPTIONS] FILE...

Core Use Cases:

  • rm file.txt: Deletes file.txt. If the file is write-protected, it may ask you to confirm.
  • rm file1.txt file2.txt: Deletes both files.
  • rm *.txt (Globbing): This is a shell feature, not an rm feature, but it’s critical. The * (asterisk) is a “wildcard” for “anything.” rm *.txt means “Remove all files that end with .txt.” rm log_* means “Remove all files that start with log_.”

rm‘s Exhaustive (and Terrifying) Command-Line Options

  • -i (Interactive): “Ask me about every single file.” This is slow, but it’s safe. It will ask rm: remove regular empty file 'file.txt'? for every file.
  • -r (Recursive): This is the most dangerous flag in all of Linux. By default, rm will not delete directories. rm -r tells it to “recursively” delete. It will go into a directory, delete everything inside it, then delete the directory itself. This is how you delete an entire project.
  • -f (Force): “Force” the deletion. Do not ask, ever. Ignore write-protection. Ignore non-existent files. Just… delete.

The “Foot Gun”: rm -rf When you combine -r (recursive) and -f (force), you get rm -rf. This command means:

“Forcefully delete, without question, this directory and everything in it and all its subdirectories.”

rm -rf Project/ will wipe out your entire project.

THE COMMAND THAT CAN DESTROY YOUR SYSTEM: rm -rf / NEVER. EVER. RUN. THIS. This tells the system: “Start at the root directory (/) and forcefully delete everything recursively.” You are telling your computer to eat itself. Modern systems have safeguards, but on many, this will begin to irreversibly delete your entire operating system.

Rule of Thumb:

  1. Pause and think before you press Enter on any rm command.
  2. Use rm -i if you’re ever unsure.
  3. Double, triple, quadruple-check any rm command that uses -r or a wildcard *.

cat – The Concatenator (Review)

cat (for “concatenate”) is your tool for short file viewing and for combining files.

  • View Short File:cat README.md
    • Pitfall: Never use this on a large file. It will dump 10,000 lines to your screen, and you’ll have to Ctrl+C to stop it.
  • View Multiple: cat file1.txt file2.txt (Dumps them one after another).
  • Combine Files (Its Real Job): cat header.txt body.txt footer.txt > final_page.html The > (redirection) operator takes the output of cat and redirects it into a new file. Warning: > overwrites the file if it exists.
  • Append to File: cat new_log_entry.txt >> system.log The >> (append) operator adds the output to the end of the file. This is much safer.
  • Create File: cat > new_file.txt Lets you type directly into the terminal. Press Ctrl+D to save and exit. Great for quick notes.

cat‘s Debugging Options:

  • -n (Number): Numbers all output lines.
  • -b (Number Non-Blank): Numbers only lines with content.
  • -E (Show Ends): Puts a $ at the end of every line. Instantly reveals “trailing whitespace” (spaces at the end of a line), a common bug.
  • -T (Show Tabs): Shows Tab characters as ^I.
  • -A (Show All): The ultimate debug flag. Turns on -E and -T and shows all other invisible characters.

less – The Pager (Review)

less is the tool you should use 99% of the time you want to view a file. It’s a “pager” that lets you open a file of any size instantly and navigate it.

The Interface:

  • You are “in” the less app.
  • q: QUIT. This is the most important key.
  • Arrow Keys / j & k: Scroll line-by-line.
  • Spacebar / Page Down / f: Scroll page-by-page.
  • Page Up / b: Scroll backward a page.
  • g: Go to the very beginning of the file.
  • G: Go to the very end of the file.

The Killer Feature: Searching

  • / (Forward Search):
    1. Press /.
    2. Type a term (e.g., ERROR).
    3. Press Enter.
    4. less jumps to the next match.
  • ? (Backward Search): Same, but searches up from your position.
  • n (Next Match): Jumps to the next match.
  • N (Previous Match): Jumps to the previous match.

less‘s “God Mode” Options:

  • -N (Line Numbers): Adds a line number gutter. Essential.
  • -S (No Wrap): This is the other essential flag. For long log files, it stops lines from wrapping, letting you scroll horizontally with the left/right arrows.
  • -i (Ignore Case): Makes your search case-insensitive.
  • -R (Raw Colors): Renders color codes. Try ls -la --color=always | less -R.

The Pro-Tip:

  • less +F /var/log/syslog: The +F command opens less in “Follow” mode. It’s the same as tail -f, letting you watch a log file in real-time. The best part? You can press Ctrl+C to stop following, and you’re right back in less, free to scroll up and search!

nano – The Friendly Editor (Review)

nano is your simple, beginner-friendly terminal text editor.

  • nano file.txt: Opens file.txt for editing.

The Interface:

  • It’s “modeless.” You just type.
  • The commands are at the bottom. ^ means Ctrl. M- means Alt.
Nano Editor
Nano Editor

The “Big Four” Commands:

  1. ^X (Exit):
    • If you’ve changed the file, it will ask: Save modified buffer?
    • Press Y (Yes), then Enter to confirm the filename.
    • Press N (No) to discard changes and exit.
  2. ^O (WriteOut / Save):
    • Saves the file without exiting.
    • Just press ^O and then Enter to confirm the filename.
  3. ^W (Where Is / Search):
    • Prompts you for a search term. Press Enter.
    • Press Alt+W (M-W) to find the next match.
  4. ^G (Get Help):
    • Opens the built-in nano help manual. Press ^X to exit help.

Cut, Copy, Paste:

  • ^K (Cut): Cuts the entire line your cursor is on.
  • ^U (Uncut): Pastes the text from the “cut buffer”.
  • To select text: Alt+A (Set Mark), use arrow keys to highlight, then ^K (Cut) or Alt+6 (Copy). Then ^U to paste.

Permanent Customization (.nanorc): Create nano ~/.nanorc and add these lines to make nano 1000x better:

set linenumbers
set autoindent
set mouse
set nowrap
set backup
include "/usr/share/nano/*.nanorc"

This gives you line numbers, auto-indent, mouse support, no line wrapping, automatic backups, and (most importantly) syntax highlighting for all your code files.

The Week 1 Gauntlet Challenge

You’ve reviewed the theory. Now, the practical.

Your Mission: You are a developer starting a new software project. Your task is to create the entire project structure, add some files, organize them, and then clean up after yourself, using only the 11 commands we just reviewed.

Open your terminal. cd to your home directory (cd ~). We’re starting from a clean slate.

Step 1: Build Your Workshop

First, we need the main folder and sub-folders.

Command: mkdir -p Project/docs Project/src What’s Happening: We are using mkdir‘s magic -p (parents) flag. We’re telling it to:

  1. Create a directory named Project.
  2. Inside Project, create a directory named docs.
  3. Inside Project (at the same level as docs), create src. All in one line!

Step 2: Enter Your Workshop and Verify

Command: cd Project What’s Happening: We’re moving into our new project folder.

Command: pwd Output: /home/user/Project (or similar) What’s Happening: We’re confirming our location.

Command: ls -l Output:

total 8
drwxr-xr-x 2 user group 4096 Oct 31 18:05 docs
drwxr-xr-x 2 user group 4096 Oct 31 18:05 src

What’s Happening: We’re using ls -l to list the contents. We can see our two new, empty directories.

Directory Manipulation Linux Commands
Directory Manipulation Linux Commands

Step 3: Create Your Project Files

Every project needs a README and a main source file.

Command: touch README.md What’s Happening: We’re using touch to create an empty file in our current directory (/home/user/Project). This will be our main project description.

Command: touch src/main.py What’s Happening: We’re creating our main Python file, but we’re not in the src directory. We’re placing it inside src by specifying the relative path src/main.py.

Step 4: Add Content

An empty file is no good. Let’s edit the README.

Command: nano README.md What’s Happening:

  1. nano opens your empty README.md file.
  2. Type the following text: # My First Linux Project
  3. Now, let’s save and exit.
  4. Press Ctrl+O (WriteOut). It will ask File Name to Write: README.md. Press Enter to confirm.
  5. Press Ctrl+X (Exit). You are now back at your terminal.

Command: cat README.md Output: # My First Linux Project What’s Happening: We’re using cat (on a short file!) to instantly verify that our changes were saved.

Step 5: Organize Your Files

We need instructions for our project, and they should go in the docs folder. We could create a new file, but our README is a good starting point.

Command: cp README.md docs/ What’s Happening: We’re using cp (Form 2) to copy README.md into the docs/ directory.

Command: ls -R Output:

.:
README.md
docs
src

./docs:
README.md

./src:
main.py

What’s Happening: We’re using ls -R (recursive) to see our whole project. Notice we now have two README.md files!

Now, that file in docs should be called INSTRUCTIONS.md.

Command: mv docs/README.md docs/INSTRUCTIONS.md What’s Happening: We’re using mv (Form 1) to rename the file. We’re telling it: “The file at docs/README.md should now be called docs/INSTRUCTIONS.md.”

Step 6: Final Verification

Let’s check our work.

Command: ls -l Output:

total 12
-rw-r--r-- 1 user group   25 Oct 31 18:10 README.md
drwxr-xr-x 2 user group 4096 Oct 31 18:12 docs
drwxr-xr-x 2 user group 4096 Oct 31 18:06 src

What’s Happening: Our main README.md is still here.

Command: ls -l docs/ Output:

total 4
-rw-r--r-- 1 user group 25 Oct 31 18:12 INSTRUCTIONS.md

What’s Happening: Our file in docs/ has been successfully renamed!

Command: less docs/INSTRUCTIONS.md What’s Happening: We’re using less (the correct tool for viewing) to check the contents. You’ll see # My First Linux Project. Press q to quit.

Directory Navigation Linux Commands
Directory Navigation Linux Commands

Step 7: Clean Up (The Grand Finale)

Our work is done. Time to demolish the workshop.

Command: cd .. What’s Happening: We’re currently inside /home/user/Project. You cannot delete a directory you are currently standing in. This command moves us up one level to /home/user.

Command: rm -rf Project/ What’s Happening:

  • rm: We are removing…
  • -r: …recursively (the Project directory and everything inside it: docs, src, README.md, INSTRUCTIONS.md, main.py).
  • -f: …forcefully (don’t ask us any questions, just do it). You press Enter. The terminal is silent.

Command: ls -l What’s Happening: You check the contents of your home directory. …Project/ is gone. Completely.

You’ve Done It

If you’ve followed along, you’ve just used all 11 foundational commands in a single, practical workflow. You have built, modified, navigated, and destroyed a project structure from scratch.

This is it. These commands, which seemed so alien a week ago, are now your tools. You can see (ls, cat, less), you can move (cd, pwd), you can build (mkdir, touch), and you can change (cp, mv, nano, rm).

You’ve completed Week 1. You are no longer just a “user” of a computer. You are a “commander.”

The amnesia will fade. The muscle memory will build. This week was the foundation. Next week, we build the house. We’ll take our project and learn how to manage users and permissions—how to control who can read, write, and execute all the new files you now know how to create.

What was the trickiest part of the challenge for you? Did you try rm -i Project/ instead of -rf? What’s your favorite new command? Leave a comment below and share your experience!

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Your contribution powers free tutorials, hands-on labs, and security resources.

Why your support matters:
  • Writeup Access: Get complete writeup access within 24 hours
  • Zero paywalls: Keep the content 100% free for learners worldwide

Perks for one-time supporters:
☕️ $5: Shoutout in Buy Me a Coffee
🛡️ $8: Fast-track Access to Live Webinars
💻 $10: Vote on future tutorial topics + exclusive AMA access

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

If you like this post, then please share it:

Linux 101

Discover more from The CyberSec Guru

Subscribe to get the latest posts sent to your email!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from The CyberSec Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading