Im accessing my sever over SSH, with a normal user account. At some point i need to log as root, i have the root and password credentials, but when I invoke the sudo - command the prompt ask me for a root password for the current logged user user, how can i change the username back to root?


I think you're confusing two commands: sudo and su.

sudo allows you to run a single command as another user.

su allows you to switch to another user.

So, when you've signed in as your normal user, if you want to issue a single command as root, you should use sudo:

$ sudo <command>

This will ask for your password.

Likewise, if you want to issue a command as user jimbob:

$ sudo -u jimbob <command>

This will also ask for your password.

If you want to switch to the root user:

$ su -

This will ask for the root password.

It is highly recommended that you always use sudo to run privileged commands, though, instead of switching to another user.

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.