Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Setup Sudo Privileges for User in Linux

    How to Setup Sudo Privileges for User in Linux

    By RahulDecember 27, 20192 Mins Read

    Sudo is used for providing access to root (Super admin) commands to non-root users. For example, As an administrator, you want to provide access to restart the webserver to user nick, but he cannot make any changes to its configuration. You can provide sudo access to user nick to do it.

    Advertisement

    To edit sudo configuration file use:

    visudo
    

    The above command will open /etc/sudoers file in an editor. This file is the main configuration file for sudo settings. In the sudoers file, you will get an entry like below. This provides privileges to root user to do anything.

    root ALL=(ALL) ALL
    

    Sudores File Syntax

    The format of /etc/sudores is as below

    user  host:runas  command
    
    • user – Name of user, Use % sign to specify a group name like %webadmins
    • host – Computer hostnames
    • runas – User for run as, common options are used root or ALL
    • command – One or more root level command

    Provide Access to User

    Now if you want to provide web server reboot privileges to user nick, add below configuration in the sudoers file

    nick  ALL=(root) NOPASSWD: /etc/init.d/httpd restart
    

    NOPASSWD means no verification is required if you leave this out, nick will have to re-enter his own password. Now user nick can restart web server using following command.

    sudo /etc/init.d/httpd restart
    

    Provide Access to Group

    To provide access to the superuser commands to a group of users. Define the group name started with the % symbol. As per the below example, all the users with group webadmin will have the privilege to execute the command.

    %webadmin ALL=(root) /etc/init.d/httpd restart
    

    sudo sudores visudo
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    An Introduction to the “./configure” Command: Compiling Source Code in Linux

    Getting Started with Linux Command line: The Beginning

    Backing Up Your Linux System with Rsync: A Step-by-Step Guide

    View 2 Comments

    2 Comments

    1. LLC Texas on October 8, 2018 1:42 am

      Hi! Would you mind if I share your blog with my facebook group?
      There’s a lot of folks that I think would really appreciate
      your content. Please let me know. Thank you

      Reply
    2. www.hskingstone.com on June 9, 2013 5:50 am

      Heya i am for the first time here. I came across this board and I find It really useful & it helped
      me out a lot. I hope to give something back and help
      others like you aided me.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • 11 Practical Example of cat Command in Linux
    • sleep Command in Linux with Examples
    • 20 Basic Linux Commands for the Beginners (Recommended)
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.