How to just gain root permission without running anything?
Use sudo -v
:
-v
,--validate
Update the user's cached credentials, authenticating the user if necessary.
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 side effects, like printing to the screen, etc, with sudo
. There's also the false
command, which always fails. These are both useful in shell scripting.