0

I am using Centos and want to use sudo command to run as root. But after input the root password, it always prompt to ask me input the password again. I am pretty sure the password is correct since I am able to su - to switch to root then run the command. But I can't run the command by sudo. What wrong with it? Whether I need to configure anything?

Below is an example when I run sudo ls command. I am pretty sure that I have input the correct password.

$ sudo ls
[sudo] password for cooltoo: 
Sorry, try again.
[sudo] password for cooltoo: 
Sorry, try again.
[sudo] password for cooltoo
1
  • It does not prompt you for the root password. It prompts you for the password of user cooltoo
    – Anthon
    May 3, 2016 at 11:18

2 Answers 2

2

sudo wants your password in your case user cooltoo's password, not the root password.

Update

You don't need to be root every time you want to run some specific administrative tasks. Thanks to sudo, you can run some or every command as root. Once sudo is installed (package name: sudo), you can configure it by running visudo as root. Basically, it runs $EDITOR (vim as default) on /etc/sudoers, but it is not recommended to do it manually. If you are on a desktop computer, you will want to be able to do almost everything.

So, the quick and dirty way to use sudo would be to add at the end of the sudoers file :

$su -          # Enter root Password here
$visudo   

# append below line at the end of file and save the file
cooltoo    ALL=(ALL)       ALL    
2
  • why it asks for my password instead of root password? When I give my password, I got "Sorry, user cooltoo is not allowed to execute '/bin/ls' as root on Cool-Too". How can I allow the current user to run sudo for any commands May 3, 2016 at 9:24
  • @ZhaoYi see my updated answer
    – Rahul
    May 3, 2016 at 9:31
0

Have you added yourself to the sudoers group by amending the /etc/sudoers file?

See: https://wiki.centos.org/TipsAndTricks/BecomingRoot

Not the answer you're looking for? Browse other questions tagged .