When I run a command with sudo like the following, subsequent sudo commands will not ask for a password anymore.

sudo ls

But this still runs ls. If I don't want to run any command at the beginning, but just stop subsequent sudo commands from asking a password later on. Is there a way to do so?

  • 3
    No. I'd like a command that temporarily disables the password. sudo echo -n probably is a way but it is not very elegant. Feb 25, 2021 at 15:36
  • 7
    OK. sudo true is better. Feb 25, 2021 at 15:43
  • 17
    That suspiciously sounds like an XY problem. What's wrong with entering the password the first time you actually need sudo?
    – danzel
    Feb 25, 2021 at 16:47
  • 1
    I am with @danzel on this one : this seems a XYproblem. And the only reason I could see is to enjoy a root session, which defeats the security and purpose of using a regular user most of the time and only sudo the commands that requires it. Feb 26, 2021 at 17:01
  • 5
    @danzel It's useful if sudo is needed in a script and some output comes before it. If you just leave it like that, the output is going to get garbled with the sudo password prompt. In this case, you can add something like sudo true before all the parts of the script that cause meaningful output so it doesn't break the output format.
    – JoL
    Feb 26, 2021 at 22:49

5 Answers 5


Use sudo -v:

-v, --validate
Update the user's cached credentials, authenticating the user if necessary.

  • 6
    and the opposite, -k, --reset-timestamp to forget about cached credentials
    – ilkkachu
    Feb 26, 2021 at 22:28

While muru's answer does exactly what you want, there's also a more general way to "do nothing," even when sudo is not involved.

sudo true

will run the true command, which always succeeds, and has no additional side effects, like printing to the screen, etc. There's also the false command, which always fails. These are both useful in shell scripting.


You have to run something, but you can run a nothing command like true.

jasen@crackle:~$ sudo true
[sudo] password for jasen: 
jasen@crackle:~$ sudo whoami

Have you considered just creating a copy of the command you want to run as root (or any other user) and setting "Special Permissions"? (either SUID or SGID)

For example:

sudo cp /bin/touch /bin/plex-touch; sudo chown plex /bin/plex-touch; sudo chmod 4755 /bin/plex-touch

Now, every time you run the command "plex-touch", regardless of your userid/sudo, it runs the command as user "plex". This works for commands owned by root, so I don't like giving super-powers willy-nilly, but there are some legitimate reasons to run commands as another user (and Linux/Unix provides this ability).


I use

sudo bash

That's simple enough!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.