Solved sudo command failed

Hello,

I install sudo command. But when to use it it failed.

Code:
[tomsserver@Toms-Server ~]$ chsh -s /bin/sh root
chsh: Permission denied
[tomsserver@Toms-Server ~]$ sudo chsh -s /bin/sh root

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
sudo: 3 incorrect password attempts
[tomsserver@Toms-Server ~]$
 
Exactly, you have installed sudo package only, without its configuration.
Log on onto the system as root or switch to super user (if you are a member of wheel group) with

su -

and then type

visudo

Press "SHIFT+G" (to go to the last line within file) and then "o" (you will start editing file one line below.
Put this entry
Code:
myUser  ALL=(ALL) ALL
where myUser is your real user name.

At the end press "SHIFT+ZZ" to save changes.
Exit super user mode or re-logon with your regular user credentials. From now sudo should work fine.

Regards,
Krzysztof
 
Thanks for the help.

I am not familiar with vi editor. Instead I installed and use nano editor. The path of sudo configure file is /usr/local/etc/sudoers

Tom
 
Don't change root's shell. Leave it set to csh(1).

But besides that, configuration is not relevant judging by the "password" errors, you get a different error message when you're not allowed to sudo(8). When you sudo(8) you need to enter your password, not the password of the account you sudo(8) to. With su(1) you need to enter the password you su(1) to.
 
No luck, the sudo command still feedback sorry message. Should I reboot?

Code:
[tomsserver@Toms-Server ~]$ sudo wget -c ## Uncomment to enable logging of a command's output, except for

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
sudo: 3 incorrect password attempts
[tomsserver@Toms-Server ~]$ sudo wget -c https://github.com/discourse/discourse/archive/master.zip /var/discourse

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:
Sorry, try again.
Password:

Below is my /usr/local/etc/sudoers file.

Code:
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!REBOOT !log_output

##
## Runas alias specification
##

##
## User privilege specification
##
root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

## Read drop-in files from /usr/local/etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /usr/local/etc/sudoers.d

tomsserver ALL=(ALL) ALL
 
You're either not typing the password correctly or you're using the wrong password. You need to enter your password, not root's password.
 
Back
Top