In today’s tutorial, we are going to see how you can add a user to sudoers on Debian distributions.

The sudo command allows authorized users to perform commands as another user, which is by default the root user.

There are two ways to add a user to sudoers : you can add this user to the sudo group or you can add this user to the sudoers file located at etc.

Here are the details of the two methods.

I – Adding an existing user to the sudo group

As a prerequisites, make sure that the sudo command is available by default. If it’s not the case, you can install it by running (with an account with admin rights)

 
$ apt-get update
$ apt-get install sudo

The first method is to add the user to the sudo group.

To do that, you are going to use the “usermod” command with the capital G flag (for groups)

$ sudo usermod -a -G sudo user

You can also use the gpasswd command to grand sudo rights.

$ sudo gpasswd -a bob sudo
Adding user to the group sudo

Make sure that the user belongs to the sudo group with the groups command.

$ su - user
(password for user) $ groups
user sudo

You should now be able to perform a sudo request on Debian 10.

 

Depending on the configuration you chose during your Debian 10 installation process, you may or may not have access to a root account. If you chose a password for your root account, you will be able to connect to it. Otherwise, the default admin account is the one you created during the installation process.

II – Adding an existing user to the sudoers file

The sudoers file is located at /etc/sudoers.

This file contains a set of rules that are applied to determine who has sudo rights on a system, which commands they can execute with sudo privileges, and if they should be prompted a password or not.

However, you should never modify the sudoers file with a text editor.

Saving a bad sudoers may leave you with the impossibility of getting sudo rights ever again.

 

Instead, you are going to use visudo, a tool designed to make sure you don’t do any mistakes.

$ sudo visudo

This is what you should see.

At the end of the file, add a new line for the user.

$ john       ALL=(ALL:ALL) ALL

By default, the account password will be asked every five minutes to perform sudo operations.

However, if you want to remove this password verification, you can set the NOPASSWD option.

$ john       ALL=(ALL:ALL) NOPASSWD:ALL

If you want the password verification to be skipped for longer periods of time, you can overwrite the timestamp_timeout (in minutes) parameter in your sudoers file.

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
# Defaults env_reset
Defaults mail_badpass
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Defaults timestamp_timeout=30

III – Adding a group to the sudoers file

Via the visudo, you can add an entire group to the sudoers.

This might be handy if you have a group for system administrators for example. In this case, you simply have to add a user to the system administrators group for him/her to be granted sudo privileges.

 

To add a group to the sudoers file, simply add a percent symbol at the beginning of the file.

$ %sysadmins       ALL=(ALL:ALL) NOPASSWD:ALL

Make sure that your user is part of the designed group with the groups command.

$ su - user
$ groups
user sysadmins

You can test your new sudo rights by changing your password for example

$ sudo passwd

IV – Most Common Errors

  • user is not in the sudoers file. This incident will be reported.

This is the standard error message you get when a user does not belong to the sudo group on Debian 10.

 

By adding this user to the sudoers file on Debian, this error message should not be raised anymore.

How To Add User To Sudoers On Debian 10 Buster的更多相关文章

  1. How to Set Up a NFS Server on Debian 10 Buster

    How to Set Up a NFS Server on Debian 10 Buster Nick Congleton Debian 24 May 2019   Contents 1. Softw ...

  2. 【转贴】Debian 10 "buster" 正式发布

    Debian 10 "buster" 正式发布 https://news.cnblogs.com/n/627909/ 我看到龙芯的 就是 mips64el 的指令集.. Linux ...

  3. debian 10 "Buster"正式发布了

    Debian Buster将从内核4.9.0.3升级到4.19.0-4.

  4. 用开源软件TrinityCore在Debian 10上搭建魔兽世界8.3.0.34220的服务器

    用开源软件TrinityCore在Debian 10上搭建魔兽世界8.3.0.34220的服务器 TrinityCore是魔兽世界(World of Warcraft)的开源的服务端.目前支持魔兽的3 ...

  5. Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10快速开启BBR加速 或 关闭BBR加速

    如果使用的是Debian 9.Debian 10.Ubuntu 18.04.Ubuntu 18.10等内核高于4.9版本的系统,均可以使用此方法开启BBR加速,若你使用了Ubuntu 19.04的系统 ...

  6. debian 10安装英伟达独显驱动

    我的显卡是GTX1050TI,刚安装好Debian 10的时候启动会黑屏,无法进入系统,解决办法是在grub界面,按e修改启动参数,在启动参数那一行(一般会包含quiet)后面加上 nouveau.m ...

  7. Debian 10 xfce 错误提示 ACCESS DENIED

    闲来无事重新安装自己的服务器发现很多关于Debian的初始安装问题都已经陌生了在此重新整理下自己安装所遇到的问题: ACCESS DENIED  释: 登录成功拒绝Root密码访问 解决方法: loc ...

  8. debian 10 安装fcitx 后设置

    设置好代理后 apt-get install fcitx 后 仍然看不到 语言栏 可能是 在设置fcitx时 的字体太小了 输入法配置 ->外观->字体 加大 即可

  9. Debian 10 或Ubuntu 安装后启动黑屏解决办法

    对于双显卡设备,很有可能是开源显卡驱动异常导致无法启动,在启动参数那一行加上 nouveau.modeset=0 禁用nouveau驱动即可进入系统

随机推荐

  1. 有关同时进行两条线路的四维dp

    今天发现自己完全对这种dp没有思路……我果然太蒻了./落泪.jpg 对于一个N*N的方格图中选择两条线路从左上角到右下角,其实只要用一个数组f[i][j][p][q]记录一个人走到(i,j)另一个人走 ...

  2. centos7 为使用su命令的用户添加pam授权认证

    # 查看用户所属哪个组 groups 用户名 #查看当前有哪些用户运行程序 ps -aux|awk '{print $1}'|sort -rn|uniq -c|sort -rn # 清理不再使用的用户 ...

  3. 二十四、V4L2框架主要结构体分析和虚拟摄像头驱动编写

    一.V4L2框架主要结构体分析 V4L2(video for linux version 2),是内核中视频设备的驱动框架,为上层访问视频设备提供统一接口. V4L2整体框架如下图: 图中主要包括两层 ...

  4. hadoop 批量处理脚本编写

    编写shell脚本就是解决批量处理 1. 在/usr/local/bin 创建脚本 并授权所有用户 chmod a+x  xcall.sh xcall.sh 比如:删除/tmp/*所有文件   批量删 ...

  5. dotnet Core学习之旅(二):安装IDE

    [重要:文中所有外链不能确保永久有效] >开发工具 高效的开发必然需要一个优秀的集成开发环境(IDE) 对于.NET Core 2.x可以使用包括但不限于以下IDE来进行开发. Visual S ...

  6. OOM与StackOverFlow发生的原因及解决办法【待完成】

    1,Out Of Memery 内存耗尽 1,1 产生原因 1.1.1 内存用完[堆内存] package com.cnblogs.mufasa; import org.junit.Test; imp ...

  7. C#委托,匿名方法,Lambda,泛型委托,表达式树代码示例

    第一分钟:委托 有些教材,博客说到委托都会提到事件,虽然事件是委托的一个实例,但是为了理解起来更简单,今天只谈委托不谈事件.先上一段代码: 下边的代码,完成了一个委托应用的演示.一个委托分三个步骤: ...

  8. navigator(浏览器对象)Screen对象(屏幕)

    浅谈navigator对象: 注意:不是所有浏览器都支持 .cookieEnabled  判断是否启用了cookie  在客户端硬盘持久保存用户私密数据的小文件 .plugins 浏览器安装的所有插件 ...

  9. JavaScript内置一些方法的实现原理--new关键字,call/apply/bind方法--前戏

    new关键字,call/apply/bind方法都和this的绑定有关,在学习之前,首先要理解this. 一起来学习一下this吧 首先.this是一个对象. 对象很好理解,引用类型值,可以实现如th ...

  10. Android 在同一台设备上安装多个同一项目的apk

    如果设备上已经安装了一个apk,再次安装这个apk就会提示覆盖前面的应用 解决办法: 方法一:手动改包名 不好改,改了几次都不成功(可能是代码在svn管理的原因,改完后文件夹里的代码就没了),确实不实 ...