哪个配置文件包含我的路径变量?

哪个配置文件包含我的路径变量?

在我的《Linux 命令行》一书中,有这样的说法

“PATH 变量通常(但并非总是,取决于发行版)由 /etc/profile 启动文件设置,并使用此代码:

PATH=$PATH:$HOME/bin”

当我打开 etc/profile 查看它是否存在时,它不存在....但是这段代码肯定在系统中吗?在环境中,有路径变量,但它不一样,有几条用冒号分隔的路径。

如果有的话,这段代码在我的系统上位于哪里?

答案1

该特定代码片段位于~/.profile,默认情况下如下所示:

$ cat /etc/skel/.profile
# ~/.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

相关内容