← All cheatsheets

Shell

Shell basics — the 20 commands that cover 90% of daily work

## Navigation
`pwd` — print working directory
`ls` / `ls -lah` — list / list with details
`cd` / `cd -` — change dir / jump to previous

## Files
`cat file` — print file
`less file` — page through file (`q` to quit)
`head -n 20 file` / `tail -n 20 file` — first / last 20 lines
`tail -f log` — follow log file

## Search
`grep "pattern" file` — search file
`grep -ri "pattern" dir` — recursive case-insensitive search
`find . -name "*.md"` — find files by name

## Manipulate
`cp src dst` — copy
`mv src dst` — move/rename
`rm file` / `rm -rf dir` — delete (careful with the second)
`mkdir -p path` — create nested dirs

## Pipes + redirects
`cmd1 | cmd2` — pipe stdout of cmd1 into cmd2
`cmd > file` — overwrite file with stdout
`cmd >> file` — append stdout to file