|
|
#1 |
![]() Join Date: Mar 2010
Reputation: 858
Posts: 88
|
How to execute a binary/script in Linux without a "./" in front of it?
For example, I just compiled a C++ program that uses command line arguments. However, everytime I want to run it, I have to type "./" in front of it, i.e. "./runit argument1 argument2" in order to run the program. How do I make it so that I don't have to type ./ in front of it every time?
|
|
|
|
|
|
#2 |
![]() Join Date: Oct 2009
Reputation: 3234
Posts: 8,265
|
If I remember right, its something like
export PATH=$PATH:./ Put that in your .bashrc |
|
|
|
|
|
#3 |
![]() Join Date: Sep 2010
Reputation: 1463
Posts: 77
|
Ya gotta add it to some folder in root, to make it recognized immediately by bash. Maybe /usr or /bin/ or /usr/local/bin ?
|
|
|
|
|
|
#4 |
|
Volunteer Moderator
Join Date: Nov 2004
Reputation: 10015
Posts: 9,967
|
http://home.ubalt.edu/abento/linux/t...addtopath.html
That should do it. Although I was shown to do it by editing the .bashrc file. I'm not sure which is the better option (I'm still a Linux noob). __________________ It's hard to be humble when you know how to rumble! Need something? PM me or contact support | Join us in SPUFU chat |
|
|
|
|
|
#5 | |
|
Banned
Join Date: Oct 2007
Reputation: 2103
Posts: 504
|
Quote:
Code:
export PATH=$PATH:./ However, if you are permanently adding executable files, consider putting them in /bin or /usr/bin depending on how critical it is for system execution is. If memory serves, programs usually go into /bin if they are system-critical. i.e. something that helps the system boot or critical tools for using and maintaining the system. Programs that are not so critical go into /usr/bin. Also, not many people know this, but in ubuntu if you add a "bin" directory in your home directory the system will automatically check to see if the program you want to run is in that directory without setting anything up. You don't even need to be in the same directory. I could be in /media/storage/scoobydoo and run the "shaggy" program and if shaggy is in /home/user/bin it will find it. At least that's how it works on my system and I never configured it special to do that. |
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|