Bash Quick Ref

Bash Shell Ultimate Quick Reference
Bash Logo

Bash QuickRef

search
Terminal Background
#!/bin/bash

The Ultimate
Bash Shell Cheat Sheet

Master the command line with this comprehensive, interactive reference guide. File operations, permissions, scripting variables, and keyboard shortcuts at your fingertips.

File Control
ls -la

List all files including hidden ones with detailed info.

File Control
cp -r source dest

Copy a directory recursively.

File Control
mv file.txt new.txt

Rename or move a file.

File Control
rm -rf folder

Force remove a directory and its contents (Careful!).

File Control
touch file.txt

Create an empty file or update timestamp.

File Control
mkdir -p a/b/c

Create nested directories.

File Control
cat file.txt

Output the contents of a file.

File Control
tail -f log.txt

Watch a log file in real-time.

File Control
tar -czvf a.tar.gz folder

Compress a folder into tar.gz.

Navigation
cd /path/to/dir

Change directory.

Navigation
cd ..

Go up one directory level.

Navigation
cd ~

Go to home directory.

Navigation
cd -

Go to the previous directory.

Navigation
pwd

Print working directory path.

Search
grep "text" file

Search for text in a file.

Search
grep -r "text" .

Recursive search for text in current dir.

Search
find . -name "*.js"

Find files by name pattern.

Search
find . -type f -size +10M

Find files larger than 10MB.

Search
locate filename

Quickly find file by name (indexed).

Permissions
chmod 755 script.sh

Set rwx for owner, rx for others.

Permissions
chmod +x script.sh

Make a file executable.

Permissions
chown user:group file

Change file owner and group.

Permissions
umask 022

Set default file permissions.

Network
ping google.com

Check network connectivity.

Network
curl -O url

Download file from URL.

Network
wget url

Download file from URL.

Network
ifconfig

Display network interfaces (Legacy).

Network
ip a

Display network interfaces (Modern).

Network
ssh user@host

Secure shell login.

Network
netstat -tuln

List listening ports.

System
ps aux

List all running processes.

System
top

Real-time system monitor.

System
htop

Interactive process viewer (if installed).

System
kill 1234

Terminate process by PID.

System
killall firefox

Kill all processes by name.

System
df -h

Show disk usage (human readable).

System
du -sh folder

Show directory size.

System
free -m

Show memory usage in MB.

Text Processing
wc -l file

Count lines in a file.

Text Processing
sort file.txt

Sort lines alphabetically.

Text Processing
uniq

Filter adjacent duplicate lines.

Text Processing
head -n 5 file

Show first 5 lines.

Text Processing
sed "s/foo/bar/g" file

Replace "foo" with "bar".

Text Processing
awk "{print $1}"

Print the first column.

keyboard Keyboard Shortcuts

Emacs Mode (Default)
Key Combo Action Category
Ctrl + A Go to beginning of line Navigation
Ctrl + E Go to end of line Navigation
Ctrl + R Search history backwards History
Ctrl + L Clear screen Control
Ctrl + C Kill current process Control
Ctrl + Z Suspend current process Control
Alt + . Insert last argument of previous command Editing

compare_arrows I/O Redirection

> Redirect stdout to file (overwrite)
>> Redirect stdout to file (append)
2> Redirect stderr to file
2>&1 Redirect stderr to stdout
&> Redirect both stdout and stderr
| Pipe stdout of left to stdin of right

attach_money Special Variables

$0 Name of the script
$1 - $9 Script arguments
$# Number of arguments
$@ All arguments (as separate strings)
$? Exit status of last command
$$ PID of current shell

Bash Ultimate QuickRef © 2026. Generated for educational purposes.

check_circle Action successful

Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form