首页 > 编程知识 正文

linux su无法切换root用户,su切换用户执行命令

时间:2023-05-03 16:06:45 阅读:189905 作者:3958

su命令切换到根用户

linuxprovidesrootaccountassuperuseroradministrator.asrootaccounthasallprivilegestomanageasystemthismaybeathreatformisuseorerereatformisusususssesesestoratoreaton nerallyusenormaluseraccountsindailyoperationandchangetothesuperuserwithsucommand。

Linux以超级用户或管理员身份提供root帐户。 root帐户具有管理系统的所有权限,因此管理员可能会遭到滥用或错误的威胁。 通常,日常操作使用普通用户帐户,通过su命令更改为超级用户。

路线(路线)。 rootexistallinuxsystemsandcannotbedeletedbecauseoflinuxprivilegesadministrationlogic.rootuserhasspecialhomedirectorylocated

root驻留在所有Linux系统上,并且由于Linux特权管理逻辑而无法删除。 root用户有一个位于/root的特殊主目录,其他用户在正常情况下无法读写或执行。

超级用户命令su(superusercommandsu )。 sometimesweneedtochangesuperusercompletesystemrelatedjobs.therearealternativeandmoresecurewaylikeusingsudocommandwhichichissssshoresteshomand allreadyexaminedthissudocommandinthefollowingtutorial。

您可能需要修改与超级用户的完整系统相关的任务。 还有其他更安全的方法,例如使用sudo命令。 这是超级用户do的缩写。 您在以下教程中查看了此sudo命令。

linuxsudocommandtutorialwithexamplestogetrootprivileges

包含获取根权限示例的Linux Sudo命令教程

sucommandwillaskforrootuserpasswordinordertobecomerootuser。

su命令提示root用户密码才能成为root用户。

$ su以超级用户身份运行单个命令(Run Single Command As Super User ) )。 wehavetheoptiontorunsinglecommandassuperuserbyusing-coptionandthecommand.inthisexamplewillrunmkdir/etc/testcommmandas

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

$ su-c ' mkdir/etc/test ' runsinglecommandassuperuser以超级用户身份查看单个命令和sudo之间的差异微信命令

我们可以如下所示比较su和sudo命令。

suwilldirectlychangetotherootuser

su将直接更改为根用户

sudowillusecurrentuserwithadministratorrootprivileges

sudo使用具有管理员或根权限的当前用户

suwillchangeuserlinuxenvironmenttotheroot

su将用户Linux环境更改为root

sudowillusecurrentuserenvironmentafterthecommandexecutioniscompleted

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

suwill require rootuser passw

ord

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文件中的WHEEL或ROOT组。

.u74b39948f33807db319786080ba35dc1 , .u74b39948f33807db319786080ba35dc1 .postImageUrl , .u74b39948f33807db319786080ba35dc1 .centered-text-area { min-height: 80px; position: relative; } .u74b39948f33807db319786080ba35dc1 , .u74b39948f33807db319786080ba35dc1:hover , .u74b39948f33807db319786080ba35dc1:visited , .u74b39948f33807db319786080ba35dc1:active { border:0!important; } .u74b39948f33807db319786080ba35dc1 .clearfix:after { content: ""; display: table; clear: both; } .u74b39948f33807db319786080ba35dc1 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u74b39948f33807db319786080ba35dc1:active , .u74b39948f33807db319786080ba35dc1:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u74b39948f33807db319786080ba35dc1 .centered-text-area { width: 100%; position: relative; } .u74b39948f33807db319786080ba35dc1 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u74b39948f33807db319786080ba35dc1 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u74b39948f33807db319786080ba35dc1 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u74b39948f33807db319786080ba35dc1:hover .ctaButton { background-color: #E67E22!important; } .u74b39948f33807db319786080ba35dc1 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u74b39948f33807db319786080ba35dc1 .u74b39948f33807db319786080ba35dc1-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u74b39948f33807db319786080ba35dc1:after { content: ""; display: block; clear: both; } LEARN MORE  Linux Sudo Command Tutorial with Examples To Get Root Privileges .u74b39948f33807db319786080ba35dc1 , .u74b39948f33807db319786080ba35dc1 .postImageUrl , .u74b39948f33807db319786080ba35dc1 .centered-text-area { min-height: 80px; position: relative; } .u74b39948f33807db319786080ba35dc1 , .u74b39948f33807db319786080ba35dc1:hover , .u74b39948f33807db319786080ba35dc1:visited , .u74b39948f33807db319786080ba35dc1:active { border:0!important; } .u74b39948f33807db319786080ba35dc1 .clearfix:after { content: ""; display: table; clear: both; } .u74b39948f33807db319786080ba35dc1 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u74b39948f33807db319786080ba35dc1:active , .u74b39948f33807db319786080ba35dc1:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u74b39948f33807db319786080ba35dc1 .centered-text-area { width: 100%; position: relative; } .u74b39948f33807db319786080ba35dc1 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u74b39948f33807db319786080ba35dc1 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u74b39948f33807db319786080ba35dc1 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u74b39948f33807db319786080ba35dc1:hover .ctaButton { background-color: #E67E22!important; } .u74b39948f33807db319786080ba35dc1 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u74b39948f33807db319786080ba35dc1 .u74b39948f33807db319786080ba35dc1-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u74b39948f33807db319786080ba35dc1:after { content: ""; display: block; clear: both; } 了解更多Linux Sudo命令教程,并附带示例以获取root特权

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

su命令切换到root用户

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。