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:
- Fire up your terminal program
- Move to your $HOME directory: cd ~/
- Open the .bash_profile file: vi .bash_profile (I’m on OS X. On other systems, like Ubuntu, this file will be .bashrc)
- Add this line to the end of the file and save: alias force=’sudo’
- Reload .bash_profile: source .bash_profile
- 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.)