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!
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.
I'm following along with linuxcommand.org on the command line and shell scripting. After writing the first script and getting it to run I'm instructed to add: export PATH=$PATH:home_directory to my .bash_profile so I will be able to run the script by typing: my_script rather than specifying the path: ./my_script. But I can't find it. All I have is bash_history, bash_logout, bashrc.
Just a side note: Only writing $PATH is telling the terminal to execute your path as if it were a command, which doesn't do anything. 'echo $PATH' is the way to have it print out the path.
I don't know about Ubuntu, but there should be a file called /etc/profile, which is a system-wide bash profile. At least in Slackware there's a line at the end specifically for the $PATH of non-root users. Maybe you'd want to use that instead. It's guaranteed to work.
Another thing I've noticed is when you 'logout', you have to logout completely, not just exit the current xterm.
GUI environments seem to cache your login settings when you first login & apply those to all child xterms.
A login shell is one whose first character of argument zero is a -, or one started with the --login option.
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to
terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a
shell script or a startup file to test this state.
The following paragraphs describe how bash executes its startup files. If any of the files exist but cannot be read, bash reports an error.
Tildes are expanded in file names as described below under Tilde Expansion in the EXPANSION section.
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands
from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that
order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is
started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these
files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from
file instead of /etc/bash.bashrc and ~/.bashrc.
Ok, so what does that mean for you? A terminal launched inside of X (Gnome, KDE, etc) is not a login shell, so you will have to put your path information into ~/.bashrc or /etc/bash.bashrc, since these are the only rc (run-control) files run when you launch a terminal window.
The same cannot be said if you log in from the console (i.e. if you get out of X using <ctrl><alt><F1>)... this will be a login shell and will use ~/.bash_profile, ~/.bash_login and ~/.profile.
Add "export PATH" at the end of your .bash_profile or .profile script. This moves a variable to your environment.
The .profile, .bash_login or .bash_profile script will be executed for a login shell. Bash looks for them in that order and executes the first one it finds.
For most distro's if you have a $HOME/bin/ directory, the /etc/profile script or $HOME/.profile script will add it to your PATH variable. Read your /etc/profile script and see if it does that. On my system, a profile script will also check for a $HOME/.bashrc script and source it if it exists. A bin/ directory in your home directory would be a better place for your personal scripts.