摘要:

sudo和su两个命令是Linux比较常用的两个命令,笔者最初的认知里认为两个命令存在某种关联,后来发现两个命令只是内容上相似,本质上是两个不相关的命令。sudo命令用来在普通用户中获取系统管理员权限执行特定任务,提高系统安全性。su命令用来转换已登入会话的owner,说简单一点就是转换用户。

sudo命令

sudo (/ˈsuːduː/or/ˈsuːdoʊ/, superuser do) is a utilityfor UNIX- and Linux-based systems that provides an efficient way to givespecific users permission to use specific system commands at the root (mostpowerful) level of the system. Sudo also logs all commands and arguments.

超级用户执行(superuser do,sudo)是一个Unix系统工具,它提供一个有效方法,允许给定用户在系统的root(权利最大)层次使用特定的系统命令。sudo还记录所有的命令和参数。它允许系统管理员分配给普通用户一些合理的“权利”,让他们执行一些只有超级用户或其他特许用户才能完成的任务,从而减少root用户的登陆次数和管理时间,提高系统安全性。

使用sudo,能够实现如下操作:

(1)让有些用户(或者用户群)能够在系统操作的root层次运行一些(或所有)命令。

(2)控制用户能在各个主机使用的命令。

(3)从记录清楚的检查哪些用户使用了哪些命令。

(4)使用时标文件,控制用户输入口令以及获得适当权益之后必须输入命令的时间长短。

配置sudo。配置sudo必须通过编辑/etc/sudoers文件,而且只有超级用户才可以修改它,还必须使用visudo编辑。之所以使用visudo有两个原因,一是它能够防止两个用户同时修改它;二是它也能进行有限的语法检查。所以,即使只有一个超级用户,也最好用visudo来检查一下语法。

su命令

The su (substitute user) command makes it possible to change a login session's owner(i.e., the user who originally created that session by logging on to thesystem) without the owner having to first log out of that session.

Although su canbe used to change the ownership of a session to any user, it is most commonlyemployed to change the ownership from an ordinary user to the root (i.e.,administrative) user, thereby providing access to all parts of and all commandson the computer or system. For this reason, it is often referred to (although somewhatinaccurately) as the superuser command. It is also sometimes called the switch user command.

su is usuallythe simplest and most convenient way to change the ownership of a login sessionto root or to any other user.

Moreimportantly, it provides a safer way for administrators on multi-user systems(as well as for users on home computers or other single-user systems) to usethe system than to routinely log on as the root user. That is, there is muchless potential for accidental or malicious damage if an administrator firstlogs on as an ordinary user (who, by default, has very limited systemprivileges) and uses that account for routine tasks that do not require root'ssweeping powers. su can then be used to switch to the root account for onlythose operations that actually require root access (e.g., making system repairsand managing user accounts).

su(switch user的缩写,有的地方也被看作是substituteuser的缩写)用于以其他用户的身份来打开一个shell或者登录界面。当该命令不加任何参数运行时,su命令将假设你想成为root。当运行该命令时,你将被提示输入密码。输入的密码即你想切换到的用户的密码。例如,如果想成为root,在终端中运行su,则将需要输入root用户的密码。如果运行su bill命令,将需要输入bill的密码。

sudo和su命令简介相关推荐

  1. sudo和su命令的联系和区别详解

    sudo和su命令 sudo sudo是一种权限管理机制,依赖于/etc/sudoers,其定义了授权给哪个用户可以以管理员的身份能够执行什么样的管理命令. 默认情况下,系统只有root用户可以执行s ...

  2. shell中sudo和su命令

    原文地址::http://blog.csdn.net/liuxigiant/article/details/9090993 sudo command    sudo命令是以root的身份执行comma ...

  3. Linux: sudo 和 su 命令异同

    sudo 通常 'Permission denied' 错误的时候,需要执行 sudo 命令. 该命令会提高执行权限(通常是 root). 当然 使用 sudo -u username 会指定特定用户 ...

  4. Ubuntu进入root权限命令——sudo和su命令详解

    ubuntu用户管理 sudo意思就是super-user do,让当前用户暂时以管理员的身份root来执行这条命令. su是用来改变当前用户的,su root,就是将当前用户切换为root,用了su ...

  5. Linux 中 sudo、su命令

    sudo : 暂时切换到超级用户模式以执行超级用户权限,提示输入密码时该密码为当前用户的密码,而不是超级账户的密码.不过有时间限制,Ubuntu默认为一次时长15分钟. su : 切换到某某用户模式, ...

  6. 深入理解 sudo 与 su 之间的区别

    深入理解 sudo 与 su 之间的区别 作者: Himanshu Arora 译者: LCTT zhb127 在早前的一篇文章中,我们深入讨论了 sudo 命令的相关内容.同时,在该文章的末尾有提到 ...

  7. 深入理解 sudo 与 su 之间的区别【转】

    深入理解 sudo 与 su 之间的区别 两个命令的最大区别是: sudo 命令需要输入当前用户的密码,su 命令需要输入 root 用户的密码.另外一个区别是其默认行为.sudo 命令只允许使用提升 ...

  8. linux sudo和su区别,了解sudo和su之间的区别

    在我们之前的一篇文章中 ,我们详细讨论了"sudo"命令. 在该教程的末尾,在一个小笔记中提到另一个类似的命令"su". 那么在这篇文章中,我们将详细讨论'su ...

  9. docker使用过程中遇到的Linux中的su命令

    遇到的Linux中的su命令 linux环境下,常常需要我们切换用户,通过不同的权限,可以控制系统的安全性.所以例如ES会明确要求不能用root用户进行开发. 于是我们需要使用su命令切换用户. 然而 ...

  10. Linux的su命令,sudo命令和限制root远程登录

    3.7 su命令: su命令是用来切换用户的,例如我要从root用户切换到user2用户:   这个 - 选项是彻底切换用户的意思,如果不加 - 选项也可以,但是切换得不彻底,例如当前的家目录还是ro ...

最新文章

  1. 2021-04-12MYSQL修改密码报错
  2. linux iptables规则组成及用法
  3. POJ 1001 Exponentiation C++解题报告 JAVA解题报告
  4. 解决Failed to load resource: net::ERR_CONNECTION_TIMED_OUT问题
  5. Deep learning Reading List
  6. 汇编html文档,欢迎走进HTML的世界汇编.ppt
  7. 从头到尾再讲一遍ThreadLocal
  8. python html解析对比_python htmlparse页面解析示例
  9. Atitti html5 h5 新特性attilax总结
  10. Navicat Premium 12.0.29 / 12.1.5.0注册机激活
  11. Keil中C代码常见错误的解决
  12. spring-boot-starter-data-jpa详细使用介绍
  13. css背景图不失真_CSS如何实现这种背景效果?
  14. idea 查找替换快捷键
  15. iis提示“另一个程序正在使用此文件,进程无法访问。(异常来自HRESULT:0x80070020) ”解决办法
  16. Python高级-前端-01-HTML和CSS
  17. 数据结构 - 迭代、递归和分治思想
  18. 《设计心理学》学习笔记之设计未来(第四册)
  19. UVa 11062 Andy's Second Dictionary(刘汝佳紫书升级题)
  20. ZT看不懂的中国历史:老蒋的智力竟然在50之下

热门文章

  1. 推荐方法-1:UserCFItemCF
  2. [PAT B1023]组个最小数
  3. 自动驾驶3-3 自动驾驶的安全框架 Safety Frameworks for Self-Driving
  4. 阿里云云计算 29 AS的原理
  5. 翻译:您在Swift 5中的第一个UITest
  6. 参考文献顺序_科技论文参考文献的著录规则及存在问题
  7. 谷歌浏览器禁止右滑返回历史_早报:拼多多加大百亿补贴力度;嫦娥五号择机返回地球;贾跃亭再成被执行人;微信订阅号页面改版...
  8. HashMap与ConcurrentHashMap的底层原理
  9. gis投影中未定义的地理转换_PhotoScan中经纬度转换为投影坐标快捷方法
  10. Information Extraction