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. Hibernate 主键生成策略

    表示符生成器 描述 Increment 由hibernate自动以递增的方式生成表识符,每次增量为1 Identity 由底层数据库生成表识符.条件是数据库支持自动增长数据类型. Sequence H ...

  2. 几种常见ECG数据格式及对比

    SCP.DICOM.HL7aECG.GDF格式及对比 本文档首先给出SCP.DICOM.HL7aECG.GDF四种心电信号格式的具体数据结构,然后分析其各自的特点及适用范围. 一.SCP-ECG fo ...

  3. C++11中int,float,double与string的转化

    在C++11中可以使用std::to_string()函数将数值转换为string格式,十分方便. 以下部分来选自cplusplus.com. std::to_string string to_str ...

  4. javascript权威指南学习笔记1

    打开这本书,进入到javascript的世界.以前都是看各种视频,感觉什么收获也没有,反而弄得脑袋混乱,希望能够按照这本书的节奏掌握javascript这门语言,为我的前端学习打下基础. 学习前准备: ...

  5. __PUBLIC__模板文件路径配置

    __PUBLIC__ 默认指向 项目文件下的Public文件夹 注意: __PUBLIC__不是一个常量,只在模板中进行替换,__ROOT__是一个常量 项目文件路径 defined('__PUBLI ...

  6. Net Core 项目实战之权限管理系统(0)

    0 前言 Net Core 项目实战之权限管理系统(0) 无中生有   0 http://www.cnblogs.com/fonour/p/5848933.html 学习的最好方法就是动手去做,这里以 ...

  7. 3D touch 的 应用 --备用

    在iPhone 6s和iPhone 6s Plus中Apple引入了3D Touch技术.3D Touch的触控技术,被苹果称为新一代多点触控技术.其实,就是此前在Apple Watch上采用的For ...

  8. 启动Activity但不显示其界面

    最近在工作中做了一个很简单的任务,制作一个apk,点击该app链接到某一个网站.     代码很简单,只有如寥寥几行: (browser.java) package com.test.browser; ...

  9. POJ3267 The Cow Lexicon(dp)

    题目链接. 分析: dp[i]表示母串从第i位起始的后缀所对应的最少去掉字母数. dp[i] = min(dp[i+res]+res-strlen(pa[j])); 其中res 为从第 i 位开始匹配 ...

  10. -_-#【AJAX】XMLHttpRequest

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...