• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Why is sudo command asking for root password in Linux

    I have written two blogs earlier to help you understand sudo configuration and its function which you can follow using the below link
    How to configure passwordless sudo for a user in Linux
    How to give permission to user to run some commands in Linux

    In this blog I will try to keep my self strictly to the point of issue. You might have noticed that at times when you try to execute a command using sudo user it prompts for root password.





    Reason:

    You can see the below line in your /etc/sudoers file
    Defaults       targetpw
    [deepak@test ~]$ sudo /etc/init.d/sshd restart
    [sudo] password for root:

    As per this configuration ask for the password of the target user i.e. root.


    Solution:

    To fix this comment out this line
    # visudo
    # Defaults targetpw

    Save and exit the file

    Next try to use sudo for executing any command
    [deepak@test ~]$ sudo /etc/init.d/sshd restart
    [sudo] password for deepak:

    Follow the below links for more tutorials


    Why is sudo command asking for root password in Linux Why is sudo command asking for root password in Linux Reviewed by Deepak Prasad on Sunday, May 28, 2017 Rating: 5

    1 comment:

    1. I think this option has been changed to "Defaults !visiblepw" in RHEL6 and now it ask for user password.

      ReplyDelete

    Powered by Blogger.