Friday, January 22, 2010

.bashrc vs. .bash_profile

One continuing source of confusion among bash users is the question "Where should start-up settings go?"

As you may recall, bash reads startup files when it starts.  These startup files are used to establish the user's environment including environment variables like PATH, command aliases, and programs to launch when the user logs in.

Shell sessions can be divided into two different types: login shells and non-login shells.  bash uses different startup files for each type.

A login shell occurs when the user is prompted for a user name and password.  Examples include virtual consoles (accessed by pressing Ctrl-Alt-F1 through Ctrl-Alt-F6) and terminal sessions on remote hosts using ssh or telnet.

A non-login shell is typically a terminal session launched on the graphical desktop.

Startup files can also be divided into two groups: global and personal.  Global startup files are located in the /etc directory and apply to all users while personal startup files are located in each user's home directory.

So let's look at which files are read for each type of shell session:

Non-Login Shells

bash reads and executes the global startup file /etc/bash.bashrc followed by the personal file ~/.bashrc if they exist.

Login Shells

bash reads and executes the global startup file /etc/profile if it exists.  Next, it attempts to read and execute ~/.bash_profile, ~/.bash_login, and ~/.profile in that order, stopping after the first file is found.  Red Hat distributions by default supply ~/.bash_profile, while Debian distributions (such as Ubuntu) use ~/.profile.

Adding Your Own Settings

If you study the contents of either ~/.bash_profile or ~/.profile, you will see that both files source (i.e., read in the contents of) the ~/.bashrc file.  This means that ~/.bashrc is read during the startup of both login and non-login shells, so putting your changes in ~/.bashrc is usually a safe bet.

Further Reading

The Linux Command Line covers this in Chapter 12.

The INVOCATION section of the bash man page contains a full description of the the bash startup process.

Wednesday, January 20, 2010

In Praise Of Panix

During the editing of my book, one of my reviewers suggested that it would be cool if there could be an on-line shell host that readers could use to play with command line stuff while reading the book.  While this is an interesting idea, it's not really practical for me to do.

If you have ever received an email from me, you know that my email address contains the domain "panix.com."  What is Panix?  Therein lies a tale.

Panix (short for Public Access Network Corp.) is a small, regional ISP located in New York City.  According to Wikipedia, it is also the third oldest ISP in the world.  They do the usual ISP stuff plus something special.  They provide shell accounts.  In fact, one of their slogans is "Your $HOME Away From Home."  Here is a quote from their web site:

Panix has been providing shell accounts and Internet connections since 1989 —nearly twenty years! During that time we've developed a reputation for technical know-how, reliability and customer service unmatched by today's Internet "superstores". If you're looking for access to a professionally-maintained UNIX host, with the latest versions of all your favorite newsreaders, mailers, compilers and internet clients —and if you want your home and email address to be good for the rest of your life, not just until some DotCom.CEO decides that shell services aren't profitable enough to keep running— you want a Panix account.

We are all shell users ourselves, and we are shell snobs. We know a well-maintained UNIX shell is indispensable for serious programmers, web developers and net fiends. Nothing else gives you as much control over your operating environment, nothing else is as flexible. You know that, we know that, and that is why Panix will always make shell access our first service.

I'm not sure when I started using Panix, probably around 1996 and they have been my faithful partner ever since.  Now since I don't live in NYC, I don't use Panix for my Internet connectivity.  I'm a Verizon FiOS customer at present, but you can still use Panix even if they are not your "primary" ISP.

Panix offers an account called a "No-dial: Full Shell, Remote Login Only" which allows you to use SSH to reach your Panix shell account.  From there you can access a huge array of command line programs and tools.  Included with the account is web hosting, email (accessible directly from the shell with a text mail reader, or remotely via POP or IMAP), USENET access, and 500 MB of disk storage.

In addition to the services, there is the Panix community.  Panix maintains their own hierarchy of USENET newsgroups for access within the Panix system.  Here you will find a vibrant collection of Unix people and other colorful characters.  There is also frequent interaction with the system administrators who are very experienced and knowledgeable.  You can learn a lot just hanging around.

The No-dial account costs $10/month or $100/year if you prepay.



So if you want to experience what a large, multi-user Unix system (they run NetBSD) is like, give them a look

Monday, December 14, 2009

The Linux Command Line - First Edition Is Now Available!

After a two year effort, I have released the first edition of "The Linux Command Line" in all of its 522 page glory!

I want to give special thanks to Mark Polesky for his extraordinary review and test of the book, as well as the rest of the review team: Jesse Becker, Tomasz Chrzczonowicz, Michael Levin, and Spence Miner.

Special thanks also go out to Karen Shotts for editing all of my so-called English.

To download the free PDF version of the book, go to https://sourceforge.net/projects/linuxcommand/files/ and get the file TLCL-09.12.pdf.

You may also purchase a printed version of the book in large, easy-to-read format (which is, in fact, very handy) by going to: http://www.lulu.com/content/paperback-book/the-linux-command-line/7594184

Enjoy!

Thursday, November 19, 2009

The Linux Command Line - Fourth Draft Now Available

The fourth draft of the book is now available. This version contains almost all the the review feedback received so far and has been edited through the final chapter. This draft does not yet include an index, but is otherwise close to being finished.

The new draft, named TLCL-09.11.pdf, is available here.

Enjoy!

Saturday, October 3, 2009

The Linux Command Line - Third Draft Now Available

The third draft is now available. This version features reformatted and captioned tables, some of the changes suggested by the review team (more to follow), and a number of small additions. It also includes the edited versions of the first 18 chapters.

If you are working on the review, please switch to this version. The new draft, named TLCL-09.10.pdf, is available here.

Thanks for your help!