ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Got a quick question:
I am trying to run scripts in Red Hat 9.0, I include the #!/bin/bash directive, so I try to run the script my typing its name, nothing. If I type "bash script_name" it will run fine. Any way to get around the bash command?
I do not get any error, it just hard returns back to by prompt. I set the file permission to 777, and I am in the correct directory. The ./ worked...I thought there was a way to make it work by just typing the file name...am I wrong?
To be more precise, you either need to specify the directory where the script is (e.g. ./your_script, or /home/yourname/your_script, etc.) or put it in a directory listed in the PATH environment variable (seperated by colons ':'). Normally the directories /usr/local/bin:/usr/bin:/bin are in the PATH var. This is arranged by your distribution. To see the directories where the shell will find the script by itself through the PATH var, type:
If you put your script in one of the directories you see, you can just type its name (without ./ ).
You can also include a directory of your choice to the PATH var, say the directory "myscripts" in your home directory. Make sure this dir exists, put you script there, and type:
By convention a directory named "bin" is used for this. Some distributions arrange for the bin directory as a subdir of your homedir to be included automatically. This is done by some lines in your ~/.bashrc or ~/.bash_profile or maybe ~/.profile. These lines resemble somthing like:
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
To have you custom dir "/home/yourname/myscripts" permanently in the PATH var. Add the following line at the end of your ~/.bashrc or ~/bash_profile:
FYI: You can also put "." in your PATH and then the current directory is searched, much like in DOS. Generally, however, this is not recommended, though I personally prefer it for my non-root development user.
e.g. put in your ~/.bashrc:
Or something of the sort. If you do put "." in your PATH, you should make it the last thing in the PATH.