关于linux下可执行文件的疑问
我有一个用 C 编写的程序,名为computeWeight.c,为了编译它,我使用以下代码,
chaitu@ubuntu:~$ gcc -Wall -o computeWeight computeWeight.c
//to execute it:
chaitu@ubuntu:~$ ./computeWeight
我是否有任何可以直接使用的机制,如下所述,
chaitu@ubuntu:~$ computeWeight
我是否应该更改可执行文件的任何权限来获得此权限?
I have a program written in C, which is named computeWeight.c and to compile it i use the following code
chaitu@ubuntu:~$ gcc -Wall -o computeWeight computeWeight.c
//to execute it:
chaitu@ubuntu:~$ ./computeWeight
Do i have any mechansim where i can directly use as mentioned below,
chaitu@ubuntu:~$ computeWeight
Should i be changing any permissions on the executable to get this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要添加“。”到你的道路。不过,有些人认为这很危险。例如,请参见 http://www.arsc.edu/support/policy/dotinpath.html 。
You need to add "." to your path. Some people regard this as dangerous, though. See for instance http://www.arsc.edu/support/policy/dotinpath.html .
$PATH 变量定义 linux 查找可执行文件的位置(尝试在终端中输入 echo $PATH)。您需要将该文件放在这些位置之一。一种方法是在主目录中添加一个 bin 文件夹,将可执行文件放在那里,并将此行(将主文件夹中的 bin 目录添加到搜索路径)添加到 .cshrc 文件中,以便执行它对于每个 shell:
话虽如此,我认为输入 ./ 并没有那么糟糕。
The $PATH variable define the places where linux would look for executables (try typing echo $PATH in a terminal). You need to put that file in one of those places. One way is to add a bin folder in your home directory, put the executable file there, and add this line (which adds the bin directory in your home folder to the search path) to your .cshrc file so that it'd be executed for every shell:
With that said I don't think typing ./ is that bad.
导出路径=$路径:.
export PATH=$PATH:.