分配给PATH变量的字符串

I am a new to Linux/Unix programming and was learning form the tutorial: https://www.tutorialspoint.com/unix/unix-environment.htm

在本教程中,它说主目录中的.profile文件 初始化TERM变量并初始化PATH变量 到:$ PATH = / bin:/ usr / bin $

但是,当我打印.profile文件的内容时,会得到以下内容:

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

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

 9  # if running bash
10  if [ -n "$BASH_VERSION" ]; then
11      # include .bashrc if it exists
12      if [ -f "$HOME/.bashrc" ]; then
13      . "$HOME/.bashrc"
14      fi
15  fi

16  # set PATH so it includes user's private bin directories
17  PATH="$HOME/bin:$HOME/.local/bin:$PATH"

我的问题是

(1)TERM变量未在任何地方初始化吗?

(2)PATH变量初始化为垃圾桶(?)-因为找不到名为“ HOME”的任何文件夹,所以路径 $ HOME / bin和$ HOME / .local / bin没有意义;还有哪个文件夹是$ PATH?

评论
  • 仵灵波
    仵灵波 回复

    $ TERM变量是一个环境变量,它控制您的终端是否具有颜色。变量$ HOME设置为您的主目录。要查看此位置,可以执行以下操作:

    echo $HOME
    

    要么

    cd $HOME
    

    您需要在变量的开头加上$,否则bash不会知道您正在引用该变量,而是将其视为字符串。

    我希望这个对你有用。