The shell environment is a persistent data layer containing:
Command | Description |
---|---|
printenv | Displays environment variables |
set | Lists all shell and environment variables |
export | Makes a variable available to child processes |
alias | Defines command shortcuts |
printenv PATH
set | less
alias
Variable | Description |
---|---|
USER | Current username |
HOME | User’s home directory |
PATH | Executable search paths |
SHELL | Default shell interpreter |
EDITOR | Preferred text editor |
TERM | Terminal type |
DISPLAY | X server display (for GUI) |
PS1 | Shell prompt string |
PWD | Present working directory |
TZ | Timezone setting |
Startup files initialize your shell at login or terminal launch:
/etc/profile
system-wide; then ~/.bash_profile
, ~/.bash_login
, or ~/.profile
per-user/etc/bash.bashrc
globally; ~/.bashrc
user-specificMost systems link .bashrc
within .bash_profile
:
# ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export PATH=$PATH:$HOME/bin
Use editors like nano, vim, or gedit:
cp ~/.bashrc ~/.bashrc.bak
nano ~/.bashrc
# Increase history size
export HISTSIZE=1000
# Ignore duplicate commands in history
export HISTCONTROL=ignoredups
# Helpful aliases
alias ll='ls -l --color=auto'
alias l.='ls -d .* --color=auto'
Use #
to document your configuration:
# Custom alias to show hidden directories
alias l.='ls -d .* --color=auto'
Use source
to reload your shell settings:
source ~/.bashrc
Then test with your new aliases or variables:
ll
A customized shell environment enhances productivity, reduces repetition, and brings elegance to your command-line workflow. With control over variables, startup files, and aliases, Linux becomes a workspace tailored to your needs—whether you're a sysadmin or just exploring the shell.