⌨️ how-to linux
or, the “the wisdom of the tee” part.

tl;dr

  • absolute basics: cd, ls, rm, mv, vim
  • shortcuts: [ctrl] + [a|e|c|k|z]
  • intermediate: |, history, grep (ripgrep), cat, less, man, find (fd), df, du (dust), sudo, tail, touch, alias, sh, exit
  • processes: &, >, top, ps, kill, killall, which, locate, fg
  • network: curl, whois, traceroute, ping, lsof, scp
  • handy commands: SSH key generation, handling archives, replacing en masse, permissions, JSON parsing, shell script checks, zx


learning how to use the terminal of your computer is a console without any buttons. you are expected almost to know which “buttons” are hidden there below the surface. no one ever gave me a primer and it was painful to learn over time through trial and error what those hidden commands are. here’s a compilation of some useful commands to get you through most basic functions and some more interesting ones.

btw, god help you if you need to write shell scripts. ugh, i think they’re the worst syntactically. my tendency is to write node or python scripts instead because at least they make bore sense to me.

absolute basics

cd [name] — change directory 
  • ~ is shorthand for your home directory
  • .. is shorthand for the parent directory
  • . is shorthand for the current directory
  • - is shorthand for the previous directory you were in (like your browser’s “back” button)
  • e.g. cd .. will take you to the parent directory
ls — list contents of the directory you’re in
  • ls -lah is useful to list hidden files as well
rm [file] — remove a file
  • rm -r [file] — remove a directory
mv [origin] [destination] — move a file somewhere else
  • clear — also, clears screen
vim [file] — edit a file
  • i to go to insert mode
  • esc to go back to command-mode
  • / to search in the file
  • :w (in command mode) to save
  • :q (in command mode) to quit

shortcuts

this is a pet peeve of mine that no one ever taught me these super handy shortcuts and i didn’t know about them for many years.

[ctrl] + a — go to beginning of the line
[ctrl] + e — go to the end of the line
[ctrl] + c — kill the currently running program
[ctrl] + k — clear screen
[ctrl] + z — pause the currently running program

intermediate