1. 程式人生 > 其它 >ubuntu添加了新的path之後,每次xshell登入之後都得source ~/.bashrc才管用。解決過程。

ubuntu添加了新的path之後,每次xshell登入之後都得source ~/.bashrc才管用。解決過程。

1. 使用lsb_release -a檢視ubuntu版本如下:

:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

2. 檢視~/.profile是否存在,如果沒有新建一個,拷貝如下內容到.profile檔案。 另外如果有vim不能從外部拷貝的問題,可以使用nano~/.profile編輯,ctrl+x退出編輯,選擇y儲存。

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

3. xshell重新登入,就不用再source。。。了