I'm bit bored today. While digging in Google, I came across this cool and useless(!) hack. There is an option to change the sudo prompt in Linux 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 apt update
[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. If you want to change it, here is how you can change the sudo password prompt as you please.
$ sudo -p "Sir, Could You Please Enter Your password: " apt update
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 the whole sentence every time. Is there anyway to display this automatically when I am 'sudo'ing? Of course, yes! Here is where "alias" command comes in help.
$ alias sudo='sudo -p "Sir, Could You Please Enter Your password: "'
To make it permanent, just add the alias to your ~/.bashrc file and then run the following command to take effect the changes.
$ source ~/.bashrc
I don't want to use alias. No problem! You can do this by modifying the sudoers file.
To do so, run:
$ sudo visudo
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?
Anyway, don't do this on your production systems. Your boss might not be happy!!