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.
最新文章
- Kafka 文档用例
- JBOSS通过Apache负载均衡方法一:使用mod_jk
- Redis教程(七):Key操作命令详解
- 在Android上使用fontAwesome
- python时间处理函数
- tcpdump学习
- CSS常用布局整理(二)
- CentOS-6.3安装配置Nginx
- DOM 之 document 查找元素方法
- angular中设置$http的post请求的数据传递格式
- jar 包和批量处理
- 从51跳cortex-m0学习2——程序详解
- lodoop打印控制具体解释
- io的四个分类
- ldd获得可执行程序的所有库并输出到指定目录
- linux统计多个文件大小总和
- JavaScript 将两个数组合并,且删除重复的值
- 21.PHP实现Word/Excel/PPT转换为PDF
- java中用jdom创建xml文档/将数据写入XML中
- [C++]Linux之文件拷贝在系统调用和C库函数下的效率比较