Operations 4 min read

Install and Use the SUDO Tool to Run Commands as sudo with a Single Keystroke

This guide explains how to clone the SUDO repository from GitHub, install the tool, configure your ~/.bashrc, and then run any Linux command in uppercase to automatically execute it with sudo privileges, while preserving safety features like password prompts and backup files.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Install and Use the SUDO Tool to Run Commands as sudo with a Single Keystroke

Installation of SUDO

Clone the SUDO source code from its GitHub repository and enter the project directory:

$ git clone https://github.com/jthistle/SUDO.git
$ cd SUDO/

Run the provided install.sh script. It appends alias definitions to ~/.bashrc that map each executable found in $PATH to an uppercase alias invoking sudo:

# 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

The installer backs up the original ~/.bashrc as ~/.bashrc.old. After installation, apply the changes with:

$ source ~/.bashrc

Using Uppercase Commands as sudo

Commands that normally require a sudo prefix can be run by typing the command name in uppercase. For example:

$ sudo mkdir /test_dir
# equivalent to
$ MKDIR /test_dir
$ TOUCH /test_dir/test.txt
$ LS /test_dir

The tool does not bypass the sudo password prompt; you will still be asked for your password when the command executes. Using the traditional sudo prefix remains optional.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

command-lineBashsudo shortcutSUDO tool
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.