(转)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 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的更多相关文章
- 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 ...
随机推荐
- 转载_fread函数详解
fread函数详解 函数原型: size_t fread( void *buffer, size_t size, size_t count, FILE *strea ...
- Ubuntu 18.10 安装之后做的一点事
sb_release -c //查看系统代号 #更新源/etc/apt/sources.list //打开更新目录 deb https://linux.xidian.edu.cn/mirrors/ub ...
- Hibernate各种状态(瞬时状态、持久化状态、游离|托管状态)之间的转换
- Beta冲刺(6/7)——2019.5.27
所属课程 软件工程1916|W(福州大学) 作业要求 Beta冲刺(6/7)--2019.5.27 团队名称 待就业六人组 1.团队信息 团队名称:待就业六人组 团队描述:同舟共济扬帆起,乘风破浪万里 ...
- Zipkin 知识点
在Spring Cloud D版本,zipkin-server通过引入依赖的方式构建工程,自从E版本之后,这一方式改变了,采用官方的jar形式启动. 出处:https://juejin.im/post ...
- STL str replace
#include <iostream> #include <string> using namespace std; void main() { string s=" ...
- 最后一个对象属性后边不要加豆号的bug,血淋淋的教训啊,模块化开发IE7下的严重错误,养成好习惯
最近总是写滚动图效果,重复的劳动后,决定写一个滚动图的封装插件.结果写完后在其他浏览器都可以用,却IE7下毫无反应.反复测试各种检查后,发现竟然是在参数对象最后一个属性后多加了个逗号,结果就死在了IE ...
- Java-Modifier类常用方法详解
一.Modifier类的定义 Modifier类 (修饰符工具类) 位于 java.lang.reflect 包中,用于判断和获取某个类.变量或方法的修饰符Modifier类将各个修饰符表示为相对应的 ...
- 设置web应用的 context root (转)-- web project setting
context root确定了Tomcat将那些URL请求转发到Web应用. 如果应用的context root 设置为 myapp,除非存在更为明确context root的Web应用,那么所有 / ...
- pkusc2019游记
Day0 早上 6:55 的高铁,6 点就起了,好困呜呜呜 去的路上跟 memset0 坐一起,突然发现雀魂还没停服,先雀了一局(居然拿了个 1 位还飞了一个人),与此同时 memset0 切了一道毒 ...