Bash Cheat Sheet

Searchable reference for everyday Bash commands.

CommandDescription
ls -laList files including hidden, long format
cd <dir>Change directory
pwdPrint working directory
mkdir -p a/b/cMake nested directories
rm -rf <dir>Remove directory recursively
cp -r <src> <dst>Copy directory recursively
mv <src> <dst>Move / rename
cat <file>Print file contents
less <file>Page through a file
head -n 20 <file>First 20 lines
tail -f <file>Follow file output
grep -r 'pat' .Recursive grep
find . -name '*.cs'Find files by name
sed 's/foo/bar/g' fStream edit (replace globally)
awk '{print $1}' fPrint first column
chmod 755 <file>Set file permissions
chown user:group fChange file owner
ps aux | grep appFind running process
kill -9 <pid>Force-kill process
df -hDisk space (human readable)
du -sh <dir>Folder size
tar -czf a.tgz d/Create gzipped tar
tar -xzf a.tgzExtract gzipped tar
curl -fsSL urlQuietly fetch and pipe
wget urlDownload a URL
ssh user@hostSSH into host
scp f user@host:/pCopy over SSH
export VAR=valueSet environment variable
history | grep cmdSearch shell history
man <cmd>Show command manual

About this tool

Common file, process, archive and shell commands with one-line descriptions.

An unhandled error has occurred. Reload ×