Why I Alias the Shutdown Command on My Linux Workstations

linux bash aliases shutdown safety productivity terminal

Preventing accidental shutdowns of remote machines by creating distinct aliases for local vs remote system control

The Problem

Have you ever accidentally shut down a production server with this command?

shutdown now

I work in the terminal all day, so naturally at the end of my workday I use the command line to shut down my machine. However, I’ll typically have anywhere from 4 to 8 tabs open that—despite my best efforts to disconnect—could still be connected to remote machines.

On occasion, when I’m in a hurry checking that all my code is saved, committed, and pushed, I’ve accidentally run shutdown on a remote machine. When you do this, you get a really deep sinking feeling in your gut.

The Solution

I needed to force a change in my daily habits. The action to shutdown my local machine needed to be different than the action to shutdown a remote machine.

I added these lines to the end of my ~/.bashrc file:

alias shutdown="echo 'You must call \"sd\" to shutdown this machine.'"
alias reboot="echo 'You must call \"rb\" to reboot this machine.'"
alias sd="/usr/sbin/shutdown"
alias rb="/usr/sbin/reboot"

The Result

It’s been a little over a year since I added this, and it took about a week before I instinctively knew what to type without having to think about it.

I was doing some work on a development server a few days ago and had to leave in a bit of a hurry. When I came back to my desk later that night to put away my laptop, I had a single terminal open and I ran:

sd now

I was still connected to that remote dev server. It threw an error for an unrecognized command, and it was obvious that for the first time, setting up those aliases was worth it.

Benefits

  • Prevents accidents: Distinct commands for local vs remote operations
  • Forces awareness: Makes you think about what you’re shutting down
  • Maintains workflow: Still allows quick shutdowns when needed
  • Easy to implement: Simple bash aliases, no complex scripts required

Usage

  • Local shutdown: sd now
  • Local reboot: rb now
  • Remote operations: Use the standard shutdown and reboot commands (which will fail safely if you’re not root)

This simple precaution has saved me from potential disasters and given me peace of mind when working with multiple terminal sessions.