Customizing your Environment

The functioning of the Bash shell is controlled by a large number of configuration files. Here is a summary of the most important ones:

  • /etc/profile: If this file exists, Bash will evaluate it when you log in to your system. For most desktop users, this will only happen once per bootup. The file contains system-wide settings that are of a rather general nature. For example, the PATH variable is typically set in /etc/profile.
  • ~/.bash_profile: This file has the same purpose as /etc/profile, but it's located in a user's home directory and contains user-specific settings. ~/.bash_profile may also be called ~/.profile or ~/.bash_login. Make sure that only one of these files exists on your system to avoid confusion.
  • /etc/bash.bashrc (named /etc/bashrc on some systems): If this file exists, Bash will evaluate it each time you start a non-login shell, for example a terminal window. The file contains system-wide settings that are of a more specific nature. For example, the file commonly contains →alias definitions.
  • ~/.bashrc: This file is a user-specific version of /etc/bash.bashrc. It's the file that you'll need most often.

What to make of this confusing array of configuration files? On a desktop system, deciding what goes into which file is not terribly important; it's more a matter of aesthetic considerations. As a general rule, save the configurations that you want root and your regular user to share in the system-wide files /etc/profile and /etc/bashrc, and save your regular user-specific settings in ~/.bashrc. Many desktop users only use this latter file and are fine with it. In the remainder of this book, you'll learn about some useful settings that you can put in your ~/.bashrc.

This concludes our short intro to the command line. Type exit to quit the shell, or delve into the following chapters and learn more commands. Above all, have fun! Remember that the first version of Linux was written by Linus Torvalds just for fun, and this shines through in many aspects of the operating system. Try not to learn lists of commands and their options by rote. Experiment, discover, and get in touch with other Linux users on the Internet. This book was written in a way that supports learning by discovery. May it serve you well.