(转)How To Create a Sudo User on Ubuntu
转自: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 username
with 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的更多相关文章
- 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 ...
- Create & use FTP service on Ubuntu(在Ubuntu上搭建并使用FTP服务)
Check if the FTP service has been installed.(检查是否已安装) Vsftpd --version If it has not install,Pres ...
- linux学习: sudo命令(ubuntu)
使用 sudo 命令可以提高命令的执行权限,以root权限执行 如 : sudo vi xxx 但是有些内置命令 如 cd 无法通过 sudo来执行 ,如 sudo cd xxx 这是会报错的. ...
- Linux服务器新建用户和组,并分配sudo权限 (Ubuntu系统)
新拿到一台服务器后我们一般都是要新建用户组,用户,并为其分配权限. ==================================================== 赋予用户组sudo权限: ...
- ubuntu创建sudo 用户
The sudo command provides a mechanism for granting administrator privileges, ordinarily only availab ...
- 【linux】linux创建用户并授予sudo权限
1. 新建用户 root@ubuntu:~# adduser hadoop root@ubuntu:~# passwd hadoop #为hadoop用户设置密码 2. 为hadoop用户添加sudo ...
- unbuntu下的root 用户和 sudo 命令
参考: http://james23dier.iteye.com/blog/721246 http://blog.csdn.net/shichexixi/article/details/5969993 ...
- 【新技术】Docker 学习笔记
原文地址 一.Docker 简介 Docker 两个主要部件: Docker: 开源的容器虚拟化平台 Docker Hub: 用于分享.管理 Docker 容器的 Docker SaaS 平台 -- ...
- 导出本地和远程SVN项目, Export remote SVN repository
在有服务器控制权的情况下, 源服务器上 sudo svnadmin dump ironbank/ > ~/ironbank.svn.dump 在目的服务器上 sudo svnadmin crea ...
随机推荐
- Python 基础-> 字符串,数字,变量
Python 基础:字符串,数字,变量 1. 字符串 (信息的一种表达方式) a. 使用引号创建字符串 b. 单引号,双引号,三引号: ', ", ''', ""&quo ...
- idea忽略.iml文件
.iml 和 eclipse中的.classpath,.project都属于开发工具配置文件, 也就是在项目导入ide的过程中生成的配置文件,每个人开发环境是不一样的,所以这个文件没必要提交. 而且如 ...
- Nuxt.js 提供了两种发布部署应用的方式:服务端渲染应用部署 和 静态应用部署
官方网址:https://zh.nuxtjs.org/guide/commands/#%E5%8F%91%E5%B8%83%E9%83%A8%E7%BD%B2
- 三大框架整合(hibernate-spring-struts2)
三大框架整合说明 一.导包---41个包 二.单独配置spring容器---applicationContext.xml (1)导入约束(beans|context|aop|tx) (2)写数据库读取 ...
- wordpress站点更换域名了如何快速设置
有时我们的wordpress站点因为各种原因需要更换域名了,如何快速设置让网站直接用新域名而不受影响呢?比如旧域名是a.com,新域名为b.com,下面这段sql代码很有用 UPDATE wp_opt ...
- Ofbiz项目学习——阶段性小结——删除数据
一.根据主键进行删除 /** * 按主键进行删除 * @param dctx * @param context * @return */ public static Map<String,Obj ...
- SpringBoot 过滤器, 拦截器, 监听器 对比及使用场景
1. 过滤器 (实现 javax.servlet.Filter 接口) ① 过滤器是在web应用启动的时候初始化一次, 在web应用停止的时候销毁. ② 可以对请求的URL进行过滤, 对敏感词过滤, ...
- log4j2 配置文件解读
1.日志相关介绍 日志接口(slf4j):slf4j是对所有日志框架制定的一种规范.标准.接口,并不是一个框架的具体的实现,因为接口并不能独立使用,需要和具体的日志框架实现配合使用,比如log4j.l ...
- js 对小数进行格式化(保留小数,去除小数后的0)
// 如果去零时需要保留位数: (比如 19.520100 --> 19.52) parseFloat(Number(19.520100).toFixed(2)) // 如果只想去除小数点后多余 ...
- shell习题训练
shell习题训练 求2个数之和 计算1-100的和 将一目录下所有的文件的扩展名改为bak 编译当前目录下的所有.c文件: 打印root可以使用可执行文件数,处理结果: root's bins: 2 ...