今天一台服务器root用户登录不了,普通用户可以登录。
普通用户su到root用户也报错
su: bash: No such file or directory

查看下passwd文件
oracle@linux-35:~> cat /etc/passwd|grep root
root:x:0:0:root:/root:cd

root的shell竟然被人改成cd了,难怪报上面的错。
直接用oracle用户修改passwd文件还不行,没有修改权限。
所以我们得用sudoedit

oracle@linux-38:/etc> sudoedit
usage: sudoedit [-HPSb] [-p prompt] [-u username|#uid] file [...]
oracle@linux-38:/etc> sudoedit passwd

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

root's password:


root:x:0:0:root:/root:cd
改为
root:x:0:0:root:/root:/bin/bash

保存退出。

oracle@linux-35:/etc> su - root
Password:
linux-35:~ #

root可以登录了。

 


#sudo             sudo 是通过另一个用户来执行命令(execute a command as another user),su 是用来切换用户,然后通过切换到的用户来完成相应的任务,但sudo 能后面直接执行命令,比如sudo 不需要root 密码就可以执行root 赋与的执行只有root才能执行相应的命令;但得通过visudo 来编辑/etc/sudoers来实现;
#sudoedit        和sudo功能差不多

sudo详细请查看
 http://zxf261.blog.51cto.com/701797/748756