DevOps/Cloud By GK
  • DevOps/Cloud Introduction
  • 🚩AWS
    • Create AWS Account
    • Launch EC2 Instance
  • 🚩Linux
    • User Managment
      • Adding the User to Sudo group
      • visudo
    • Directory / File Management
      • Vi
      • Changing Permissions (chmod)
      • Filtering IO/File
    • Memory Management
    • Process Management
    • Network Management
    • Service Management
    • Environmental Variables
      • $PATH
    • Utilities
    • SHELL PROGRAMMING
      • Hello World
      • Variables
      • Command Line arguments
      • Conditional Statements
      • Array
      • Loops
      • Functions
      • AWK
      • sed
      • Example Useful Scripts
      • Basic -> Advanced
  • 🚩git
    • Introduction
    • Creating GitHub Account
    • Installation
      • Git Bash In Windows
      • Git In VS Code
      • Git In Eclipse
      • Git CLI in Linux
  • Creating Git Remote Repository
  • Git Commands L -> R
  • Git Commands L <- R
  • Git Branch Commands
  • Using SSH (Password Less)
  • 🚩maven
    • Introduction
    • Installation
    • POM.xml
    • Goals
  • 🚩SonarQube
    • Introduction
    • Sonar Cloud
    • Creating Project In SonarCloud
    • Installing Sonar-Scanner
    • Triggering Scan
  • 🚩Nexus
    • Introduction
    • Installation of Nexus
    • Creating Repository
    • Uploading Artifacts to Repository
  • 🚩Jenkins
    • Introduction
    • Installation of Jenkins
    • First Job In Jenkins
    • Git + Jenkins
      • WebHook
    • Maven + Jenkins
    • Sonar-Scanner + Jenkins
    • Nexus + Jenkins
Powered by GitBook
On this page
  1. Linux
  2. User Managment

visudo

Here's an example of how you can use visudo to grant permissions to a user:

  1. Open a terminal window.

  2. Type the following command and press Enter to open the sudoers file with visudo:

    sudo visudo

    This will prompt you to enter your password.

  3. Once the sudoers file opens in the text editor, navigate to the section that defines user privileges. It typically starts with a line similar to:

    # User privilege specification
  4. To grant permissions to a specific user, add a line in the following format:

    username    ALL=(ALL:ALL) command

    Replace username with the actual username of the user you want to grant permissions to, and replace command with the specific command or commands they should be able to execute with sudo.

    For example, let's say you want to grant the user "john" the ability to manage network settings using the ifconfig command. You would add the following line:

    john    ALL=(ALL:ALL) /sbin/ifconfig

    This grants the user "john" the ability to run the ifconfig command with sudo.

  5. Save the changes and exit the text editor. In vi, you can press Esc to exit insert mode, then type :wq and press Enter.

    Visudo will perform a syntax check, and if everything is valid, it will save the changes to the sudoers file.

Now, the user "john" should be able to execute the specified command with elevated privileges using the sudo command.

Grant ALL permissions to User

If you want to grant permission for a user to run any command with sudo, you can use the wildcard character ALL. Here's an example:

  1. Open a terminal window.

  2. Type the following command and press Enter to open the sudoers file with visudo:

    sudo visudo

    This will prompt you to enter your password.

  3. Once the sudoers file opens in the text editor, navigate to the section that defines user privileges. It typically starts with a line similar to:

    # User privilege specification
  4. To grant permission for a specific user to run any command with sudo, add a line in the following format:

    username    ALL=(ALL:ALL) ALL

    Replace username with the actual username of the user you want to grant permissions to.

    For example, if you want to grant the user "john" permission to run any command with sudo, you would add the following line:

    john    ALL=(ALL:ALL) ALL
  5. Save the changes and exit the text editor. In vi, you can press Esc to exit insert mode, then type :wq and press Enter.

    Visudo will perform a syntax check, and if everything is valid, it will save the changes to the sudoers file.

Now, the user "john" should have full sudo privileges and be able to execute any command with elevated privileges using the sudo command.

PreviousAdding the User to Sudo groupNextDirectory / File Management

Last updated 2 years ago

🚩