当前位置: 技术问答>linux和unix
linux switch user 都发生了些什么?
来源: 互联网 发布时间:2017-04-13
本文导语: linux通过桌面环境,切换用户的时候都有哪些响应呢? 都加载了哪些文件,哪些内容? 我自己测试发现根本没有任何动静 注:切换用户不是使用su命令 谢谢 | 在/etc/bashrc里面有做终端判断的: # It's NO...
linux通过桌面环境,切换用户的时候都有哪些响应呢?
都加载了哪些文件,哪些内容?
我自己测试发现根本没有任何动静
注:切换用户不是使用su命令
谢谢
都加载了哪些文件,哪些内容?
我自己测试发现根本没有任何动静
注:切换用户不是使用su命令
谢谢
|
在/etc/bashrc里面有做终端判断的:
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "33]0;%s@%s:%s33\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
fi
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\s-\v\$ " ] && PS1="[u@h W]\$ "
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
# and console windows
# If you want to do so, just add e.g.
# if [ "$PS1" ]; then
# PS1="[u@h:l W]\$ "
# fi
# to your custom modification shell script in /etc/profile.d/ directory
fi
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "33]0;%s@%s:%s33\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
fi
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\s-\v\$ " ] && PS1="[u@h W]\$ "
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
# and console windows
# If you want to do so, just add e.g.
# if [ "$PS1" ]; then
# PS1="[u@h:l W]\$ "
# fi
# to your custom modification shell script in /etc/profile.d/ directory
fi
|
/etc/profile
/home/用户名/.bash_profile
/home/用户名/.bashrc
/etc/bashrc
还有/home/用户名/桌面的配置文件
/home/用户名/.bash_profile
/home/用户名/.bashrc
/etc/bashrc
还有/home/用户名/桌面的配置文件
|
猜测,纯属猜测
启动就是图形登陆界面的话X估计是gdm/xdm之类的脚本用特定系统权限运行的。
桌面和窗口管理器都是从用户登录的sesison继承权限
如果这样的话
图形下的切换用户,就只是用新身份启动了新的桌面和窗口管理器。
建议图形方式两个用户各开一个gedit,然后看pstree的输出,找两个gedit的共同祖先
启动就是图形登陆界面的话X估计是gdm/xdm之类的脚本用特定系统权限运行的。
桌面和窗口管理器都是从用户登录的sesison继承权限
如果这样的话
图形下的切换用户,就只是用新身份启动了新的桌面和窗口管理器。
建议图形方式两个用户各开一个gedit,然后看pstree的输出,找两个gedit的共同祖先