UOS个人版不加载~/.profile里面的内容
Tofloor
poster avatar
widon1104
deepin
2020-05-22 02:00
Author
UOS个人版,我在~/.profile里面做的设置全部没有生效,比如说我在里面export PATH=XXX结果没有生效
我是从deepin15.11转到UOS个人版来的,转之前是没有问题的


Reply Favorite View the author
All Replies
avatar
小兰米
deepin
2020-05-22 02:14
#1
V20和UOS应该都是加载~/.bash_profile和/etc/profile,但这里有个问题要注意:
1. 使用深度终端,它只加载~/.bashrc而不加载~/.bash_profile
2. 当使用字符终端登录或者图形桌面程序(非深度终羰中执行的程序)一概不加载~/.bashrc,只加载~/.bash_profile

我的解决方法是,把一切配置放在~/.bashrc中,然后新建~/.bash_profile,内容如下:
  1. if [ -f ~/.bashrc ]; then
  2.     source ~/.bashrc
  3. fi
Copy the Code
Reply View the author
Comments
deepinuser17
2020-08-16 07:49
正解
avatar
widon1104
deepin
2020-05-22 03:08
#2
https://bbs.deepin.org/post/194823
V20和UOS应该都是加载~/.bash_profile和/etc/profile,但这里有个问题要注意:
1. 使用深度终端,它只加载~ ...

好麻烦,希望uos加载~/.profile,以前用的好好的,干嘛乱改一通
Reply View the author
avatar
widon1104
deepin
2020-05-23 23:33
#3
@jingle
希望uos个人版和其他linux发行版包括deepin保持一致,加载~/.profile这个文件



Reply View the author
avatar
nolocus
deepin
2020-05-24 00:56
#4
有加载的, 比如我第一次安装conky的时候, 脚本有直接写到.profile里面, 然后开机就会自动启动了...  不过之后不知道进行了哪些操作, .profile 就不再加载了..
Reply View the author
Comments
lbygljq
2020-06-17 17:58
因为不会自动加载,所以conky没有启动
avatar
忘记、过去
deepin
2020-05-24 03:52
#5
所以直接换成zsh好像也可以?我这里只要改.zshrc就行,避免一切烦恼......
Reply View the author
avatar
Feng Yu
deepin
2020-05-24 04:05
#6
又一个被国内误人子弟的资料误导的。这是对的,你应该自行去看bash的man手册,而不是国内误人子弟的资料
Reply View the author
avatar
lbygljq
deepin
2020-06-17 18:20
#7
https://bbs.deepin.org/post/194823
又一个被国内误人子弟的资料误导的。这是对的,你应该自行去看bash的man手册,而不是国内误人子弟的资料 ...

man中这样说的:
        当bash作为交互式登录shell或具有--login选项的非交互式shell被调用时,它首先从文件/etc/profile中读取并执行命令(如果该文件存在)。读取该文件后,它将按该顺序查找〜/.bash_profile,〜/.bash_login和〜/.profile,并从存在的且可读的第一个命令中读取并执行命令。

〜/.profile文件注释:如果存在〜/.bash_profile或〜/.bash_login,则bash不会读取此文件。
        
Reply View the author
avatar
widon1104
deepin
2020-08-01 04:02
#8
UOS20正式版修复了这个问题没有,开始加载~/.profile了吗?
Reply View the author
avatar
widon1104
deepin
2020-08-16 05:40
#9
UOS专业版1021和deepin V20都还是没有加载~/.profile
Reply View the author
avatar
要讲武德
deepin
2020-08-16 06:25
#10
我也发现, 在.profile里配置的环境变量再登录就无效。非得配置到baserc,  太影响使用了;深度的开发都没在.profile配置过,没发现吗??
Reply View the author
avatar
deepinuser17
deepin
2020-08-16 08:09
#11
深度V20只有~/.bashrc.

对于bash来说,个人shell正确的设置是用.bash_profile和.bashrc.  .bash_profile适用于交互界面(即打开终端,与终端交互使用). .bashrc适用于非交互界面(如通过ssh远程运行命令,这种情况没有打开终端).

#2楼的方法是正解.创建.bash_profile文件,但.bash_profile只是读取.bashrc里的设置.这种方法在红帽,CentOS上是初始设置.

在红帽,CentOS机器上创建个人账户时,.bash_logout,.bash_profile,.bashrc会自动加载到新创建用户的目录下.

  1. $ ls -lh /etc/skel/.bash*
  2. -rw-r--r-- 1 root root  18 Aug  8  2019 /etc/skel/.bash_logout
  3. -rw-r--r-- 1 root root 193 Aug  8  2019 /etc/skel/.bash_profile
  4. -rw-r--r-- 1 root root 231 Aug  8  2019 /etc/skel/.bashrc
Copy the Code

  1. $ cat /etc/skel/.bash_profile
  2. # .bash_profile

  3. # Get the aliases and functions
  4. if [ -f ~/.bashrc ]; then
  5.         . ~/.bashrc
  6. fi

  7. # User specific environment and startup programs

  8. PATH=$PATH:$HOME/.local/bin:$HOME/bin

  9. export PATH
Copy the Code

  1. $ cat /etc/skel/.bashrc
  2. # .bashrc

  3. # Source global definitions
  4. if [ -f /etc/bashrc ]; then
  5.         . /etc/bashrc
  6. fi

  7. # Uncomment the following line if you don't like systemctl's auto-paging feature:
  8. # export SYSTEMD_PAGER=

  9. # User specific aliases and functions
Copy the Code


用.bashrc是bash的通用方法.就像csh,tcsh,用.cshrc; zsh用.zshrc一样. 个人的设置一般是放在rc文件里. 
Reply View the author
avatar
duanyao
deepin
2020-09-07 00:33
#12
完美的解决办法(回到旧 deepin 的行为): https://bbs.deepin.org/post/192373
Reply View the author
avatar
duanyao
deepin
2020-09-07 00:39
#13
https://bbs.deepin.org/post/194823
深度V20只有~/.bashrc.

对于bash来说,个人shell正确的设置是用.bash_profile和.bashrc.  .bash_profile适 ...

这应该是 deepin V20 和 debian 10 的 bug 。.profile 存在的一个理由就是它不仅适用于 bash ,也适用于很多其它 shell ,而 .bashrc 就只有 bash 会使用。

可以按这个帖子里我的回复修改: https://bbs.deepin.org/post/192373
Reply View the author