添加用户并授予该用户 root 权限是系统的众多任务之一 admin. 添加用户并授予 root 权限后,他们将能够登录到您的 Ubuntu VPS 并执行维护系统的重要功能。 之后,他们将能够使用 sudo 在执行提升任务的命令之前。 在本快速教程中,我们将向您展示如何添加新用户并授予 root 权限。
预检
- 这些说明专门用于在 Ubuntu 18.04 LTS 上添加用户。
- 我们将在 Liquid Web Core Managed Ubuntu 18.04 LTS 服务器上工作,我将以 root 身份登录。
第 1 步:添加用户名
在我的 example,我将添加我的猫的名字,汤姆,使用 添加用户 命令。 用您想要的用户名替换 tom。 在此期间,系统还会向我的用户询问我的详细信息。 请随意按回车键跳过这些详细信息,最终它会要求我们确认信息是否正确,从而导致我们添加了一个新用户。
adduser tom
示例输出:Adding user `tom' ...
Adding new group `tom' (1001) ...
Adding new user `tom' (1001) with group `tom' ...
Creating home directory `/home/tom' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for tom
Enter the new value, or press ENTER for the default
Full Name []: Tom
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
第 2 步:向用户授予 Root 权限
visudo
上面的命令将我们带到 /etc/sudoers.tmp 文件,我们可以在其中查看以下代码:# User privilege specification
root ALL=(ALL:ALL) ALL
在 root 用户行之后,您将添加具有相同格式的新用户以供我们授予 admin 特权。
tom ALL=(ALL:ALL)ALL
添加权限后,使用以下过程保存并退出文件。 (在 Ubuntu 18.04 中,nano 是默认的编辑器,所以我们需要使用 ctrl+x、y 键来保存和退出文件。)
hold `ctrl` and press `x`. At the prompt, press `y` and then hit `enter` to save and exit the file.
第 3 步:验证用户是否有权限
如果您正确地按照说明进行操作,那么该用户将能够运行更新等命令,使用 sudo:
su - tom
sudo apt-get update
想做 admin 通过控制面板执行任务? 查看我们随 cPanel 提供的服务器。 我们提供辅助迁移和 24/7 支持,让您轻松切换到 Liquid Web!