The reason I love Linux community a lot is they create so many FUN projects which you rarely find in any other propriety operating systems. A while ago, we looked at a fun project named "Hollywood" which turns the Terminal into a Hollywood technical melodrama hacker interface in Ubuntu-like systems. There are a few other utilities available, for example cowsay, fortune, sl and toilet(!) etc., to kill your free time and keep you entertained! They may not be useful, but these utilities are really entertaining and fun to use. Today, I stumbled upon yet another similar utility named "SUDO". As the name implies, whenever you type Linux commands in capital letters, the SUDO utility will run them as sudo user! Meaning, you need not to type "sudo" in-front of the Linux commands you about to run. Cool, yeah?
Table of Contents
Install SUDO in Linux
A word of caution:
Before installing this (or any utility), take a look at the source code (Link given at the end) and see if there are suspicious/malicious code included to harm your system. Test it in a VM. If you like or found it useful, you can use it in your personal/production systems.
Git clone the SUDO repository:
$ git clone https://github.com/jthistle/SUDO.git
This command will clone the contents of SUDO GIT repository and saves them in a directory named "SUDO" in your current working directory.
Cloning into 'SUDO'... remote: Enumerating objects: 42, done. remote: Counting objects: 100% (42/42), done. remote: Compressing objects: 100% (29/29), done. remote: Total 42 (delta 17), reused 30 (delta 12), pack-reused 0 Unpacking objects: 100% (42/42), done.
Switch to SUDO directory:
$ cd SUDO/
And, install it using command:
$ ./install.sh
The command will add the following entries in your ~/.bashrc file:
[...] # SUDO - shout at bash to su commands # Distributed under GNU GPLv2, @jthistle on github shopt -s expand_aliases IFS_=${IFS} IFS=":" read -ra PATHS <<< "$PATH" for i in "${PATHS[@]}"; do for j in $( ls "$i" ); do if [ ${j^^} != $j ] && [ $j != "sudo" ]; then alias ${j^^}="sudo $j" fi done done alias SUDO='sudo $(history -p !!)' IFS=${IFS_} # end SUDO
It will also take a backup of your ~/.bashrc and save it as ~/.bashrc.old. You can restore it if anything goes catastrophically wrong.
Finally, update the changes using command:
$ source ~/.bashrc
Type Linux Commands in Capital letters to run them as Sudo user
Usually, we execute Linux commands that requires sudo/root privileges like below.
$ sudo mkdir /ostechnix
Right? Yes! The above command will create directory named "ostechnix" in root (/). Let us cancel this command using Ctrl+c.
Once SUDO is installed, you can type any Linux command in capital without sudo and run them. So, you can run the above command like below:
$ MKDIR /ostechnix
$ TOUCH /ostechnix/test.txt
$ LS /ostechnix
Please note that it will not bypass the sudo password. You still need to type sudo password to execute the given command. It will only help to avoid typing "sudo" in-front of each command.
Related read:
- How To Run Particular Commands Without Sudo Password In Linux
- How To Restore Sudo Privileges To A User
- How To Grant And Remove Sudo Privileges To Users On Ubuntu
- How To Find All Sudo Users In Your Linux System
- How To Display Asterisks When You Type Password In Terminal
- How To Change The Sudo Prompt In Linux
Of course, typing "sudo" will take only a few seconds, so it is not a big deal. I must tell this is just fun and USELESS project to pass time. If you don't like it, go away and learn something useful. If you like it, give it a go and have fun!
Resource:
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Reddit | Facebook | Twitter | LinkedIn | RSS feeds
Have a Good day!!
9 comments
uh. wow. who’d’ve thunk it? Not sure I like it, but it’s creative
Thanks for the tip!
I’m just curious how this might be better than running the “sudo su” command to escalate your privileges.
A common issue for me is typing a full command, then realising i need sudo. If there was a keystroke i could enter to “add sudo” or upcase my line then this would be awesome
You might find useful that you can run the command without sudo and after it fails type “`sudo !!“` it’ll run the last command and prepend the sudo.
Good tip. Thanks.
You can customize input handling in bash by editing ~/.inputrc, including macros like “on Alt-Enter go to the beginning of the line, insert some text, and then run the command”.
Try: sudo !!
This will run the last command again
Steve, I normally press the up arrow, the. Ctrl+A to go to the beginning of the line. Then type sudo and space and press enter. That was the quickest way I found but I see a comment from Marcos that says just type sudo and press enter and it will run the last command with sudo. I’m on vacation now but looking forward to trying that ? thanks Marcos
If you’ve already run the command, then just use “sudo !!” to rerun the last command with sudo in front, otherwise if you haven’t run it yet, try Ctrl+A to get you to the beginning of the line and then you can add sudo yourself