(转)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 ...
随机推荐
- Go基本运行编译命令解释
go run命令: 直接执行命令源码文件:一定要声明自己是在main包下,要是只有一个工作区,相应的文件就会存在bin文件下 go build: 把文件夹下的命令源码文件编译成直接运行文件,但是不能有 ...
- Android开发学习了这些,上帝都淘汰不了你
曾听过很多人说Android学习很简单,做个App就上手了,工作机会多,毕业后也比较容易找工作.这种观点可能是很多Android开发者最开始入行的原因之一. 在工作初期,工作主要是按照业务需求实现Ap ...
- php命令模式(command pattern)
... <?php /* The command pattern decouples the object that executes certain operations from objec ...
- ECHO命令输出空行的11种方法和效率
标题: 批处理技术内幕:ECHO命令作者: Demon链接: http://demon.tw/reverse/cmd-internal-echo.html版权: 本博客的所有文章,都遵守“署名-非商业 ...
- 关于__int 128 的读入与输出
inline __int128 read() { ,w=; ; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} )+(X<<)+(ch^),c ...
- test20191210 钟子谦
100+40+0=140.暴力没写满-- 简单模拟 很久很久以前,有一个 \(1\sim n\) 的排列 \(a\),还有一个长度为 \(q\) 的,每个元素在 \(1\) 到 \(n\) 之间的序列 ...
- Redis 入门知识点
1.Redis简介 1.1.简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis 与其他 key - value 缓存产品有以下三个特点: Redi ...
- 【时空大数据】Access 到 Postgres 数据迁移遇到的ODBC坑----驱动程序和应用程序之间的体系结构不匹配
1.安装Postgres10 2.安装Postgis插件 3.创建数据库 4.执行postgis脚本插件:参考https://www.cnblogs.com/defineconst/p/1064853 ...
- [译] 2017 年比较 Angular、React、Vue 三剑客
原文地址:Angular vs. React vs. Vue: A 2017 comparison 原文作者:Jens Neuhaus 译文出自:掘金翻译计划 本文永久链接:github.com/xi ...
- Type Encodings
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles ...