如何将可执行文件添加到我的搜索路径?

Eug*_*ene 23 paths

作为参考,我对Linux知之甚少,正在使用它来运行别人编写的程序。说明说Add the executable 'ttt' to the search path. In most installations this can be accomplished by linking the file to the 'bin' subdirectory at user home.

我该怎么做?

此可执行文件当前位于主机区域的子文件夹中,因为它在双引导计算机上运行,​​我无法改变它是双引导的事实,因为它是一台工作计算机。

Tho*_*ard 32

要使其适用于命令行(终端):

我建议您在终端中执行以下步骤:

  1. bin在您的主目录中创建一个名为的文件夹。

    mkdir ~/bin
    
    Run Code Online (Sandbox Code Playgroud)
  2. 添加~/binPATHBash 的所有会话(终端内部使用的默认 shell)。

    $ nano ~/.bashrc
    
    # Add the following to the end of your .bashrc file while using nano
    # or your text editor of choice:
    
    export PATH="/home/$USER/bin:$PATH"
    
    Run Code Online (Sandbox Code Playgroud)
  3. 无论是可执行文件本身或者符号链接添加到可执行~/bin

  4. 通过关闭终端并重新打开它source ~/.bashrc来重新启动终端会话,或者运行以重新加载会话的配置

这应该允许您的终端读取PATH终端会话的变量。

不过,我不知道如何将它添加到 GUI,因为我不确定 GUI 如何管理PATH变量,但如果此方法在此处不起作用,则可能需要使用其他方法修改路径图形用户界面。

  • 你不能只是`source ~/.bashrc` 而不是关闭并重新打开终端吗? (7认同)
  • @wordsforthewise 一些不完美的 `~/.bashrc` 在两次获取时表现得很奇怪。 (2认同)
  • @styrofoamfly 这就是为什么你永远不会有不完美的 ~/.bashrc ;) (2认同)