-2

I am a user in Oracle Linux server with sudo access. If I run su command, system prompts for password. When I input my account password, system gives message Incorrect password while I login successfully with the same password.

  • Why is it happening?
  • Need to execute su or sudo command after login if I have sudo access?
  • Need to prefix sudo with every command?
8

Why is it happening?

Because you use su with no username, su default switch to root, so you must type root's password correctly.

Need to execute su or sudo command after login if I have sudo access?

You must use sudo.

Need to prefix sudo with every command?

Yes, you should type sudo before every command which you want to run with root privilege.

Updated

What's different between su and sudo:

  • su is used to become another user, you switch to another user in your login session and do anything with switched user privilege. You must know the switched user's password to su successfully.

  • sudo is used to execute a command with another user privilege, specified by policy in /etc/sudoer file. You don't have to know another user's password to sudo to work. With sudo, you only have another user privilege in temporary time. After this time expired, you must type your password again to sudo works.

  • He/she can run sudo su. – enedil Apr 16 '14 at 6:52
  • Actually, you can just do sudo bash to get a root shell. – celtschk Apr 16 '14 at 6:52
  • If I run Sudo once just after login, will it not affect every command I execute after that? – ursitesion Apr 16 '14 at 6:57
  • @Gnouc, what is the difference between sudo and su commands? – ursitesion Apr 16 '14 at 7:00
  • @ursitesion: No, it only affects the command you give it as argument. It doesn't make "you" root, it starts a new root process for the command you use it for. – celtschk Apr 16 '14 at 7:11

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.