LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-19-2009, 10:19 AM   #1
geo_diver
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
how to make ./ not necessary when executing


hi, when i want to execute a file in the terminal it always makes me type ./ first, is there something i can edit to have it so i don't have to type ./?
 
Old 06-19-2009, 10:23 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You can add the current directory to the PATH variable. In ~/.bashrc (or ~/.bash_profile)
Code:
PATH=$PATH:.
export PATH
Some people might advise against having the current directory in your PATH if you're root.

Last edited by pwc101; 06-19-2009 at 10:25 AM. Reason: added .bash_profile
 
Old 06-19-2009, 10:25 AM   #3
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 69
Yes, you just have to include . (the current directory) in the PATH variable. Some distros put . in the PATH for the ordinary users, but never for root.

In ~/.bashrc file, try putting something like this

PATH=$PATH:.
 
Old 06-19-2009, 10:26 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Depending on what shell, terminal, desktop, distribution, etc. you are using, there are a bunch of different places you might add or change an export of the PATH variable.

The most likely (not knowing any the details of your system) is ~/.bashrc

Edit that file. Did it already exist? Did it already include a line starting
export PATH=
If so, you can add .: right after the =
If the line wasn't there, you could add
export PATH=.:$PATH

Quote:
Originally Posted by Uncle_Theodore View Post
PATH=$PATH:.
I only partially understand the behavior you get by defining PATH without exporting it. I don't think it is the desired behavior.

Adding . at the end of PATH rather than the beginning means it would find programs in . only if the same program is not elsewhere in the path. Again, I think that is not the desired behavior (though I understand why some people might want that behavior).

Last edited by johnsfine; 06-19-2009 at 10:33 AM.
 
Old 06-19-2009, 10:32 AM   #5
saivin
Member
 
Registered: Dec 2008
Location: Bengaluru, India
Distribution: CentOS, openSUSE, Mandriva, Slackware
Posts: 111

Rep: Reputation: 19
The files we edit may probably differ from distro to distro. But, I learnt that all environment variables go into .bash_profile and aliases etc go into .bashrc. So, the PATH variable is preferably put in .bash_profile.

Secondly, if I'm right '.' is not necessary to indicate current directory. Just ending the PATH with ':' should do. As,
Code:
echo 'PATH=$PATH:' >> .bash_profile
. .bash_profile
The second line is to restart bash_profile.
 
Old 06-19-2009, 10:47 AM   #6
geo_diver
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
thanks everybody,
after trying all those suggestions, it appeared to only work in the bashrc file, though i do have a profile file too. but all the different methods worked and i can now compute worry free. but please, do tell, what is a distro?
 
Old 06-19-2009, 10:52 AM   #7
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 69
Quote:
Originally Posted by johnsfine View Post
I only partially understand the behavior you get by defining PATH without exporting it. I don't think it is the desired behavior.

Adding . at the end of PATH rather than the beginning means it would find programs in . only if the same program is not elsewhere in the path. Again, I think that is not the desired behavior (though I understand why some people might want that behavior).
Yeah, you're right, I forgot to put "export" before the definition.
As to the other thing, I'd rather have the dot at the end of PATH. Precisely for the reason you've stated. The command is looked up in the current directory only if it's not found elsewhere. Somehow it seems right for security reasons and also prevents certain mess when a program compiled by the user accidentally has the name used in the system.
 
Old 06-19-2009, 10:54 AM   #8
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 69
Quote:
Originally Posted by geo_diver View Post
thanks everybody,
after trying all those suggestions, it appeared to only work in the bashrc file, though i do have a profile file too. but all the different methods worked and i can now compute worry free. but please, do tell, what is a distro?
"Distro" is a slang form of "distribution". Like Ubuntu, Gentoo, Slackware, Fedora etc.
 
Old 06-19-2009, 01:52 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,093

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
now if the command you are wanting to run is
configure , make , make install
DO NOT put that folder path into the system path !!!!

But if it is a program that you installed , say Gimp ( i build and install it in it's own folder) then DO put it in the system path
 
Old 06-19-2009, 01:58 PM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
Is it really too much trouble typing ./ before a command?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error executing make command for xmlrpc-c 1.06.32 tarball version jayamurugan Linux - Software 3 04-17-2009 06:34 AM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM
executing file dontknowshit Mandriva 2 06-10-2004 08:28 PM
problem with executing "make menuconfig" foxy17 Slackware 9 09-14-2003 07:17 AM
make dep,make clean,make bzImage problem Babba Linux - Newbie 2 01-08-2003 03:49 AM


All times are GMT -5. The time now is 03:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration