Ubuntu 20.04 Server Enable root User Account
Posted primerplus
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu 20.04 Server Enable root User Account相关的知识,希望对你有一定的参考价值。
初始设置:启用root用户帐户
The root Account in Ubuntu is disabled by default because his password is not set. To use root priviledges, basically it‘s better to use the sudo command with administrative accounts. But if you‘d like to use root Account itself by some reason, it‘s possible to use like follows.
默认情况下,Ubuntu中的root账户是禁用的,因为未设置其密码。要想使用root特权,最好是将sudo命令与管理账户一起使用。但是,如果出于某种原因想要使用root帐户本身,则可以像下面这样使用
The user account added during installation is set an administrative account with sudo, so it‘s easy to get root account‘s shell like follows.
ubuntu@dlp:~$ sudo -s
[sudo] password for ubuntu: # input self password
root@dlp:/home/ubuntu# # just switched
Or it‘s possible to switch to root account with standard su command to set root account‘s password.
或者可以使用标准su命令切换到root帐户来设置root帐户的密码
ubuntu@dlp:~$ sudo passwd root
[sudo] password for ubuntu: # input self password
New password: # set root password
Retype new password: # confirm
passwd: password updated successfully
ubuntu@dlp:~$ su -
Password: # input root password
root@dlp:~# # just switched
The examples on this site shows by root user account. If you use sudo, add [sudo] on the head of commands.
It‘s better to restrict users who can [su] to root if you enable root account like follows. For using by sudo, it‘s possible to limit to prohibit shells in sudoers config, refer to details about sudo Settings.
For [su] command restriction, set like follows.
root@dlp:~# vi /etc/pam.d/su
# line 15: uncomment and add a group which is allow to run [su] command
auth required pam_wheel.so group=adm
# add a user you allowed to run [su] to the group you set above
# 将您允许运行[su]的用户添加到上面设置的组中
root@dlp:~# usermod -G adm ubuntu
以上是关于Ubuntu 20.04 Server Enable root User Account的主要内容,如果未能解决你的问题,请参考以下文章