Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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