LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-26-2004, 01:34 AM   #1
SamerAdra
LQ Newbie
 
Registered: Mar 2004
Location: Kansas
Distribution: Mandrake 10.0
Posts: 21

Rep: Reputation: 15
noobie bash command question


Is it necessary to always type the full path name to run an executable in a shell? In the labs, I've always been able to just the program, but I installed Mandrake 10 at home, and when I type just the file name, which is hw3, I get "bash: hw3: command not found," but it works when I type the full pathname /home/myusername/Desktop/hw3/hw3
It won't work with any other programs I compile either (command used was g++ Queue.cpp Stack.cpp hw3.cpp -o hw3, for what it's worth. When I type ls, I get hw3* with an asterisk after it, and it is in green...weird.
Thanks,
-Samer
 
Old 10-26-2004, 01:52 AM   #2
theonebeyond
Member
 
Registered: Aug 2004
Location: Germany
Distribution: Slackware 10.0
Posts: 258

Rep: Reputation: 30
you don't have to call the whole path every time...

If you are the the directory with the programm you would like to call, run it this way:

./programm

If you are not in the directory you wether have to call it with the pathname or you put the path to the programm into your environment-variable named $PATH ... it is set in .bashrc or .bash_profile I think. So just add path's as needed.

If you compile a programm, you can test-run it in it's directory like I said above. But if you install the programm ("make install"), it will go to /usr/bin or /usr/local/bin, and those should be in your path.

Greetings, Sascha

Last edited by theonebeyond; 10-26-2004 at 01:54 AM.
 
Old 10-26-2004, 01:56 AM   #3
SamerAdra
LQ Newbie
 
Registered: Mar 2004
Location: Kansas
Distribution: Mandrake 10.0
Posts: 21

Original Poster
Rep: Reputation: 15
cool beans.
thanks.
so, at the computer lab when i haven't been having to type ./ in front of stuff, what's the deal with that? (just curious) maybe they assumed we'd all be s like me and it'd be too tricky so they aliased it somehow? heh
-Samer

Edit: Hey, while I'm at it, is there a bash command equivalent to the DOS cls (clear screen) command? I like to free myself of my mess occasionally.

Last edited by SamerAdra; 10-26-2004 at 02:01 AM.
 
Old 10-26-2004, 02:02 AM   #4
theonebeyond
Member
 
Registered: Aug 2004
Location: Germany
Distribution: Slackware 10.0
Posts: 258

Rep: Reputation: 30
The only way I know to get rid of the ./ (which is a path too) is to put the dir with the programms into the $PATH-variable ... don't know any other way. So if you run programms without any path in front of it, it is propably stored in /usr/bin or /usr/local/bin or similar or maybe in ~/bin.

Greetings, Sascha
 
Old 10-26-2004, 03:15 AM   #5
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
To run programs that are in the current directory without using a ./, add the following lines to your .bash_profile file:
Code:
PATH=.:$PATH
export PATH
Be careful though, it is best not to do this for root for security purposes.

You could also create a directory ~/bin as suggested above, by doing this:
Code:
PATH=/home/yourname/bin:$PATH
export PATH
I hope this helps
--Ian
 
Old 10-26-2004, 03:42 AM   #6
mjjzf
Member
 
Registered: Feb 2004
Location: Valby, Denmark / Citizen of the Web
Distribution: Slackware 14.1
Posts: 879

Rep: Reputation: 39
If you enter command/program name (without the path), the system will look for it in the folders specified in the PATH. If you enter ./command/program name, the system will look for it in your current folder.
 
  


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
noobie question about rc.d file bob cashman Ubuntu 3 07-15-2005 11:31 AM
Trivial bash question - executing $COMMAND atom Programming 4 06-05-2005 05:17 AM
Bash Scripting - echo command question gbhil Programming 2 04-27-2005 08:27 PM
bash command question BajaNick Linux - Software 8 10-05-2003 08:56 PM
Very NOOBIE type question...weird though tarballed Linux - Newbie 4 03-20-2003 10:53 PM


All times are GMT -5. The time now is 06:29 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