su命令切换到root用户_如何在Linux中使用su命令成为超级用户或root?

su命令切换到root用户

su命令切换到root用户

Linux provides root account as superuser or Administrator. As root account has all privileges to manage a system this may be a threat for misuse or error of administrators. We generally use normal user accounts in daily operation and change to the superuser with su  command.

Linux提供root帐户作为超级用户或管理员。 由于root帐户具有管理系统的所有特权,因此这可能会导致管理员滥用或错误的威胁。 我们通常在日常操作中使用普通用户帐户,并通过su命令更改为超级用户。

(Root)

root exist all Linux systems and can not be deleted because of Linux privileges administration logic. root user has special home directory located /root and other users can not read write or execute in normal situation.

root存在于所有Linux系统中,由于Linux特权管理逻辑而无法删除。 root用户具有位于/root特殊主目录,其他用户在正常情况下不能读写或执行。

超级用户命令Su (SuperUser Command Su)

Some times we need to change superuser complete system related jobs. There are alternative and more secure way like using sudo command which is short for of super user do . We have allready examined this sudo command in the following tutorial.

有时我们需要更改与超级用户完整的系统相关的工作。 还有其他更安全的方式,例如使用sudo命令,这是超级用户do的缩写。 我们已经在以下教程中检查了此sudo命令。

Linux Sudo Command Tutorial with Examples To Get Root Privileges

Linux Sudo命令教程,并附有获得根特权的示例

su command will ask for root user password in order to become root user.

su命令将要求root用户密码才能成为root用户。

$ su

以超级用户身份运行单个命令 (Run Single Command As Super User)

We have the option to run single command as super user by using -c option and the command. In this example we will run mkdir /etc/test command as root user in order to complete command successfully.

我们可以选择使用-c选项和命令以超级用户身份运行单个命令。 在此示例中,我们将以root用户身份运行mkdir /etc/test命令,以成功完成命令。

$ su -c "mkdir /etc/test"
Run Single Command As Super User
Run Single Command As Super User
以超级用户身份运行单个命令

与sudo的差异(Differences with sudo)

We can compare su and sudo commands like below.

我们可以像下面比较susudo命令。

  • su will directly change to the root user

    su将直接更改为root用户

  • sudo will use current user with administrator or root privileges

    sudo将使用具有管理员或root特权的当前用户

  • su will change user Linux environment to the root

    su将用户Linux环境更改为root

  • sudo will use current user environment after the command execution is completed

    sudo将在命令执行完成后使用当前用户环境

  • su will require root user password

    su将需要root用户密码

  • sudo will require current user password

    sudo将需要当前的用户密码

  • sudo will require the current user added tot he WHEEL or ROOT group in the /etc/sudoers file.

    sudo将要求当前用户添加到/etc/sudoers文件中的WHEELROOT组。

LEARN MORE  Linux Sudo Command Tutorial with Examples To Get Root Privileges
了解更多Linux Sudo命令教程,并附带示例以获取root特权

翻译自: https://www.poftut.com/become-superuser-or-root-with-su-command-in-linux/

su命令切换到root用户

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值