sudo passwd root
显示
Enter new UNIX password:
设置root用户密码,终端显示
Retype new UNIX password:
再输入一遍,显示
passwd: password updated successfully
表示root用户成功创建并设置密码
验证:输入su,终端显示password,输入刚刚设置的root密码,没有错误提示,并且#即代表当前用户有root权限
在ubuntu系统中,默认是不开启ssh使用root用户登陆的,在/etc/ssh/sshd_config配置文件中如下配置:
# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
很多时候需要允许root用户登陆,需要将PermitRootLogin without-password修改为PermitRootLogin yes.然后重启ssh,sudo service ssh restart.这样就可以使用root用户登陆了