进入单用户模式:
按shift进入 1、开机到grub时,用上下键移到第二行的恢复模式,按e(注意不是回车) 即Ubuntu,With Linux 3.2.0-23-generic(recovery mode) 2、把ro recovery nomodeset 改成rw single init=/bin/bash
然后按ctrl+x 就可以进入 单用户模式。 修改主机名时要用到。
在单用户模式下,输入命令
usermod -l new_username -d /home/new_username -m old_username
-l 指定新的登录名称;
-d 指定新的主目录;
-m 移动原来用户主目录的内容到新用户主目录中,与-d结合使用。