bashrc

.bashrcBash Configuration File

GNU Project · 1989

Developer
GNU Project
Category
Programming
MIME Type
text/x-shellscript
First Released
1989
Open Format
Yes
File Signature
N/A (plain text file)
At a Glance
.bashrc
Bash Configuration File

A .bashrc file is a script that customizes your Bash shell environment by setting up aliases, variables, and commands when you open a new terminal.

Reviewed on July 26, 2026
Compression
Plain text
Transparency
N/A
Editability
High
Best for
Shell customization

Key Features

  • Customizes interactive shell startup.
  • Supports environment variable definitions.
  • Allows creation of command aliases.
  • Enhances user-specific shell configurations.

Best For

  • Personalizing your command-line experience.
  • Streamlining repetitive commands with aliases.
  • Setting up your development environment variables.
  • Creating a consistent shell setup across sessions.

Less Ideal For

  • Storing sensitive credentials or passwords.
  • Complex application logic or graphical interfaces.
  • System-wide configurations (use system-wide profiles instead).
  • Non-interactive or login shell startup.

Common Use Cases

  • Setting up custom command aliases (e.g., `alias ll='ls -alF'`).
  • Defining or modifying environment variables (e.g., `export EDITOR=vim`).
  • Customizing the shell prompt appearance.
  • Loading specific shell functions or scripts.

How to Open It

  1. Open your terminal application.
  2. Use a text editor with the command `nano ~/.bashrc` or `vim ~/.bashrc`.
  3. To apply changes immediately, run `source ~/.bashrc` in your current terminal.

What is a .bashrc file?

A .bashrc file is a shell script that Bash (Bourne Again SHell) runs whenever an interactive non-login shell session starts. It's primarily used to customize your command-line environment by setting up aliases, defining environment variables, and configuring shell behavior. Think of it as a personalized startup script for your terminal. By modifying this file, you can streamline your workflow, add custom commands, and tailor the shell to your specific needs and preferences.

Programs That Open .bashrc Files

PlatformProgram
WindowsWindows Subsystem for Linux (WSL)FreeOfficial
Git BashFree
macOSTerminal.appFreeOfficial
iTerm2Free
LinuxGNOME TerminalFreeOfficial
KonsoleFreeOfficial
Xfce TerminalFreeOfficial

Common Problems with .bashrc Files

⚠️ Changes not taking effect.
Ensure you have saved the file and reloaded the shell configuration by running `source ~/.bashrc` or by opening a new terminal window.
⚠️ Syntax errors breaking the shell.
Carefully check for typos, missing quotes, or incorrect command syntax. If you can't access your terminal, try booting into recovery mode or editing the file from another user account or a live environment.
⚠️ Overwriting important system defaults.
Be cautious when modifying system-wide settings. It's generally recommended to keep personal customizations in your user's .bashrc file rather than altering global configuration files.

Frequently Asked Questions

What is the difference between .bashrc and .bash_profile?

.bashrc is typically executed for interactive non-login shells, while .bash_profile is for login shells. Many users configure .bash_profile to source .bashrc to ensure customizations are available in both scenarios.

Can I put any command in .bashrc?

Yes, but it's best to only include commands that are relevant to customizing your shell environment and that execute quickly, as they run every time a new interactive shell starts.

Where is the .bashrc file located?

It is located in your home directory (e.g., `/home/username/.bashrc`).

Technical Details

The .bashrc file is a plain text file containing Bash commands. When a new interactive shell session begins, Bash executes these commands. This allows for the persistent definition of environment variables (like PATH), the creation of custom shortcuts via aliases, and the configuration of shell options such as command completion or prompt appearance.

Did You Know?

The '.' at the beginning of the filename makes it a hidden file on Unix-like systems.
It's a core component of the user experience for many developers and system administrators working on Linux and macOS.

Security Information

Be cautious about executing scripts from untrusted sources in your .bashrc file, as they will run automatically in your shell environment. Always review the content before adding it.

Related Extensions