How to configure sudo in linux?



  • The sudo package must be installed.

    $ /bin/rpm -qa sudo
    sudo-1.6.8p12-10
    

    As a standard user, user testuser is not able to run the parted command:

    $ /sbin/parted
    WARNING: You are not superuser.  Watch out for permissions.
    Error: No device found
    Retry/Cancel? c
    $ 
    

    To enable user testuser to run any command as root, enter the following line in the sudoers file (in the commands section):

    # /usr/sbin/visudo
    testuser        ALL=(ALL)       ALL
    

    Warning: this is not recommended as non-root users would be able to shutdown your machine, for example, and basically run any command as root. It is safer to list the commands that are allowed or exclude the commands you do not want non-priviledged users to run.

    Then, as user testuser (when prompted for a password, enter the password for user testuser):

    $ /usr/bin/sudo /sbin/parted
    
    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:
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)
    

    If you try and run a command with sudo and your user name is not allowed to use sudo, you will receive the following message:

    $ /usr/bin/sudo /sbin/parted
    Password:
    testuser is not in the sudoers file.  This incident will be reported.
    

    For more detailed options regarding sudo's configuration:

    man sudoers


Log in to reply
 

© Lightnetics 2024