Using Initialization Files Correctly

Problem

You’d like to know just what the heck is with all the initialization, or rc, files.

Solution

Here’s the cheat sheet for files and what do with them. Some or all of these files may be missing from your system, depending on how it is set up. Systems that use bash by default (e.g., Linux) tend to have a complete set; systems that use some other shell by default are usually missing at least some of them.

/etc/profile

Global login environment file for Bourne and similar login shells. We recommend you leave this alone unless you are the system administrator and know what you are doing.

/etc/bashrc (Red Hat) /etc/bash.bashrc (Debian)

Global environment file for interactive bash subshells. We recommend you leave this alone unless you are the system administrator and know what you are doing.

/etc/bash_completion

If this exists, it’s almost certainly the configuration file for Ian Macdonald’s programmable completion library (see Improving Programmable Completion). We recommend looking into it—it’s pretty cool.

/etc/inputrc

Global GNU Readline configuration. We recommend tweaking this as desired for the entire system (if you are the administrator), or tweaking ~/.inputrc for just you (Getting Started with a Custom Configuration). This is not executed or sourced but read in via Readline and $INPUTRC, and $include (or bind -f). Note that it may contain include statements to other Readline files.

~/.bashrc

Personal environment file for interactive bash subshells. ...

Get bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.