add new user tom

useradd -m -p 12345 -s /bin/bash -G wheel tom

switch user from root to tom

su tom

and tom cannot use sudo, even I type right password.

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.

enter image description here

%wheel (ALL)=(ALL) ALL

/etc/pam.s/su uncommented
auth required pam_wheel.so

$ groups
tom wheel
  • Welcome. The error in your image is wrong password – schrodigerscatcuriosity Aug 31 '19 at 14:59
  • @guillermochamorro password is right – thomasz Aug 31 '19 at 15:07
  • The sudo error when you have no privileges is <user> is not in the sudoers file. This incident will be reported. – schrodigerscatcuriosity Aug 31 '19 at 15:09
  • Try logging out the user and log in again and then try sudo. – Abhik Bose Aug 31 '19 at 19:16

From man useradd (8):

-p, --password PASSWORD
     The encrypted password, as returned by crypt(3). The default is to disable the password.

Look into /etc/shadow and you will see that the encrypted password is 12345. So it's no wonder that your password is wrong.

You can change the password as root with

passwd tom

and it should work.

  • thank you. it works – thomasz Aug 31 '19 at 15:41

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.