Bash

March 16, 2026 • Bash • Clicking is for people who have time to waste.

You click the same things every day. Copy files. Rename a batch of photos. Restart a service. Stop doing that manually. Write a script. Let the machine work for you.

What Bash Actually Is

Bash is a shell - a way to talk to your computer through text. You type commands, the computer executes them. This is how all computers worked before GUIs. It's still the most powerful way to work.

Bash is the default shell on most Linux systems and macOS. On Windows, use WSL (Windows Subsystem for Linux) or Git Bash. Stop using PowerShell if you can avoid it.

The Commands You Need

These are the basics. Use these every day:

ls                  # List files
ls -la              # List all files with details
cd myfolder         # Change to myfolder
cd ..               # Go back one level
cd ~                # Go to home directory
pwd                 # Print working directory (where are you?)
mkdir myfolder      # Create a folder
rm file.txt         # Delete a file
rm -rf folder       # Delete folder and everything in it
cp source dest       # Copy file
mv old new          # Move or rename
cat file.txt        # Print file contents
head file.txt       # First 10 lines
tail file.txt       # Last 10 lines
grep "search" file  # Search in file

Pipes - Chain Commands Together

This is where it gets powerful. The pipe character (|) takes the output of one command and feeds it to the next:

ls | grep ".txt"          # List only .txt files
cat log.txt | tail -20   # Last 20 lines of log
ps aux | grep nginx      # Find nginx process
history | grep git       # Find previous git commands

Chaining commands this way is what makes the terminal actually useful. Learn this pattern.

Variables - Store Things

Like any programming language, Bash has variables:

name="Alex"
age=25
echo "Hello, $name"
echo "You are $age years old"

No spaces around the = sign. Always use quotes around strings. The $ sign accesses the variable.

Conditionals - Make Decisions

if [ $age -ge 18 ]; then
    echo "Adult"
else
    echo "Minor"
fi

Bash has if/then/else/fi. The condition goes in square brackets. Watch your spaces - [$age will break. It must be [ $age.

Loops - Do Things Multiple Times

# Loop through files
for file in *.txt; do
    echo "Processing $file"
done

# Count to 5
for i in 1 2 3 4 5; do
    echo $i
done

Loops automate repetitive tasks. Batch rename files. Process every image in a folder. Whatever needs doing repeatedly.

Write Scripts - Save Your Work

A script is just a file with commands in it. Make it executable and run it:

#!/bin/bash

echo "Starting backup..."

# Get current date
date=$(date +%Y-%m-%d)

# Create backup folder
mkdir -p backups/$date

# Copy important files
cp -r ~/Documents backups/$date/

echo "Backup complete!"

Save this as backup.sh, run chmod +x backup.sh, then execute with ./backup.sh.

Why Bother?

Because clicking is slow. Because scripts are reproducible. Because you can run the same task on 100 servers with one command. Because the terminal is what actual engineers use.

The GUI is for casuals. The terminal is for people who want control.

Get Started

Open your terminal. Run these commands. Then start writing small scripts to automate something you do regularly. Backups. File organization. Service monitoring. Anything.

Learn more:

// Comments

Leave a Comment