.bashrc and .profile
These files run automatically when you open a shell.
Files and when they run
| File | When it runs |
|---|---|
~/.bashrc | Every new interactive bash shell |
~/.bash_profile | Login shells only |
~/.profile | Login shells (any shell) |
~/.bash_aliases | Usually sourced from .bashrc |
/etc/profile | System-wide, all users |
/etc/bash.bashrc | System-wide bashrc |
Editing .bashrc
nano ~/.bashrc
Common .bashrc contents
# Aliases
alias ll='ls -la'
alias grep='grep --color=auto'
# Custom PATH
export PATH="$HOME/scripts:$PATH"
# Editor
export EDITOR=nano
# Custom prompt
export PS1='\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ '
# History settings
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTCONTROL=ignoredups:erasedups
# Functions
function mkcd() { mkdir -p "$1" && cd "$1"; }
Reload without logging out
source ~/.bashrc
. ~/.bashrc # Same thing, shorthand