我下载了两个可执行文件并尝试添加到路径中。它们位于
/home/user/folder
具体文件是
/home/user/folder/app1
/home/user/folder/app2
app1 和 app2 都将可执行标志设置为 all(用户、组、其他)。
如果我在 /home/user/folder 中,我可以执行文件并执行这些命令
./app1
./app2
但是我不能从其他地方运行它们。我将此行添加到我的 .profile
PATH="$PATH:/home/user/folder"
然后用
. /home/user/.profile
当我使用命令完成(按标签)时,我可以看到 app1 和 app2。但是,当我尝试使用以下命令运行 app1 或 app2 时会发生这种情况(以下仅显示“app1”,但“app2”也是如此)
user@comp:~$ app1
-bash: app1: command not found
user@comp:~$ /home/user/folder/app1
-bash: app1: command not found
user@comp:~/folder$ ./app1
(program runs)
我很难过:),我一定错过了一些简单的事情。谢谢你的帮助!!
更新
好的,我在我认为已修复的路径中发现了一些错误,但现在它无论如何都没有运行 - 出于某种原因,我认为这是向前迈出的一步。感谢您建议以下步骤,这是他们的输出:
user@computer:~$ echo $PATH
/usr/share/fsl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/matlab/bin:/usr/local/VoxBo/bin:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron:/usr/lib/voxbo/bin:/home/user/folder:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11/:/usr/games/:/usr/local/matlab/bin:/usr/local/VoxBo/bin/:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron/
user@computer:~$ typeset -p PATH
declare -x PATH="/usr/share/fsl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/matlab/bin:/usr/local/VoxBo/bin:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron:/usr/lib/voxbo/bin:/home/user/folder:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11/:/usr/games/:/usr/local/matlab/bin:/usr/local/VoxBo/bin/:/usr/local/itt/idl64/bin:/usr/local/afni/bin/:/usr/local/mricron/"
user@computer:~$ type app1
app1 is /home/user/folder/app1
user@computer:~$ type app2
app2 is /home/user/folder/app2
user@computer:~$ app1
bash: /home/user/folder/app1: No such file or directory
user@computer:~$ app2
bash: /home/user/folder/app2: No such file or directory
user@computer:~$ /home/user/folder/app1
bash: /home/user/folder/app1: No such file or directory
user@computer:~$ /home/user/folder/app2
bash: /home/user/folder/app2: No such file or directory
user@computer:~$ cd /home/user/folder
user@computer:~/folder$ app1
bash: /home/user/folder/app1: No such file or directory
user@computer:~/folder$ ./app1
bash: ./app1: No such file or directory
user@computer:~/folder$ ./app2
bash: ./app2: No such file or directory
user@computer:~/folder$ ls -l
total 29384
-rwxr-xr-x 1 user user 14949776 2011-02-03 11:09 app1
-rwxr-xr-x 1 user user 15137300 2011-02-03 11:10 app2
user@computer:~/folder$
感谢大家的投入!
我知道其中一些是重复的……但是……
编辑您的 BASH RC 文件:
导出路径:
如果您不想再次登录以获取路径,请 SOURCE 它:
确保该文件是您的并且可执行:
尝试运行:
还是出现command not found错误?那么,app1 和 app2 是什么样的文件呢?
如果它们是文本文件,则它们可能是脚本,例如 BASH 或 Python。如果是这样,请使用编辑器打开它们,看看您是否可以收集问题的根源。如果您粘贴文本文件的任何内容(如果它们确实是文本文件),请务必包含第一行 - 例如#!/bin/sh之类的“文件魔术” 。