Linux su和sudo的区别

首先通过man 对两条命令查看

man su

SU(1)                            User Commands                           SU(1)
                                    用户命令

NAME

       su - run a shell with substitute user and group IDs

      使用替换用户和组id来运行shell。

Change the effective user id and group id to that of USER.(将有效的用户id和组id更改为USER。)

man sudo

SUDO(8)                   BSD System Manager’s Manual                  SUDO(8)
                                BSD系统管理手册
NAME

     sudo, sudoedit - execute a command as another user

     sudo,sudoedit—执行作为另一个用户的命令

sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.(sudo允许允许用户按照安全策略指定的超级用户或其他用户执行命令。)

其实两者都可以对当前用户进行切换。

su 需要输入的密码是你将切换后的账户的密码。

su -账户名,可以任意切换到你所需要的账户。不写账户名,默认切换到root。

sudo 需要输入的密码是你当前正在使用的账户的密码。它能暂时获得root用户权限,但有时间限制。所以我们也称sudo 是受限制的su 。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值