Use the Force, Unixuser42!

DISCLAIMER: Don’t get confused by the title. This post won’t teach you any advanced UNIX trickery stuff. If you’re expectation is such, you’ll be pissed after reading the article. You’ve been warned!

I had quite a laugh watching the Volkswagen Superbowl commercial, where this kid dressed up in Darth Vader Ccostume trying to control everything using the Force.

Then I got a (lame)idea! What if the powerful ‘sudo’ command in UNIX, which enables you to perform task as the superuser, was replaced by ‘force’! So you can type things like “force halt” in the terminal and shutdown the system. The Star Wars fan inside me got excited, and the Unix fan set out on a (very short)path to figure out how to achieve that.

The obvious way to do this is create to an alias for command ‘sudo’ and set it to ‘force’. Here’s how this can be done:

  1. Fire up your terminal program
  2. Move to your $HOME directory: cd ~/
  3. Open the .bash_profile file: vi .bash_profile (I’m on OS X. On other systems, like Ubuntu, this file will be .bashrc)
  4. Add this line to the end of the file and save: alias force=’sudo’
  5. Reload .bash_profile: source .bash_profile
  6. Try it: force reboot (System will reboot after authentication)

Don’t worry about ‘sudo’, you’ll still be able to use it. You didn’t exactly ‘replace’ sudo, you just gave it another name.

Also, it’s good idea to check if your system somehow already not using the ‘force’ command. (Type force in the shell to see whether it responds ‘command not found’ message.)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s