[Terminal] ~/.profile不主动加载问题
Tofloor
poster avatar
wuchu
deepin
2021-03-18 22:23
Author

使用系统内置的雷神终端开机后不主动执行source ~/.profile。需要手动执行。

Reply Favorite View the author
All Replies
thepoy
deepin
2021-03-19 01:00
#1

Display Manager 是否应该默认加载 ~/.profile ,有一定的争议,ubuntu 认为是,而 debian 认为不是,所以 debian 10 开始,lightdm 就不再加载了。deepin 可能过去是跟随 ubuntu 的行为会自动加载,V20 又改成跟随 debian 10 的行为不再加载。

 

解决办法

修改 lightdm ,删除 /etc/X11/Xsession.d/01deepin-profile:
 

  1. wget https://github.com/canonical/lightdm/blob/master/debian/lightdm-session  # 下载 deepin/debian 缺失的 lightdm-session 文件
  2. chmod +x lightdm-session
  3. sudo cp lightdm-session /usr/sbin/lightdm-session
  4. sudo dedit /etc/lightdm/lightdm.conf   # 找到 session-wrapper=lightdm-session 一行,去掉注释。
  5. sudo rm /etc/X11/Xsession.d/01deepin-profile

使用这个方法时,建议也对 ~/.profile 做个小修改:将 `if [ -n "$BASH_VERSION" ]` 改为 `if [ -n $BASH_VERSINFO ]`,因为 lightdm-session 会清除 BASH_VERSION ,使得检测不准确。

 

重启后再看看.profile是不是已经加载了。

 

另外,各个Linux发行版发展到现在,.profile已经再是推荐的配置文件了,只是很多人都习惯了修改.profile。

Reply View the author
wuchu
deepin
2021-03-19 01:14
#2
It has been deleted!
wuchu
deepin
2021-03-19 01:15
#3
thepoy

Display Manager 是否应该默认加载 ~/.profile ,有一定的争议,ubuntu 认为是,而 debian 认为不是,所以 debian 10 开始,lightdm 就不再加载了。deepin 可能过去是跟随 ubuntu 的行为会自动加载,V20 又改成跟随 debian 10 的行为不再加载。

 

解决办法

修改 lightdm ,删除 /etc/X11/Xsession.d/01deepin-profile:
 

  1. wget https://github.com/canonical/lightdm/blob/master/debian/lightdm-session  # 下载 deepin/debian 缺失的 lightdm-session 文件
  2. chmod +x lightdm-session
  3. sudo cp lightdm-session /usr/sbin/lightdm-session
  4. sudo dedit /etc/lightdm/lightdm.conf   # 找到 session-wrapper=lightdm-session 一行,去掉注释。
  5. sudo rm /etc/X11/Xsession.d/01deepin-profile

使用这个方法时,建议也对 ~/.profile 做个小修改:将 `if [ -n "$BASH_VERSION" ]` 改为 `if [ -n $BASH_VERSINFO ]`,因为 lightdm-session 会清除 BASH_VERSION ,使得检测不准确。

 

重启后再看看.profile是不是已经加载了。

 

另外,各个Linux发行版发展到现在,.profile已经再是推荐的配置文件了,只是很多人都习惯了修改.profile。

好的谢谢解答,我确实是主用ubuntu,deepin这才尝鲜

Reply View the author
deepinuser17
deepin
2021-03-19 17:58
#4

把环境变量加到~/.bashrc里就行了.

 

~/.bashrc交互和非交互的情况下都会加载.

Reply View the author