代码改变世界

ubuntu默认root密码是什么?

2013-04-07 21:26  youxin  阅读(5416)  评论(0编辑  收藏  举报

安装ubuntu后你用su 命令会发现密码始终不对,是因为root还没有密码,你需要设置root密码才能使用它。

第一个 user 是在 admin 组 ,所以他可以给 root 设置密码 , so ... 

sudo passwd root 
[sudo] password for you :---> 输入你的密码,不回显 
Enter new UNIX password: --- > 设置root 密码 
Retype new UNIX password: --> 重复

然后,你试着 su,再输入刚才的密码,你会发现ok了,成了root。root@ubuntums:~#

切换跟用户su - 或 su root 

官方答案:

The root account is disabled when you first install Ubuntu. The first user created during the installation has administrative rights on the system, and can run programs as root with sudo, using only their normal user password. For example: sudo apt-get update. 
If you wish to use the root account in more traditional UNIX fashion, you can set the root password by typing sudo passwd root. This will allow you to use su or login as root on the console. 
If you need a shell with root privileges, run sudo -s. 
All uses of sudo will require the user's password.

 切换用户

用法:su  用户名

如:su  user1

其中,user1是系统中存在的用户

注意:切换前必须确保user1有合法密码,并且当前用户知道该密码!

若user1当前没有密码,则可以用以下命令添加密码:sudo passwd user1

之后输入相应密码即可为user1设置密码。