开发者

Doubt regarding executable files in linux

开发者 https://www.devze.com 2022-12-29 08:02 出处:网络
I have a program written in C, which is named computeWeight.c and to compile it i use the following code

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?开发者_如何学Go


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 .


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:

set PATH = ($PATH $HOME/bin) 

With that said I don't think typing ./ is that bad.


export PATH=$PATH:.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号