歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 服務器root用戶登錄不了 linux普通用戶如何修改passwd文件

服務器root用戶登錄不了 linux普通用戶如何修改passwd文件

日期:2017/3/3 16:00:28   编辑:關於Linux

今天一台服務器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可以登錄了。

本文URL:http://www.bianceng.cn/OS/Linux/201410/45602.htm

#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

Copyright © Linux教程網 All Rights Reserved