To reload your .bashrc file (or any shell configuration file) without logging out and back in, use the source command or its shorthand equivalent . (dot). This re-executes the .bashrc file in your current shell session, applying any changes immediately.
Command:
source ~/.bashrc
# or equivalently
. ~/.bashrc
Example Workflow:
- Edit your
.bashrc(e.g., add an alias or updatePATH):
echo 'alias ll="ls -alh"' >> ~/.bashrc
- Reload the changes:
source ~/.bashrc
- Verify (e.g., test the new alias):
ll # Outputs detailed directory listing
Why This Works:
- The
sourcecommand runs the.bashrcscript in the current shell environment, updating variables, aliases, and functions. - Without
source, changes to.bashrconly take effect in new terminal sessions.
Key Notes:
- Scope: Only affects the current terminal session. Other open terminals remain unchanged unless you reload them individually.
- Syntax Errors: If
.bashrchas errors,sourcemay fail partially or entirely. Check for issues with:
bash -n ~/.bashrc # Syntax check without executing
- Other Files: Use the same method for
.bash_profile,.zshrc, etc.:
source ~/.bash_profile
Use source to instantly apply configuration changes!