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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-05-2004, 12:49 PM
|
#1
|
|
Member
Registered: Oct 2003
Posts: 32
Rep:
|
Linux Executable File Help (created from a .c file)
Okay .. I am a linux newb but I have to learn it for a college class I am taking. Here is my problem. At school, on their computers, I create the .c file in vi, and then run gcc on it and create the executable file (for this example, we'll call it 'example'). Then from the command line, you just type example and it runs.
On my computer at home (RH9 ... same as at school), I write the program in vi, compile it (no splint errors) and the executable is created without a problem. but when i type in 'example' to run the program, i get an error which says something like:
bash:example:no command found ... or something like that.
Can someone help me, is it a bash setting that I have to change?
also, Same problem happens when I downloaded firefox .. you should just type in firefox in the terminal (in the right directory of course) and it should run, but I get a bash:firefox:no command found ...
|
|
|
|
06-05-2004, 01:28 PM
|
#2
|
|
Moderator
Registered: Aug 2002
Posts: 10,700
|
unlike windows linux does not search the current working directory for a command. It only searches using the path environment. At school, that directory must be in the path.
./ is a shortcut for current working directory. To execute your program:
./your_program_name
|
|
|
|
06-05-2004, 01:44 PM
|
#3
|
|
Member
Registered: Oct 2003
Posts: 32
Original Poster
Rep:
|
That worked, thanks!
Is there any way that I can make it search the pwd automatically?
|
|
|
|
06-05-2004, 01:53 PM
|
#4
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
You can add the current directory to your PATH variable.
Open the your bash profile:
vi ~/.bash_profile
Search for: PATH=something
At the end of the line append ":."
Save the file and exit vi
Then execute:
source ~/.bash_profile
Now, the current directory will be included in the search path.
|
|
|
|
06-06-2004, 11:54 AM
|
#5
|
|
Member
Registered: Oct 2003
Posts: 32
Original Poster
Rep:
|
I am having a hard time find my .bash_profile file ... when I type in vi ~/.bash_profile, it opens up a new blank file in the vi editor.
|
|
|
|
06-06-2004, 12:58 PM
|
#6
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
That's not a problem. Although, I assumed most Linux distributions would install one for each user whether it was empty or not.
No matter... Here is the entire contents of my ~/.bash_profile (it is the default Red Hat includes)
Code:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
It's very simple. Lines starting with a # are ignored; they are comments to help the reader understand what the script is doing. First, it tests whether a file named ~/.bashrc exists, and if it does, it sources the file (in a shell script, the period (.) is usually a short-hand for the source command). Then it sets the PATH environment variable and "exports" it (makes it a global value in a sense. The "unset USERNAME" is probably a Red Hat thing and could be wiped (along with the bashrc stuff) if you're so inclined.
Anyway, just modify the PATH line above like mentioned earlier:
Code:
PATH=$PATH:$HOME/bin:.
Save the file, then "source ~/.bash_profile" and that will be it.
|
|
|
|
06-06-2004, 04:45 PM
|
#7
|
|
Member
Registered: Oct 2003
Posts: 32
Original Poster
Rep:
|
got it! thanks!
I have another question not on this topic .. might as well see if one of you guys can answer it. I went to download the nvidia drivers and it says that I have to exit out of any x-server (gui .. ) setups and I have to run the program from a truly command prompt mode ... how do I enter into just the command prompt?
At the bootup scrren the only options are failsafe, kde, ... etc, but none of those are truly command prompt or whatever it is called.
You guys know what to do?
Oh, and thanks for all the help thus far.
Matt
|
|
|
|
06-06-2004, 04:54 PM
|
#8
|
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 3,816
Rep: 
|
Type "init 3" at a command prompt -- that will move the machine down to runlevel 3, which on Red Hat idoes not start X Windows automatically.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:25 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|