68

Type Linux Commands In Capital Letters To Run Them As Sudo User

 4 years ago
source link: https://www.ostechnix.com/type-linux-commands-in-capital-letters-to-run-them-as-sudo-user/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Type Linux Commands In Capital Letters To Run Them As Sudo User

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?

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

Type Linux Commands In Capital Letters To Run Them As Sudo User

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:


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:

Have a Good day!!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK