LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-05-2003, 09:08 AM   #1
Abdul
LQ Newbie
 
Registered: Oct 2003
Distribution: Debian 3.0r1 Woody
Posts: 27

Rep: Reputation: 15
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.
 
Old 10-05-2003, 10:23 AM   #2
kaega2
Member
 
Registered: Sep 2003
Location: Ontario, Canada
Distribution: Gentoo 2004.3
Posts: 195

Rep: Reputation: 30
You need the ./ in there. Otherwise linux thinks your trying to use an internal command rather then a binary file
 
Old 10-05-2003, 10:30 AM   #3
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
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

Last edited by fatgod; 10-05-2003 at 10:32 AM.
 
Old 10-05-2003, 10:31 AM   #4
Svha
LQ Newbie
 
Registered: Jul 2003
Posts: 24

Rep: Reputation: 15
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
 
Old 10-05-2003, 10:36 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
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:
You need the ./ in there. Otherwise linux thinks your trying to use an internal command rather then a binary file
Sorry, but that is very wrong...
 
Old 10-05-2003, 12:37 PM   #6
Abdul
LQ Newbie
 
Registered: Oct 2003
Distribution: Debian 3.0r1 Woody
Posts: 27

Original Poster
Rep: Reputation: 15
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.
 
Old 10-05-2003, 12:47 PM   #7
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 48
you could also just place a symlink to it in /usr/bin.
 
Old 10-05-2003, 11:43 PM   #8
rahulsundaram
Member
 
Registered: May 2003
Location: India
Distribution: Knoppix, RedHat
Posts: 246

Rep: Reputation: 30
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
 
Old 10-06-2003, 01:22 AM   #9
dekket
Member
 
Registered: Oct 2003
Location: sweden
Distribution: debian
Posts: 47

Rep: Reputation: 15
Re: How do I run executables without the ./ part?

Quote:
Originally posted by Abdul
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.
No problem, do a symlink in your $PATH, such as /usr/bin/..
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...

Last edited by dekket; 10-06-2003 at 01:23 AM.
 
Old 10-06-2003, 01:40 AM   #10
miknight
Member
 
Registered: Oct 2002
Location: Sydney, Australia
Distribution: Gentoo, Ubuntu, Debian
Posts: 184

Rep: Reputation: 30
Quote:
Originally posted by acid_kewpie
don't fight the linux conventions, as they are there for very good reasons.
This is true - and they're not just Linux conventions, they're part of the POSIX standard (i.e. basically a UNIX convention).

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
 
  


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: "c compiler cannot create executables" when trying to run ./configure fedoraemu Linux - Software 2 04-24-2007 08:43 PM
Executables dudeman41465 Linux - Software 4 10-09-2005 08:59 PM
executables humblestudent87 Linux - Newbie 6 07-22-2004 12:42 PM
Executables q64 Linux - Newbie 3 03-29-2004 04:31 AM
Where are the executables? rooman Linux - Software 6 06-05-2002 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:57 PM.

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