How To Change The Sudo Prompt In Linux
Ok maybe I’m a bit bored today. While digging in Google, I came across this cool and useless hack. There is an option to change the sudo prompt to something cool or funny. As you may already know, whenever we use a sudo command, it will display “[sudo] password for …” statement, right? Yes! You can, however, change this statement to something different if you want. This is what this brief guide talks about.
Change The Sudo Prompt In Linux
Have a look at the following command.
sudo pacman -Syyu
[sudo] password for sk: [...]
As you see above, the default output starts with – “[sudo] password for sk”. Well, It’s boring to see this each time. I want something cool and funny. Here is how you can change the sudo password prompt as you please.
sudo -p "Sir, Could You Please Enter Your password: " pacman -Syyu
The sudo prompt will now look like this:
Sir, Could You Please Enter Your password:
Here, -p flag will display the custom password prompt when you use sudo command. Really cool, isn’t it?
I am too lazy to type this sentence every time. Is there anyway to display this automatically when I am ‘sudo’ing? Of course, yes! Here is where “alias” comes in help. Just add an alias to your .bashrc or .alias file like below.
alias sudo=’sudo -p “Sir, Could You Please Enter Your password: “‘
I don’t want to use alias. Good! You can do this by modifying the sudoers file.
To do so, run:
Add/modify the following line:
Defaults passprompt="Hey dude, Password Please?:"
It’s also possible to display an icon in sudo prompt. Say for example, to display a lock symbol, just enter the following from your Terminal.
export SUDO_PROMPT='[sudo] %p : '
This will display a lock symbol when you use any sudo command.
[sudo] sk :
You can use any other symbols with any custom message within quotes as shown above.
That’s it. Whenever you run sudo command, It will greet you however you please.
Want to impress your Girlfriend/wife? Just change the sudo password prompt in her Linux box to something romantic. How about this?
export SUDO_PROMPT='Hello beautiful, Enter Your password:'
You should run the above command as root user. Whenever she use sudo command, she will be greeted with the following message:
Hello beautiful, Enter Your password:
She would be delighted! Who doesn’t love compliments, huh?
Look, what I have done to my sudo prompt. LOL!
Anyway, don’t do this on your production systems. Your boss might not be happy!!
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: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!