linux中切换用户方式su和su -的区别
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 -的区别的更多相关文章
- Linux中切换用户变成-bash4.1-$的解决方法【转】
转自 Linux中切换用户变成-bash4.1-$的解决方法 - xia_xia的博客 - 博客频道 - CSDN.NEThttp://blog.csdn.net/xia_xia0919/articl ...
- 在Linux中切换用户时变成-bash-4.3$
增加普通用户 [root@git-node1 ~]#useradd nulige [root@git-node1 ~]#passwd nulige 输入两次密码 [root@git-node1 ~]# ...
- Linux中切换用户变成-bash4.1-$的解决方法
原因是root在/root下面的几个配置文件丢失,将/etc/skel/目录下的三个文件拷贝到用户家目录即可 cp /etc/skel/.bashrc /root/ cp /etc/skel/.bas ...
- Linux中root用户找不到JAVA_HOME
Linux中root用户找不到JAVA_HOME 在Ubuntu环境中安装好Java环境后设置环境变量:在/etc/profile中设置好了JAVA_HOME变量并引入到PATH中,用于Ubunt ...
- Linux自动切换用户
Linux自动切换用户 一.创建sh文件 touch su_user.sh 二.下载脚本 yum install -y expect 三.脚本内容 #!/bin/bash# This is our f ...
- linux 中更改用户权限和用户组的命令chmod,chgrp实例
linux 中更改用户权限和用户组的命令实例; 增加权限给当前用户 chmod +wx filename chmod -R 777 /upload 用户组 chgrp -R foldname zdz ...
- shell脚本中切换用户并执行命令
1.切换用户并执行命令 su 用户名 -c "命令" 2.切换用户并执行脚本 su 用户名 -s /bin/bash 脚本路径 3.切换用户并执行命令集su 用户名 << ...
- Linux中加入用户、删除用户时新手可能遇到的问题
Linux中加入用户.删除用户时新手可能遇到的问题 1.创建新用户后切换到新用户:No directory, logging in with HOME=/ 加入用户 #sudo us ...
- linux中的用户、群组和权限
linux中的用户.群组和权限 新建用户natasha,uid为1000,gid为555,备注信息为“master” groupadd -g 555 natasha useradd -u 1 ...
随机推荐
- 高级I/O函数(3)-tee、fcntl函数
tee函数使用 功能描述:tee函数在两个管道文件描述符之间复制数据,也是零拷贝操作.它不消耗数据,因此源文件描述符仍然可以用于后续的操作. 函数原型: #include <fcntl.h> ...
- Linux硬盘命名和安装分区
硬盘命名: 硬盘命名基于文件,一般有如下文件方式: /dev/hda1 /dev/sdb3 具体含义如下: /dev:是所有设备文件存放的目录. hd和sd:他们是区别的前两个字母,代表该分区所在的设 ...
- 给出2n+1个数,其中有2n个数出现过两次,如何用最简便的方法找出里面只出现了一次的那个数(转载)
有2n+1个数,其中有2n个数出现过两次,找出其中只出现一次的数 例如这样一组数3,3,1,2,4,2,5,5,4,其中只有1出现了1次,其他都是出现了2次,如何找出其中的1? 最简便的方法是使用异或 ...
- 激活office 2013
1.下载office 2013激活工具:microsoft toolkit 2.解压文件,运行Microsoft Toolkit.exe,选择office,即箭头标识处
- java判断网络连接是否正常
/** * 判断本机当前的网络状态是否联通 * 在这里主要用到中国天气信息,所以访问百度地址是否能够访问成功来判断当前的网络状态 */ public static boolean isConnect( ...
- 《asp.net mvc3 高级编程》第三章 视图
一.视图的作用 视图的职责是向用户提供界面.从ASP.NET MVC3开始,视图数据也可以通过ViewBag属性访问.例如:ViewBag.Message 就等于ViewData["Mess ...
- JQUERY1.9学习笔记 之基本过滤器(九) 小于选择器
小于选择器 jQuery( ":lt(index)" ) jQuery( ":lt(-index)" ) 描述:选择所有小于指定下标的元素. <!DOCT ...
- python之map和filter
li = [11,22,33,44,55,66] ret = filter(lambda a:a>33,li) print(list(ret)) ret2 = map(lambda a:a+10 ...
- IIS 10 安装URLRewrite组件 方式
1.Open Regedit > HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp 2.Edit "MajorVersion" an ...
- No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
运行代码是出现了这个错误,No Entity Framework provider found for the ADO.NET provider with invariant name 'System ...