DEV Community

Cover image for Supercharge Your Terminal: The Linux Aliases I Can't Live Without
Priyansh Bisht
Priyansh Bisht

Posted on

Supercharge Your Terminal: The Linux Aliases I Can't Live Without

Stop Wasting Time in the Terminal: Linux Aliases Every Developer Should Know

How much time do you spend typing the same terminal commands every day?

If you're entering git commit -m, npm run dev, or navigating through directories for the hundredth time this week, you're spending energy on repetition instead of development.

Your terminal should be your fastest tool — not a bottleneck.

The solution is simple: Aliases.

Aliases are custom shortcuts that map a short command to a longer one. Add a few lines to your shell configuration (.bashrc, .zshrc) and you'll remove thousands of unnecessary keystrokes from your workflow over time.

Over a year, these tiny optimizations compound into hours of saved time and reduced friction.


What Is an Alias?

An alias follows a simple structure:

alias shortcut="actual_command"
Enter fullscreen mode Exit fullscreen mode

Example:

alias gs="git status"
Enter fullscreen mode Exit fullscreen mode

Now instead of typing:

git status
Enter fullscreen mode Exit fullscreen mode

You only type:

gs
Enter fullscreen mode Exit fullscreen mode

Small change. Huge effect.


1. Essential Navigation Shortcuts

Directory navigation is something every developer does constantly. Shaving even a second from repetitive movement matters.

Navigation Aliases

# Move up directories quickly
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."

# Better directory listing
alias ll="ls -lah --color=auto"
alias ls="ls --color=auto"
Enter fullscreen mode Exit fullscreen mode

What these do

Alias Command Purpose
.. cd .. Go back one directory
... cd ../.. Go back two directories
.... cd ../../.. Go back three directories
ll ls -lah Detailed file listing
ls ls --color=auto Colorized output

Why ll is useful

Instead of:

-rw-r--r-- 1 user user 2400000 Jan 20 file.txt
Enter fullscreen mode Exit fullscreen mode

You'll see:

-rw-r--r-- 1 user user 2.4M Jan 20 file.txt
Enter fullscreen mode Exit fullscreen mode

Much easier to scan.


2. Web Developer Lifesavers

If you build web applications, you've probably experienced this:

  • Node crashes
  • Next.js hangs
  • Vite refuses to start
  • Port 3000 is already in use

Instead of manually searching for process IDs:

lsof -i :3000
kill -9 PID
Enter fullscreen mode Exit fullscreen mode

Create instant shortcuts.

Port Killers

# Kill processes occupying common development ports
alias kill3000="kill -9 \$(lsof -t -i:3000)"
alias kill8080="kill -9 \$(lsof -t -i:8080)"
Enter fullscreen mode Exit fullscreen mode

Now simply run:

kill3000
Enter fullscreen mode Exit fullscreen mode

Done.

How this works

The command:

lsof -t -i:3000
Enter fullscreen mode Exit fullscreen mode

silently retrieves the process ID running on port 3000.

That ID is immediately passed into:

kill -9
Enter fullscreen mode Exit fullscreen mode

which terminates the process.

Flow:

Find Process → Extract PID → Kill Process
Enter fullscreen mode Exit fullscreen mode

NPM Shortcuts

alias nrd="npm run dev"
alias nrb="npm run build"
alias ns="npm start"
Enter fullscreen mode Exit fullscreen mode

Instead of:

npm run dev
Enter fullscreen mode Exit fullscreen mode

You write:

nrd
Enter fullscreen mode Exit fullscreen mode

After hundreds of executions, your fingers will appreciate it.


3. Git on Autopilot

Git usually consumes a large portion of terminal usage.

These shortcuts significantly reduce repetitive typing.

Daily Git Workflow Aliases

alias gs="git status"
alias ga="git add ."
alias gc="git commit -m"
alias gp="git push origin"
alias gpo="git pull origin"
Enter fullscreen mode Exit fullscreen mode

Typical Workflow

Instead of:

git status
git add .
git commit -m "Added authentication"
git push origin main
Enter fullscreen mode Exit fullscreen mode

You can do:

gs
ga
gc "Added authentication"
gp main
Enter fullscreen mode Exit fullscreen mode

Cleaner and faster.


4. Beautiful Git History Visualization

The default git log output becomes difficult to read as projects grow.

This alias creates a cleaner commit graph.

alias glog="git log --graph \
--pretty=format:'%Cred%h%Creset \
-%C(yellow)%d%Creset %s \
%Cgreen(%cr) %C(bold blue)<%an>%Creset' \
--abbrev-commit"
Enter fullscreen mode Exit fullscreen mode

Example Output

* a12b45f - Added authentication (2 hours ago) <Priyansh>
* e45c789 - Fixed navbar bug (1 day ago) <Priyansh>
* c87d123 - Initial project setup (3 days ago) <Priyansh>
Enter fullscreen mode Exit fullscreen mode

Benefits:

✅ Colorized output

✅ Commit graph visualization

✅ Relative timestamps

✅ Author information

✅ Easier branch tracking


5. System Maintenance Commands

Keep your machine healthy without remembering long commands.

Update and Cleanup Shortcuts

# Debian / Ubuntu systems
alias update="sudo apt update && sudo apt upgrade -y"

alias clean="sudo apt autoremove -y && sudo apt clean"
Enter fullscreen mode Exit fullscreen mode

What they do

update

sudo apt update
sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Updates package lists and installs upgrades.

clean

sudo apt autoremove -y
sudo apt clean
Enter fullscreen mode Exit fullscreen mode

Removes unnecessary packages and clears package cache.


6. Reload Shell Configuration Instantly

After adding aliases, you normally need to reload your shell.

alias reload="source ~/.bashrc"
Enter fullscreen mode Exit fullscreen mode

For Zsh:

alias reload="source ~/.zshrc"
Enter fullscreen mode Exit fullscreen mode

Instead of closing and reopening your terminal:

reload
Enter fullscreen mode Exit fullscreen mode

Changes apply immediately.


Bonus Aliases Worth Stealing

These are useful additions many developers eventually adopt:

# Clear terminal
alias c="clear"

# Current public IP
alias myip="curl ifconfig.me"

# Create a directory and enter it immediately
mkcd() {
    mkdir -p "$1"
    cd "$1"
}

# Quick disk usage
alias duh="du -sh *"

# Show PATH entries line-by-line
alias path='echo $PATH | tr ":" "\n"'

# Restart shell session
alias restart="exec $SHELL"
Enter fullscreen mode Exit fullscreen mode

How to Add These Aliases

1. Open your shell configuration file

For Bash:

nano ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

For Zsh:

nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

2. Paste your aliases at the bottom

Example:

alias gs="git status"
alias nrd="npm run dev"
alias kill3000="kill -9 \$(lsof -t -i:3000)"
Enter fullscreen mode Exit fullscreen mode

3. Save the file

Press:

CTRL + X
Y
Enter
Enter fullscreen mode Exit fullscreen mode

4. Reload configuration

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

or:

reload
Enter fullscreen mode Exit fullscreen mode

Final Thoughts

Aliases seem insignificant at first.

Saving 2–5 seconds on a command doesn't feel important — until you realize you execute many of those commands hundreds of times every week.

Small optimizations compound:

  • Less typing
  • Less context switching
  • Faster workflows
  • Lower friction
  • More time building things

Your terminal should feel like an extension of your brain, not a place where you repeat the same commands endlessly.

What is the one terminal alias you refuse to work without?

Top comments (1)

Collapse
 
gnomeman4201 profile image
GnomeMan4201

Aliases are genuinely one of those things where the gap between a beginner and a
seasoned operator is just... visible in their .bashrc.

Here's what I'd add from years of security research and tool development:

── The "what is this machine actually doing" tier ─────────

alias listeners="ss -tlnp"
alias established="ss -tnp state established"
alias sysfail="systemctl --failed"
alias zombie="ps aux | awk '\$8==\"Z\"'"
alias recent="find . -mmin -60 -type f | sort"
alias suid="find / -perm -4000 -type f 2>/dev/null"
alias loginwatch="sudo lastlog | grep -v 'Never'"
alias failauth="sudo journalctl -u ssh | grep -i 'failed|invalid' | tail -20"

── The "I don't trust my own repo" tier ───────────────────

alias gsecrets="git log -p | grep -iE 'password|secret|token|api' | head -30"
alias gundolast="git reset --soft HEAD~1"
alias gdangling="git fsck --lost-found"
alias gcleanup="git branch --merged | grep -v '*|main|master|dev' | xargs git branch -d"

── The "on every machine within 5 minutes" tier ───────────

alias mk="make -j$(nproc)"
alias activate="source .venv/bin/activate"
alias venv="python3 -m venv .venv && source .venv/bin/activate"

Functions (the alias graduates)

whosport() { sudo lsof -i :"$1" -sTCP:LISTEN; }
bak() { cp "$1" "${1}.$(date +%Y%m%d_%H%M%S).bak"; }
b64e() { echo -n "$1" | base64; }
b64d() { echo -n "$1" | base64 -d; }
extract() {
case "$1" in
.tar.gz|.tgz) tar xzf "$1" ;; *.tar.xz) tar xJf "$1" ;;
*.zip) unzip "$1" ;; *.7z) 7z x "$1" ;;
*) echo "unknown format: $1" ;;
esac
}

The ones that have caught real issues: gsecrets (accidentally committed creds in
repo history survive a .gitignore fix this finds them), suid (SUID files that
shouldn't exist), and loginwatch (accounts with shell access that have never
logged in are worth auditing).

bak() is the one I evangelize most. Timestamped, non-destructive, no thought
required. It's replaced "let me just quickly rename this" for me entirely.

Your terminal should answer "what is this machine doing right now" just as fast
as it answers "where are my files." The aliases that do that are the ones worth
keeping.