How do I run executables without the ./ part?
This is probably a dumb question.
I have an executable file HelloWorld in a subfolder of my home directory. I can only make it run if I include the path: ./HelloWorld. I want to make it run only by typing HelloWorld without the ./ part. Any idea how to do this? I am running the bash shell. |
You need the ./ in there. Otherwise linux thinks your trying to use an internal command rather then a binary file
|
You should only have to do this as the root user, unless its some kind of debian thing, that is... I dont know about that... it's a type of safety thing.
But to answer your question... If you want to run this file as root without having to put ./ in front then you need to put it into roots search path. if you type "echo $PATH" then that will print out your search path and will look like this.. $ echo $PATH /home/owen/bin:/usr/local/bin:/usr/bin:..... So copy the file to /usr/bin or one of the dirs that are in your PATH and then you can run that file from any directory ;) |
Its because Linux has a default search path for executable files ..... you can find the default search path from the console with the
echo $PATH For example mine is; /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/svha/bin So you can either move helloworld into one of your default PATH directories, or you can add the folder that contains the helloworld program into your default path (The link should assist you with doing that) http://www.linux-tutorial.info/cgi-b...8&9998&388&0&3 Svha |
as above it is a path issue. i'd advise you to try to go with the flow where possible though, don't fight the linux conventions, as they are there for very good reasons. if you do add anythign to it, please try to use a fixed bin/ directory, not your home directory or such like.
Quote:
|
Ah well guess Ill just get used to it, helloworld probably isnt important enough to dump in the shared binaries folder. Thanks for the help.
|
you could also just place a symlink to it in /usr/bin.
|
hi
this is a security feature. if you have a program you created which you called ls and which actually deletes files. if you just type ls the internal command will get executed. if you type ./ls your program will get executed. so you know which one is yours and which one is built in. it will prove very useful if you are system admin. even if you are not this is a safety feature. you can add the current directory to the path but dont do it regards rahul sundaram |
Re: How do I run executables without the ./ part?
Quote:
basically; # cd /usr/bin # ln -s /home/username/HelloWorld/whatever helloworld That'll do it. Or you can just move/copy the HelloWorld thingie to /usr/bin/. Good luck. Edit: oh sry, didn't notice the previous post about it... ;) |
Quote:
One of the exciting things about using a new OS is that you learn to work with all its new aspects, not trying to clone it into a WIndows-like system. If there's something you need done repetitively, try writing a script to do it. Also, tab completion is your friend :) |
All times are GMT -5. The time now is 05:42 PM. |