Mastering the Command Line
The command line might seem daunting for new (and old) developers, but another unlock for developer productivity — if you can master it. A crash course syllabus that will get you 80% there (Pareto principle).
The caveat is that “the command line” means a lot of things. To be more specific, these are UNIX-y, bash, and popular terminal emulator tricks. This is not a list of complex one-liners that you can alias and never remember what they do. It's a hopefully practical list of things you can learn and remember.
Reverse-i-search ctrl+R— Fuzzy searches through past commands. Add shift to go back a selection. Jump around text with Emacs-style key bindings that generally work in bash-like shells — ctrl+a to jump to the end of the line, ctrl+e to the end. Clear the screen with ctrl+l (or cmd+K on macOS).
Unix pipes, stdin/stdout, redirection — Thinking in terms of stdin/stdout and pipes is the key to navigating the command line. Pipes pass the output (stdout) of one command as input (stdin) to another. Redirection > to a file. Append >> to a file. You can also redirect stdout/stderr to a file or file descriptor, but either memorize those commands 2>&1 or look them up when you need them.
.ssh/config — You can specify all the command line inputs so you can connect more quickly. For example, matching a domain or subnet Host *.amazonaws.com, 10.2.* or even encoding long port forwarding commands LocalForward 5432 database.com:5432
timebefore a command measures the execution timels -lhfor listing human-readable file sizes. Sometimes mnemonics are good for remembering command arg combinations –ls -thororps -aux.mv filename.{old,new}is a bit quicker and less error-pronemacOS –
open .opens finder in that folder,pbcopyandpbpastegive you access to the clipboard.You probably don't want to background a task, but if you do have to –
&will free up the terminal while continuing to write to stdout. List jobs withjobsand bring them back withfg. You can also write to a file withnohup <process> &. Your intuition might be to background a process, but that's usually the wrong solution.
