Go Back   Steam Users' Forums > Steam Discussions > Off Topic

Reply
 
Thread Tools Display Modes
Old 09-12-2011, 05:22 PM   #1
oi u agree
 
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?
oi u agree is offline  
Reply With Quote
Old 09-12-2011, 05:39 PM   #2
Levi
 
Join Date: Oct 2009
Reputation: 3234
Posts: 8,265
If I remember right, its something like

export PATH=$PATH:./

Put that in your .bashrc
Levi is offline   Reply With Quote
Old 09-12-2011, 05:42 PM   #3
sad_ism
 
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 ?
sad_ism is offline   Reply With Quote
Old 09-12-2011, 05:45 PM   #4
Modiga-Disabled
 
Modiga-Disabled's Avatar
 
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
Modiga-Disabled is offline   Reply With Quote
Old 09-12-2011, 08:18 PM   #5
bdmason
 
 
 
Banned
Join Date: Oct 2007
Reputation: 2103
Posts: 504
Quote:
Originally Posted by Modiga-Disabled View Post
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).
The general idea is that if you are permanently adding executable files then you should add them to your .bashrc. If you are simply using the application on a short-term basis, it's better to just execute
Code:
export PATH=$PATH:./
from the command line and run your programs and that export will disappear when you close that shell.

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.
bdmason is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Discussions > Off Topic


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -7. The time now is 12:21 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.