Using su

The  su  command allows users to open a terminal window, and from that terminal start a sub shell in which the user has another identity. To perform administrative tasks, for instance, you can log in with a normal user account and type  su  to open a root shell. This brings the benefit that only in the root shell root privileges are used.

If just the command  su  is typed, the username root is implied. But su can be used to run tasks as another user as well. Type  su linda  to open a subshell as the user linda, for example. When using  su  as an ordinary user, you are prompted for a password and after entering that you have acquired the credentials of the target user:

[linda@localhost ~]$ su  Password:

[root@localhost linda]#   
      When using  su , a sub shell is started. This is an environment where you are able to work as the target user account, but environment settings for that user account have not been set. If you need complete access to the entire environment of the target user account, you can use  su -  to start a login shell. If you start a login shell, all scripts that make up the user environment are processed, which makes you work in an environment that is exactly the same as when logging in as that user.   (使用su - 切换到其它用户,不要使用su直接切换)

TIP

Using  su -  is better than using  su . When the  -  is used, a login shell is started, without the  - , some variables may not be set correctly. So, you are better off using  su -  immediately.

linux中切换用户方式su和su -的区别的更多相关文章

  1. Linux中切换用户变成-bash4.1-$的解决方法【转】

    转自 Linux中切换用户变成-bash4.1-$的解决方法 - xia_xia的博客 - 博客频道 - CSDN.NEThttp://blog.csdn.net/xia_xia0919/articl ...

  2. 在Linux中切换用户时变成-bash-4.3$

    增加普通用户 [root@git-node1 ~]#useradd nulige [root@git-node1 ~]#passwd nulige 输入两次密码 [root@git-node1 ~]# ...

  3. Linux中切换用户变成-bash4.1-$的解决方法

    原因是root在/root下面的几个配置文件丢失,将/etc/skel/目录下的三个文件拷贝到用户家目录即可 cp /etc/skel/.bashrc /root/ cp /etc/skel/.bas ...

  4. Linux中root用户找不到JAVA_HOME

    Linux中root用户找不到JAVA_HOME   在Ubuntu环境中安装好Java环境后设置环境变量:在/etc/profile中设置好了JAVA_HOME变量并引入到PATH中,用于Ubunt ...

  5. Linux自动切换用户

    Linux自动切换用户 一.创建sh文件 touch su_user.sh 二.下载脚本 yum install -y expect 三.脚本内容 #!/bin/bash# This is our f ...

  6. linux 中更改用户权限和用户组的命令chmod,chgrp实例

    linux 中更改用户权限和用户组的命令实例; 增加权限给当前用户 chmod +wx filename chmod -R 777 /upload 用户组 chgrp -R foldname zdz ...

  7. shell脚本中切换用户并执行命令

    1.切换用户并执行命令 su 用户名 -c "命令" 2.切换用户并执行脚本 su 用户名 -s /bin/bash 脚本路径 3.切换用户并执行命令集su 用户名 << ...

  8. Linux中加入用户、删除用户时新手可能遇到的问题

    Linux中加入用户.删除用户时新手可能遇到的问题  1.创建新用户后切换到新用户:No directory, logging in with HOME=/     加入用户     #sudo us ...

  9. linux中的用户、群组和权限

     linux中的用户.群组和权限   新建用户natasha,uid为1000,gid为555,备注信息为“master”   groupadd -g 555 natasha useradd -u 1 ...

随机推荐

  1. qt实现类似QQ伸缩窗口--鼠标事件应用

    原创文章,引用请保证原文完整性,尊重作者劳动,原文地址http://blog.csdn.net/hiwubihe/article/details/38678305,qq:1269122125. 上一章 ...

  2. 利用js加载本地图片预览功能

    直接上代码: 经测试,除safari6包括6以下不支持,其他均可正常显示. 原因:safari6不支持filereader,同时不能使用IE滤镜导致失效. fix: 可以利用canvas,解决safa ...

  3. history对象属性和方法

    history对象保存着用户上网的历史记录,从窗口被打开的那一刻算起,history是window对象的属性,因此每个浏览器窗口.每个标签页乃至每个框架,都有自 己的history对象和特定的wind ...

  4. 扩展PHP内置的异常处理类

    在try代码块中,需要使用throw语句抛出一个异常对象,才能跳到转到catch代码块中执行,并在catch代码块中捕获并使用这个异常类的对象.虽然在PHP中提供的内置异常处理类Exception,已 ...

  5. 柯里化(Curing)

    柯里化:把接受多个参数的函数变换成接受单个参数的函数,并且返回准备接受余下参数,还能返回结果的一种技术. function currying(fn){ var args = Array.prototy ...

  6. 监测div 元素 变动

    $(div_fc_even).bind('DOMCharacterDataModified ', function(event) { } 试了很多..只有这个有效..下面这些测试了下 ,无反应 //D ...

  7. ISO14443协议中,卡片对RATS,PPS,IBLOCK的处理约定

    这几天总是看到有人因为这几条规则没处理好,结果检测时通不过,其实看看最新版的ISO14443协议就明白了. 协议中明确要求几条: 1.在激活状态后,如果收到一个无错的RATS命令后,卡片返回atr,此 ...

  8. Markdown和reStructuredText语法比较

    reStructuredText在线编辑器 http://rst.ninjs.org/ ReST是Docutils的标记语法,Docutils是Python世界的文档工具集.也因为这样ReST在Pyt ...

  9. Windows打印管理解决方案

    需求 从需求出发,我们的目的是在电脑上提供一个虚拟打印机,然后让用户选择这个虚拟机打印时产生的中间文件被拦截下来,之后进行进一步处理后在执行真实的打印. Windows打印体系 首先附上查找Windo ...

  10. python自动化测试遇到的零零碎碎

    1.需求: 提取xx.py中所有的函数名,形成一个类似于索引的参考. 解决方式: grep "def" *.py| awk '{print $2}'|awk -F ':' '{pr ...