Bash Cheatsheet

Navigate, search, and automate tasks in the terminal with the most useful Bash commands.

Navigation

Key / CodeDescription
pwdPrint working directory.
ls -laList files with details.
cd ~/projectsChange directory.
cd -Go back to previous directory.

Files & Folders

Key / CodeDescription
touch file.txtCreate a file.
mkdir -p app/srcCreate nested folders.
cp -r src distCopy recursively.
mv old newMove or rename.
rm -rf tempRemove files or folders.

Search & Text

Key / CodeDescription
grep -R "TODO" .Search recursively.
find . -name "*.ts"Find files by name.
sed -n '1,20p' filePrint a line range.
awk '{print $1}' fileExtract columns.

Pipes

Chain commands to transform data.

cat access.log | grep 500 | sort | uniq -c | sort -nr

Scripting Basics

Quick helpers for automation.

#!/usr/bin/env bash
set -euo pipefail

NAME=devref
echo "Hello $NAME"

for f in *.log; do
  echo "Processing $f"
done
Knowledge is power.