Linux Terminal Productivity Hacks

linux productivity dev

The terminal is where developers live. Mastering it means faster workflows, fewer context switches, and more time for actual problem-solving.

Here are the productivity hacks that have saved me hours over the years.

Essential Keyboard Shortcuts

Ctrl + A    # Move to beginning of line
Ctrl + E    # Move to end of line
Ctrl + U    # Delete from cursor to beginning
Ctrl + K    # Delete from cursor to end
Ctrl + W    # Delete word before cursor
Alt + B     # Move back one word
Alt + F     # Move forward one word

History

Ctrl + R    # Reverse search history (game changer!)
Ctrl + G    # Exit history search
!!          # Repeat last command
!$          # Last argument of previous command
!^          # First argument of previous command
!*          # All arguments of previous command

Process Control

Ctrl + C    # Kill current process
Ctrl + Z    # Suspend current process
fg          # Resume suspended process
bg          # Resume in background

Command History Magic

Search and Reuse

# Reverse search - start typing, press Ctrl+R again to cycle
(reverse-i-search)`git': git push origin main

# Run command by number
history | grep "docker"
!142        # Run command number 142

# Run last command starting with...
!git        # Last command starting with 'git'
!ssh        # Last command starting with 'ssh'

Fix Typos

# Replace in last command
^typo^fix^
# Example: 
git stauts
^stauts^status^   # Runs: git status

Directory Navigation

pushd/popd Stack

pushd /var/log    # Push current dir, cd to /var/log
pushd /etc        # Push /var/log, cd to /etc
popd              # Pop back to /var/log
popd              # Pop back to original dir
dirs -v           # View directory stack

Quick Shortcuts

cd -              # Go to previous directory
cd ~              # Go to home
cd                # Also goes to home
cd ~/projects     # Expand ~

Install autojump or z

# After visiting directories, just type partial names
z proj            # Jump to /home/user/projects
j logs            # Jump to /var/log (autojump)

Aliases That Save Keystrokes

Add these to ~/.bashrc or ~/.zshrc:

# Git shortcuts
alias g='git'
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline -10'
alias gd='git diff'

# Navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

# Safety nets
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Colorize output
alias ls='ls --color=auto'
alias grep='grep --color=auto'

# Show hidden files
alias la='ls -la'
alias ll='ls -l'

# Quick edits
alias bashrc='$EDITOR ~/.bashrc'
alias zshrc='$EDITOR ~/.zshrc'

# Python
alias py='python3'
alias pip='pip3'
alias venv='python3 -m venv'
alias activate='source venv/bin/activate'

Powerful One-Liners

Find and Act

# Find files by name
find . -name "*.py" -type f

# Find and delete
find . -name "*.pyc" -delete

# Find and execute
find . -name "*.txt" -exec grep "pattern" {} \;

# Find recently modified
find . -mtime -1 -type f  # Modified in last 24 hours

Text Processing Pipeline

# Count lines of code
find . -name "*.py" | xargs wc -l

# Find largest files
du -sh * | sort -rh | head -10

# Count unique occurrences
cat access.log | cut -d' ' -f1 | sort | uniq -c | sort -rn | head

# Watch log file
tail -f /var/log/app.log | grep ERROR

Quick Servers

# Python HTTP server
python3 -m http.server 8000

# PHP server
php -S localhost:8000

# Share files quickly
python3 -m http.server 8000 --bind 0.0.0.0

tmux: Terminal Multiplexer

Essential for remote work and session persistence.

# Start new session
tmux new -s dev

# Detach (keeps running)
Ctrl + B, then D

# Reattach
tmux attach -t dev

# List sessions
tmux ls

# Split panes
Ctrl + B, %     # Vertical split
Ctrl + B, "     # Horizontal split

# Navigate panes
Ctrl + B, arrow keys

# New window
Ctrl + B, C

# Switch windows
Ctrl + B, N     # Next
Ctrl + B, P     # Previous
Ctrl + B, 0-9   # By number

Shell Customization

Useful PS1 Prompts

# Show git branch in prompt (add to .bashrc)
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h:\w\$(parse_git_branch)\$ "

Consider Zsh + Oh-My-Zsh

# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Popular plugins
plugins=(git docker kubectl python node npm)

Bonus Tips

Run Long Commands in Background

# Add & to run in background
long_process &

# Redirect output
long_process > output.log 2>&1 &

# nohup survives terminal close
nohup long_process &

Quick Calculations

echo $((42 * 17))
python3 -c "print(2**10)"
bc <<< "scale=2; 100/3"

Generate Random Strings

openssl rand -hex 16
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32

Final Thoughts

The terminal is an investment. Every shortcut you learn, every alias you create, pays dividends for years.

Start with Ctrl+R for history search—it’s the single biggest productivity boost. Then gradually add aliases for your most-typed commands.


The keyboard is faster than the mouse. Always.

All posts