SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Bash
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Bash cheatsheet

Navigation

CommandDescription
pwdPrint working directory
ls -laList all files with details
cd ~Go to home directory
cd -Go to previous directory

File Operations

CommandDescription
cp -r src/ dest/Copy directory recursively
mv file newnameMove or rename file
rm -rf dir/Remove directory (careful!)
touch file.txtCreate empty file
mkdir -p a/b/cCreate nested directories

Viewing & Searching

CommandDescription
cat filePrint file contents
less fileScroll through file
head -n 20 fileFirst 20 lines
tail -f fileFollow file in real time
grep -rn "pattern" .Recursive search with line numbers
find . -name "*.txt"Find files by name

Pipes & Redirection

CommandDescription
cmd1 | cmd2Pipe output to next command
cmd > fileRedirect output to file (overwrite)
cmd >> fileAppend output to file
cmd 2>&1Redirect stderr to stdout
cmd &> fileRedirect both stdout and stderr

Process Management

CommandDescription
ps auxList all processes
kill -9 PIDForce kill a process
top / htopLive process monitor
cmd &Run command in background
jobsList background jobs
ctrl+z then bgSuspend then background a job

Permissions

CommandDescription
chmod +x fileMake file executable
chmod 755 fileSet specific permissions
chown user:group fileChange ownership

Archives

CommandDescription
tar -czf out.tar.gz dir/Create gzip archive
tar -xzf file.tar.gzExtract gzip archive
unzip file.zipExtract zip

Networking

CommandDescription
curl -O URLDownload file
wget URLDownload file
ssh user@hostSSH into remote machine
scp file user@host:pathSecure copy to remote

Text Processing

CommandDescription
sed 's/old/new/g' fileFind and replace
awk '{print $1}' filePrint first column
sort fileSort lines
uniq -cCount unique lines
wc -l fileCount lines
cut -d',' -f1Cut by delimiter

History & Shortcuts

CommandDescription
!!Repeat last command
!$Last argument of previous command
ctrl+rReverse search history
history | grep cmdSearch command history
alias ll='ls -la'Create command alias

Variables & Scripting

VAR="value" # Set variable echo $VAR # Use variable $() # Command substitution: echo $(date) [[ -f file ]] # Test if file exists for i in *.txt; do echo $i; done # Loop over files

Pro tips

  • Use man <command> for full documentation on anything
  • ctrl+a / ctrl+e jumps to start/end of line
  • ctrl+l clears the screen (faster than clear)
  • Prefix a command with a space to keep it out of history

Practice scenarios

Hands-on Bash scenarios on live Linux VMs: bash

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a