转自:https://linuxize.com/post/how-to-create-a-sudo-user-on-ubuntu/


The sudo command is designed to allow users to run programs with the security privileges of another user, by default the root user.

In this guide, we will show you how to create a new user on an Ubuntu machine and give it sudo access. You can then use this user account to execute administrative commands without a need to logging in to your Ubuntu server as a root user.

Steps to create a sudo user

Follow the steps below to create a new user account and give it sudo access. If you want to configure sudo for an existing user, skip to step 3.

1. Log in to your server.

Log in to your system as the root user:

ssh root@server_ip_address

Copy

2. Create a new user account.

Create a new user account using the adduser command. Don’t forget to replace usernamewith the user name that you want to create:

adduser username

Copy

You will be prompted to set and confirm the new user password. Make sure that the password for the new account is as strong as possible.

Adding user `username' ...
Adding new group `username' (1001) ...
Adding new user `username' (1001) with group `username' ...
Creating home directory `/home/username' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

Copy

Once you set the password the command will create a home directory for the user, copy several configuration files in the home directory and prompts you to set the new user’s information. If you want to leave all of this information blank just press ENTER to accept the defaults.

Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]

Copy

3. Add the new user to the sudo group

By default on Ubuntu systems, members of the group sudo are granted with sudo access. To add the user you created to the sudo group use the usermod command:

usermod -aG sudo username

Copy

 

Test the sudo access

Switch to the newly created user:

su - username

Copy

Use the sudo command to run the whoami command:

sudo whoami

Copy

Is the user have sudo access then the output of the whoami command will be root:

root

Copy

How to use sudo

To use sudo, simply prefix the command with sudo and space:

sudo ls -l /root

Copy

The first time you use sudo in a session, you will be prompted to enter the user password:

[sudo] password for username:

Copy

Conclusion

You have learned how to create a user with sudo privileges. You can now log in to your Ubuntu server with this user account and use sudo to run administrative commands.

That’s all! Feel free to leave a comment if you have any questions.

(转)How To Create a Sudo User on Ubuntu的更多相关文章

  1. How to create a PPPoE Server on Ubuntu? (Untested)

    How to create a PPPoE Server on Ubuntu? March 30, 2011 coder_commenter Leave a comment Go to comment ...

  2. Create & use FTP service on Ubuntu(在Ubuntu上搭建并使用FTP服务)

    Check if the FTP service has been installed.(检查是否已安装)   Vsftpd --version  If it has not install,Pres ...

  3. linux学习: sudo命令(ubuntu)

    使用 sudo 命令可以提高命令的执行权限,以root权限执行 如 :  sudo vi xxx 但是有些内置命令 如 cd 无法通过 sudo来执行 ,如  sudo cd xxx 这是会报错的. ...

  4. Linux服务器新建用户和组,并分配sudo权限 (Ubuntu系统)

    新拿到一台服务器后我们一般都是要新建用户组,用户,并为其分配权限. ==================================================== 赋予用户组sudo权限: ...

  5. ubuntu创建sudo 用户

    The sudo command provides a mechanism for granting administrator privileges, ordinarily only availab ...

  6. 【linux】linux创建用户并授予sudo权限

    1. 新建用户 root@ubuntu:~# adduser hadoop root@ubuntu:~# passwd hadoop #为hadoop用户设置密码 2. 为hadoop用户添加sudo ...

  7. unbuntu下的root 用户和 sudo 命令

    参考: http://james23dier.iteye.com/blog/721246 http://blog.csdn.net/shichexixi/article/details/5969993 ...

  8. 【新技术】Docker 学习笔记

    原文地址 一.Docker 简介 Docker 两个主要部件: Docker: 开源的容器虚拟化平台 Docker Hub: 用于分享.管理 Docker 容器的 Docker SaaS 平台 --  ...

  9. 导出本地和远程SVN项目, Export remote SVN repository

    在有服务器控制权的情况下, 源服务器上 sudo svnadmin dump ironbank/ > ~/ironbank.svn.dump 在目的服务器上 sudo svnadmin crea ...

随机推荐

  1. Httpd服务入门知识-Httpd服务常见配置案例之基于用户账号实现访问控制

    Httpd服务入门知识-Httpd服务常见配置案例之基于用户账号实现访问控制 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.基于用户的访问控制概述 认证质询: WWW-Auth ...

  2. pandas用法总结

    pandas用法总结 2018年06月07日 10:49:03 一夜了 阅读数 38705更多 分类专栏: 杂项   一.生成数据表 1.首先导入pandas库,一般都会用到numpy库,所以我们先导 ...

  3. mysql免安装版配置和一些常见问题

    博客原文点我 今天在Windows Server 2003下安装mysql,遇到不少问题.之前在另外两台服务器安装的时候也遇到了几个问题,最后找到不少文章解决了,记录一下. 所有版本都是免安装的32和 ...

  4. [图解]Windows下使用Zend Studio 10和XAMPP 1.8搭建开发环境,ZendFramework 2 HelloWorld

    1.下载并安装 ZendStudio,搜一个破解版 XAMPP,官网下载:https://www.apachefriends.org/index.html 2.打开ZendStudio新建一个php项 ...

  5. del_deploy.core.prefs.bat

    cd /d "D:\Workspaces\MyEclipse 10" del ".metadata\.plugins\org.eclipse.core.runtime\. ...

  6. IE浏览器兼容性问题输出

    1.时间函数 var startTime=new Date(a); var endTime=new Date(b); 如果a,b的时间格式是:“2017-08-01,需要将格式转换成“2017/08/ ...

  7. .net core 原生支持grpc

    文章转自:https://grpc.io/blog/grpc-on-dotnetcore This is a guest post by Sourabh Shirhatti, a Program Ma ...

  8. cogs 997. [東方S2] 射命丸文

    二次联通门 : cogs 997. [東方S2] 射命丸文 /* cogs 997. [東方S2] 射命丸文 二维前缀和 枚举每个子矩阵 更新最大值.. 莫名rank1 */ #include < ...

  9. gitlab 从古老的 bitnami 版本 迁移到官方最新版本

    这是我之前发布在 yuque 的文章.是我刚来新公司的时候帮公司搬迁 git 记录下来的,现在看来去掉敏感部分直接发布也没啥问题啦,就搬家过来,我自己也方便查 XD . 8.1.6 -> 10. ...

  10. 【POJ1416】Shredding Company

    本题传送门 本题知识点:深度优先搜索 + 回溯 本题题意很简单,就是有一条位数不超过6的数字纸条,问你怎么剪这纸条,使得得到的纸条的值的总和最接近目标值(总和不能超过目标值). 比如第一个样例 50 ...