linux怎么修改passwd文件,linux 普通用户修改passwd文件

今天一台服务器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功能差不多

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值