Bookmark this page
Press Ctrl+D (Windows) or Cmd+D (Mac) to bookmark this page.
⌨ Bash

Bash / Linux Commands Cheat Sheet

A more complete terminal reference for navigation, redirects, permissions, variables and text processing.

Navigate fasterRedirect outputPermissions and ownershipProcess and text tools

Navigation

pwd
ls -lah
cd /path/to/project
cd -
mkdir -p new-folder/sub-folder
touch notes.txt

Files and search

cp source.txt backup.txt
mv old-name.txt new-name.txt
cp -r folder backup-folder
rm -r folder
grep -Rin "query" .
find . -name "*.js"

Redirects and pipes

command > output.txt
command >> output.txt
command 2> errors.txt
command | tee output.txt
cat file.txt | grep "term" | head

Permissions

chmod +x script.sh
chmod 755 deploy.sh
chown user:group file.txt
sudo chown -R user:group folder
umask 022

Processes and jobs

ps aux
top
kill 12345
pkill node
jobs
fg
bg

Variables and quoting

name="Alex"
echo "$name"
echo '$name'
export API_KEY="secret"
echo ${name:-Guest}

Text processing

grep -R "ERROR" .
cut -d, -f1,3 data.csv
sort names.txt | uniq
sed -n '1,20p' file.txt
awk '{print $1, $NF}' data.txt
tr '[:lower:]' '[:upper:]'
find . -name "*.js" | xargs grep -n "TODO"

Package managers

sudo apt update && sudo apt upgrade
sudo apt install git curl
sudo dnf install git
brew update && brew upgrade
brew install jq
✓ Copied!