• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

sudo

Sudoers File Explained

June 30, 2021

You are probably wondering how the sudoers file works. Here’s a simple explanation.

Command

username host=(user:group) tag:commands

username host=(user:group) tag:commands

Explanation

    • username – the specified user allowed to run commands.
    • host – the specified host the command is allowed to run.
    • user – specifies which users can use the command.
    • group – specifies which groups can run the command.
    • tag – the option allowed. NOPASSWD
    • command – the command allowed to run.

Examples

root    ALL=(ALL) ALL
username ALL=(ALL) ALL
john test=(ALL) NOPASSWD: /bin/useradd
jane ALL=(sales) NOPASSWD: /bin/sh
%sudo ALL=(ALL) ALL
%adgroup ALL=(ALL) ALL

root ALL=(ALL) ALL username ALL=(ALL) ALL john test=(ALL) NOPASSWD: /bin/useradd jane ALL=(sales) NOPASSWD: /bin/sh %sudo ALL=(ALL) ALL %adgroup ALL=(ALL) ALL

Filed Under: Linux Tagged With: access, root, sudo, sudoers

Remove Sudo Password

July 28, 2020

Removing sudo password is typically not a good practice. If you’re a seasoned system administrator, or you’re the only one using your own desktop, being prompted for a sudo password can get really annoying. Here’s how to stop getting prompted every time you run sudo.

Run visudo.

sudo visudo

sudo visudo

Edit the sudo line and set to below.

%sudo ALL=(ALL) NOPASSWD: ALL

%sudo ALL=(ALL) NOPASSWD: ALL

Save file.

Filed Under: Linux Tagged With: nopasswd, password, prompt, remove, sudo, vim

Wheel Group

February 25, 2020

Here’s an alternate way to give Linux users sudo access by adding them to the wheel group. Most Linux systems come with the wheel group already predefined. By adding users to the wheel group, they now have the ability to sudo and run root commands. The wheel group is in the sudoers file for Redhat, Centos, Debian and Ubuntu.

usermod -aG wheel username

usermod -aG wheel username

Filed Under: Linux Tagged With: add, group, sudo, sudoers, usermod, wheel

Sudoers Directory

April 8, 2019

What’s in the /etc/sudoers.d/ directory? It’s a group of files with the following format as displayed in the code below. In the example, the file allows a Linux group or an AD group to assume the role of root, via the sudo command. As long as the group uses the correct format, and is located inside the /etc/sudoers.d/ directory, that group will have access to root.

%groupname  ALL=(ALL)   NOPASSWD: ALL

%groupname ALL=(ALL) NOPASSWD: ALL

Filed Under: Linux Tagged With: sudo, sudoers

Run Docker Without Sudo

February 10, 2019

Run Docker without sudo. Add user to docker group. Login as docker using newgrp.

sudo gpasswd -a $user docker
newgrp docker

sudo gpasswd -a $user docker newgrp docker

You can now run the following commands without sudo.

docker ps
docker images

docker ps docker images

Every time you open a new terminal , just run.

newgrp docker

newgrp docker

Filed Under: Linux Tagged With: docker, sudo, without

  • Home
  • About
  • Archives

Copyright © 2023