su 和 sudo、su root和su - root 区别

su - root:

just like login as root, then the shell is login shell,
which mean it will expericene a login process,
usually .bash_profile and .bashrc will be sourced

su root
like you open an interactive shell in root name,
then only .bashrc will be sourced.
su 和 sudo 的区别:
1.共同点:都是root用户的权限;
2.不同点:su仅仅取得root权限,工作环境不变,还是在切换之前用户的工作环境;sudo是完全取得root的权限和root的工作环境。
su - root 和 su root(su)有什么区别?
su - root:表示人以root身份登录
just like login as root, then the shell is login shell,
which mean it will expericene a login process,
usually .bash_profile and .bashrc will be sourced
su root:表示与root建立一个链接,通过root执行命令
like you open an interactive shell in root name,
then only .bashrc will be sourced.
最直接的区别就是su目录还是原先用户的目录
但是su或su - root后目录就变为root用户的主目录了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 最近在项目环境方面遇到的坑,明明配置了环境变量,却无法使用,原因是切换用户时使用的是su而不是su - su命令和...
    风的低语阅读 4,444评论 2 4
  • 系统环境:CentOS Linux release 7.3.1611 x86_64 GNU/Linux 查看所有用...
    Rethink阅读 201评论 0 3
  • 1. 解决「解锁Mac文件」的历程 1.1 个人遇到的问题 为了防止欧路词典对 .plist 文件进行更改,从一篇...
    WendaoSolemn阅读 2,936评论 2 1
  • 1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 cp命令:实现文件复制 源文件:目标...
    wbyyy阅读 324评论 1 0
  • su命令 切换到普通用户: [root@localhost ~]# su - hch1 [hch1@localho...
    hch004阅读 1,266评论 0 0