Linux操作,su切换用户命令中有无横杠“-”的区别
2015-05-18 11:08
676 查看
工作中遇到这样的问题,服务器上需要从root切换至postgreSQL安装用户去启动postgreSQL服务。
切换用户和启动postgreSQL命令如下:
提示pg_ctl命令不存在,但是可以肯定的是之前安装postgreSQL时就是这么启动的,怎么这次不行了呢。
后来了解到原来是su命令的问题,有没有横杠"-"是有区别的。
有横杠login shell:用户切换,更改工作目录,加载所有用户环境配置。
无横杠interactive shell:用户切换,但是工作目录不会切换到该用户所在工作目录,也不会加载该用户设置的环境变量。
"When Bash starts executes the commands in a variety of different scripts.
(1) When started as an interactive login shell: Bash reads and executes
the /etc/profile (if it exists). After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile in that order, and reads
and executes the first one (that exists and is readable). When a login
shell
exits: Bash reads and executes ~/.bash_logout (if it exists)。
(2) When started as an interactive shell (but not a login shell): Bash reads and executes ~/.bashrc (if it exists)."
切换用户和启动postgreSQL命令如下:
# 切换至pgsql用户 su postgres # 启动 pg_ctl start -bash: pg_ctl: command not found
提示pg_ctl命令不存在,但是可以肯定的是之前安装postgreSQL时就是这么启动的,怎么这次不行了呢。
后来了解到原来是su命令的问题,有没有横杠"-"是有区别的。
su - postgres
有横杠login shell:用户切换,更改工作目录,加载所有用户环境配置。
无横杠interactive shell:用户切换,但是工作目录不会切换到该用户所在工作目录,也不会加载该用户设置的环境变量。
"When Bash starts executes the commands in a variety of different scripts.
(1) When started as an interactive login shell: Bash reads and executes
the /etc/profile (if it exists). After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile in that order, and reads
and executes the first one (that exists and is readable). When a login
shell
exits: Bash reads and executes ~/.bash_logout (if it exists)。
(2) When started as an interactive shell (but not a login shell): Bash reads and executes ~/.bashrc (if it exists)."
相关文章推荐
- linux 用户切换su 命令横杠的作用
- Linux中的用户切换:su和su - 的区别
- Linux中的用户切换:su和su -的区别(转)
- linux 切换到 root 用户 [su命令,sudo命令]
- linux 切换到 root 用户 [su命令,sudo命令]
- linux su命令参数及用法详解--linux切换用户命令
- Linux如何查看系统当前登录用户信息,linux su命令参数及用法详解(linux切换用户命令)
- sudo和用su切换至root用户运行命令的区别
- linux su命令参数及用法详解(linux切换用户命令)
- linux学习入门1——bash命令基本操作(linuxcast.net)(bash部分快捷键、uname、history、通配符、切换用户、作业管理(前台、后台运行,暂停等操作))
- Linux中的用户切换:su和su -的区别
- Linux 切换用户命令: su 和 su -
- linux--> 切换用户命令su
- Linux 普通用户su命令切换控制
- Linux学习笔记——切换并取代用户身份命令——su
- linux基础命令之:su和sudo用户切换命令的使用
- linux中切换用户方式su和su -的区别
- Linux Ubuntu下使用su命令切换root用户
- linux用户切换su命令
- linux su命令 切换用户