
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
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"

与sudo的差异(Differences with sudo)
We can compare su
and sudo
commands like below.
我们可以像下面比较su
和sudo
命令。
su
will directly change to the root usersu
将直接更改为root用户sudo
will use current user with administrator or root privilegessudo
将使用具有管理员或root特权的当前用户su
will change user Linux environment to the rootsu
将用户Linux环境更改为rootsudo
will use current user environment after the command execution is completedsudo
将在命令执行完成后使用当前用户环境su
will requireroot
user passwordsu
将需要root
用户密码sudo
will require current user passwordsudo
将需要当前的用户密码sudo
will require the current user added tot heWHEEL
orROOT
group in the/etc/sudoers
file.sudo
将要求当前用户添加到/etc/sudoers
文件中的WHEEL
或ROOT
组。
翻译自: https://www.poftut.com/become-superuser-or-root-with-su-command-in-linux/
su命令切换到root用户