Linux Executable File Help (created from a .c file)
Linux - NewbieThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ...
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.