How To Change The Sudo Prompt In Linux And Unix

change the sudo prompt

I felt a bit bored today. While digging in Google, I found this cool and useless hack. There is an option to change the sudo prompt to something cool or funny. Whenever I use a sudo command, it will display “[sudo] password for …” statement. Let us consider the following example.

sudo pacman -Syyu

Sample output:

[sudo] password for sk:

As you see above, the default output is “[sudo] password for sk”. Well, It’s boring to see this each time. I just wanted to change the password prompt to 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 sudoing? Yes! Here comes “alias” 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? 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 will be happy! Who doesn’t want compliments, huh?

Look, what I have done to my sudo prompt. LOL!

Don’t do this on your production systems.

Happy sudo’ing!


Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

  • turbor

    NEVER EVER run ‘vi /etc/sudoers’ !
    Always use visudo since it will do a sanity check on the new config file before activating it when you save the changed file, and it will allow you to correct your mistakes if there are any. If sudo encounters a broken config file it will simply stop working!

    • SK

      Good point. Corrected now. Thank you!