Wong Edan's

Mastering the CLI: Wong Edan’s Chaos-Ready Command Line Survival Guide

February 23, 2026 • By Azzar Budiyanto

Why Your Fingers Should Fear the Keyboard (And How to Fix That)

Alright, you magnificent gremlin, let’s talk about the Linux command line. You’ve probably stared at that blinking cursor like it’s judging your life choices. Maybe you’ve even typed sudo rm -rf / just to see if the Internet was serious (spoiler: IT WAS). I’ve been there – crying into my Arch Linux installation ISO because pacman wouldn’t cooperate. But here’s the secret no one tells you: the CLI isn’t just some ancient ritual for beard-stroking sysadmins. It’s your digital lightsaber. And today? I’m handing you the hilt while screaming “DON’T CUT YOURSELF THIS TIME”.

We’re diving DEEP into the messy, glorious trenches of command line mastery. Forget those “Learn CLI in 5 Minutes” clickbait articles – this is Wong Edan’s 10,000-foot dive with a parachute made of duct tape and sarcasm. By the time we’re done, you’ll not only know what ~ really means (hint: it’s not a sad face), but you’ll resurrect dead processes like a tech necromancer.

The Tilda: It’s Not Just a Squiggly Line, You Heathen

First stop: that mysterious ~ character. Newbies see it and think “huh, must be a typo”. WRONG. This little squiggle is your VIP pass to home directory nirvana. When you type cd ~, you’re teleporting directly to /home/yourusername faster than a sysadmin fleeing a production outage.

“But Wong Edan,” I hear you whine, “what if I’m already in my home directory?”

Then you’re lazy! Use cd ~otheruser to invade their digital homestead (permission allowing, you script kiddie). Or better yet: cp important_file.txt ~backup/ to dump files into /home/backup/ without remembering the full path. This is how real hackers operate – by being pathetically lazy.

Let’s break it down like a poorly written BASH script:

  • ~ = Your home directory (e.g., /home/wongedan)
  • ~/Documents = Short for /home/wongedan/Documents
  • cd ~ = “Take me home, I’ve had enough of this /var/log dumpster fire”
  • echo ~ = See the actual path behind the magic (spoiler: it’s just an environment variable, $HOME)

Pro-tip: In BASH, ~+ means current directory (like .), and ~- is the previous directory. It’s like command line time travel, but with fewer DeLoreans and more typos.

Command History: Because Your Memory Sucks (Let’s Fix That)

Ever typed sudo apt-get install something-really-long then realized you forgot sudo? Instead of rage-quitting and Googling “how to die gracefully”, use history like a civilized human. The CLI remembers EVERYTHING – your genius moments and your rm -rf / near-misses.

The Ctrl+R Black Magic

Hit Ctrl+R and start typing. Your terminal searches backwards through history. Found the command? Hit Enter to run it, or Right Arrow to edit. Misspelled htop as hstop 17 times? Now you can hunt down those failures like a forensic analyst.

Example flow:

(reverse-i-search)`ap': sudo apt-get install neofetch cool-tool

Type ap, it finds your last apt command. Now edit it to sudo apt-get install cool-tool before executing. Game. Changer.

The Bang (!) Operators: History’s Cheat Codes

Move over, sudo !! – there’s a whole universe of ! sorcery:

  • !n = Run command number n from history (use history to see numbers)
  • !-2 = Run the command from 2 entries ago (like time travel for commands)
  • !su = Run last command starting with “su” (e.g., sudo nano /etc/fstab)
  • !$ = Get the last argument of previous command (e.g., after cd /very/long/path, type ls !$ to list it)
  • sudo !! = Rerun last command with sudo (the “d’oh!” fix for permission errors)

Real-world scenario: You try tar -xvf archive.tar.gz but get “Permission denied”. Instead of retyping: sudo !! becomes sudo tar -xvf archive.tar.gz. You just saved 11 keystrokes – that’s practically a productivity seminar.

Tab Completion: Your Terminal’s Psychic Powers

Here’s where most tutorials fail you. They say “press Tab to autocomplete” like it’s some mystical art. WRONG. This is your terminal screaming “LET ME DO THE WORK, YOU LAZY MONKEY”. Tab completion isn’t just for file names – it digs through commands, options, even SSH hosts.

File Path Wizardry

Type cd /u then smash Tab. It might expand to /usr/. Now type l and Tab again → /usr/local/. This is how you navigate without remembering that stupid /opt/application/dependencies/lib64 path.

But here’s the Wong Edan special: if multiple matches exist (e.g., file1.txt and file2.txt), press Tab twice. The terminal shows options like a menu. No more guessing!

Command and Flag Autocomplete

Type git c and Tab → expands to git commit. Now add a space and type --m then Tab → becomes --message. Most modern CLIs (like docker, aws, kubectl) support this out-of-the-box. For older tools, add this to ~/.bashrc:

# Enable autocomplete for ALL commands (not just built-ins)
if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi

Now when you type docker con + Tab → docker container. Type docker container ls --f + Tab → --filter. It’s like having an OCD assistant who alphabetizes your life.

Navigation Tricks: Because Walking is for Normies

You know cd and ls. Yawn. Let’s talk about advanced directory parkour.

Back and Forth Like a Digital Pendulum

cd - isn’t just “go back” – it’s a toggle switch. Run it once to return to previous directory, run it again to jump back. Like a command line yo-yo. Combine with ls for instant context switching:

wongedan@chaos:~$ cd /var/log
wongedan@chaos:/var/log$ cd -
/home/wongedan
wongedan@chaos:~$ ls !$
ls /var/log  # Lists logs without leaving home

Directory Stack Gymnastics

Ever need to jump between 5 directories? pushd and popd are your lifelines:

wongedan@chaos:~$ pushd /etc/nginx
/etc/nginx ~
wongedan@chaos:/etc/nginx$ pushd ~/Projects
~/Projects /etc/nginx ~
wongedan@chaos:~/Projects$ pushd /tmp
/tmp ~/Projects /etc/nginx ~

See that stack? Now popd takes you back through the sequence:

wongedan@chaos:/tmp$ popd
~/Projects /etc/nginx ~
wongedan@chaos:~/Projects$ popd
/etc/nginx ~

It’s a LIFO (Last-In-First-Out) stack for directories. Sysadmins use this during crisis debugging while mainlining espresso.

The Dot Files Illusion

ls hides dot files by default. Newbies think they’re gone. LIES. Use:

  • ls -a → Show ALL files (including .bashrc, .ssh/)
  • ls -A → Show all EXCEPT . and .. (more practical)
  • ls -d */ → Only show directories (that trailing */ is magic)

File Operations: How Not to Delete Your Soul

You’ve heard “don’t run rm -rf /“. But what about the landmines you don’t see?

The -i Lifesaver

Always alias rm with interactive mode:

# Add to ~/.bashrc
alias rm='rm -i'

Now rm file.txt asks: rm: remove regular file 'file.txt'? . Yes/no. No more “oops I deleted client_data” before coffee.

But Wong Edan’s Pro Move? Use trash-cli instead:

sudo apt install trash-cli  # Debian/Ubuntu
trash-put accidentally_deleted.txt  # Goes to actual trash
trash-list  # See what's recoverable
trash-restore  # Bring back files

It’s like rm with an undo button. Bless the souls who made this.

Copy/Move Like a Ninja

cp -r is for amateurs. Real warriors use:

  • cp -av source/ dest/-a preserves permissions/timestamps, -v verbose (critical for debugging)
  • rsync -Pavz source/ dest/ → Resume failed transfers (-P), compress (-z), preserve everything (-a)

Example: Copy a huge directory without melting your CPU:

rsync -Pav --partial --bwlimit=10000 Documents/ backup-server:/backups/

--bwlimit=10000 caps at 10MB/s so your SSH session doesn’t freeze. --partial resumes partial transfers. You just became a data migration hero.

Piping Hot Data: Where CLI Becomes a Symphony

Pipes (|) are Linux’s secret sauce. They chain commands like digital LEGOs. But most people stop at grep. Time to level up.

Filtering with Surgical Precision

Find processes with “chrome” but exclude “chromium”:

ps aux | grep chrome | grep -v chromium

grep -v inverts the match. Now you see ONLY Chrome instances.

Counting Without Counting

How many JPGs in a directory? Don’t ls and count – pipe to wc:

find . -name "*.jpg" | wc -l

wc -l counts lines. Each find result is a line → instant count.

Process Substitution: Mind-Bending Magic

Compare two directory listings without temporary files:

diff <(ls dir1) <(ls dir2)

<( ) feeds command output as a FILE. diff thinks it’s comparing actual files. Witchcraft.

Text Editing: nano vs vim (The Bloodsport)

Let’s settle this: nano for quick edits, vim for “I live in the terminal” energy. But both have hidden combos.

nano: The “No, I’m Not Afraid” Editor

Yes it’s simple. But try these:

  • Ctrl+W → Search (yes, it has search!)
  • Alt+\\ → Jump to start of file
  • Alt+/ → Jump to end
  • Ctrl+_ → Goto line number (e.g., Ctrl+_, 42)
  • Hold Alt and drag mouse → block selection (for copying columns)

Save time: Edit ~/.nanorc to enable syntax highlighting:

include /usr/share/nano/*.nanorc

vim: Where Keyboards Go to Die (Then Resurrect)

Forget “vim is hard”. These 5 commands make you 80% effective:

  1. i → Insert mode (type normally)
  2. Esc → Back to command mode
  3. :wq → Save and quit (WRITE, QUIT – tattoo this on your forearm)
  4. dd → Delete current line (2x d in command mode)
  5. /searchterm → Search (then n for next match)

Wong Edan’s Emergency Exit:

If you’re stuck in vim, spam Esc then type :q! + Enter. This forcefully quits without saving. You’re welcome.

Scripting: Automate or Perish

You’ve typed the same command 5 times? Script it. Start SMALL:

#!/bin/bash
# Back up my chaos directory weekly
cp -av ~/chaos/ ~/backups/chaos-$(date +%F)

Save as backup.sh, then:

chmod +x backup.sh
./backup.sh

Now the real magic: cron jobs. Run crontab -e and add:

0 3 * * * /home/wongedan/backup.sh  # Runs at 3am daily

Suddenly you’re a sysadmin. Pat yourself on the back with your other hand.

Wong Edan’s Secret Vault: Pro Tips for Digital Survivors

These are the tricks I’ve used to avoid getting fired (mostly):

sudo !! Is Just the Beginning

After a permission error:

  • sudo !! → Re-runs last command with sudo
  • sudo !-2 → Runs command from 2 entries ago with sudo
  • echo "sudo $(history 1)" | sh → Nuclear option for sudo-ifying any history entry

The watch Command: Live Dashboard Mode

Track changing data like a hawk:

watch -n 2 "ps aux | grep nginx | grep -v grep"

Refreshes every 2 seconds showing ONLY nginx processes. Drop the -n 2 for 1-second updates (CPU warning!).

xargs: The Multiplier Effect

Delete all .tmp files found by find:

find . -name "*.tmp" -print0 | xargs -0 rm -v

find -print0 and xargs -0 handle spaces in filenames (critical!). rm -v shows each deletion. Safety first.

Kill Processes Without Murdering Innocents

Instead of kill -9 (the digital shotgun), try:

pkill -f "python app.py"  # Kills by command name
killall -v nginx          # Verbose kill by service name
systemctl restart nginx   # Proper service restart (systemd)

Send gentle signals first (SIGHUP to reload config):

kill -HUP $(pgrep nginx)

When Everything Burns: Emergency CLI Resuscitation

You broke sudo? Accidentally chmod -R 777 /? I’ve been there. Bookmark these:

  • No network? Fix DNS: Edit /etc/resolv.conf → add nameserver 8.8.8.8
  • Can’t type? stty sane fixes keyboard weirdness
  • Locked out of GUI? sudo systemctl isolate multi-user.target drops to CLI
  • Forgot root password? Reboot, hold Shift for GRUB, edit kernel line to add init=/bin/bash

“But Wong Edan,” you sob, “I just ran `rm -rf /`!”
Relax. If you used `sudo rm -rf / –no-preserve-root`, reboot from live USB and restore from backup. If you ran it without sudo? Congrats – you only nuked your home directory. The system lives!

Your CLI Journey Starts Now (And Ends Never)

You’ve survived my rant. You now know more about CLI than 80% of “developers” with fancy job titles. But here’s the truth no one admits: this is kindergarten. Linux CLI mastery is a lifelong dance with chaos. You’ll still break things. You’ll still Google “how to exit vim” 47 times. That’s not failure – it’s the ritual.

So go forth, you beautiful disaster:

  • Break things in a docker run -it ubuntu container (free sandbox!)
  • Add alias ll='ls -lhF --color=auto' to ~/.bashrc today
  • Try one new command daily (start with man curl)

Remember: the command line isn’t about memorizing syntax. It’s about becoming one with the machine. When you dream in pipes and permissions, that’s when you know you’ve leveled up. Now if you’ll excuse me, I need to go fix the server I broke while writing this.

Wong Edan out. Try not to dd your bootloader.