203 β€” Environment Variables & Configuration

Beginner

Master shell configuration and environment variables. Learn to customize your shell with aliases, manage PATH, set environment variables, and configure startup files like .bashrc and .zshrc.

Learning Objectives

1
View and set environment variables
2
Understand and modify PATH
3
Create command aliases for efficiency
4
Configure shell startup files (.bashrc, .zshrc)
5
Make configuration changes persistent
Step 1

View environment variables

See what environment variables are currently set.

Commands to Run

env
printenv
echo $HOME
echo $USER
echo $SHELL
echo $PATH

What This Does

Environment variables are key-value pairs available to all programs. env/printenv show all variables. $HOME is your home directory. $USER is username. $SHELL is your shell. $PATH lists directories searched for commands.

Expected Outcome

env shows many variables. echo $HOME shows /home/username or /Users/username. $USER shows your username. $SHELL shows /bin/bash or /bin/zsh. $PATH shows colon-separated directories.

Pro Tips

  • 1
    env and printenv do the same thing
  • 2
    $ prefix accesses variable value: $HOME
  • 3
    Environment variables are UPPERCASE by convention
  • 4
    $HOME = your home directory
  • 5
    $USER = your username
  • 6
    $PWD = current directory
  • 7
    $PATH = where shell looks for commands

Common Mistakes to Avoid

  • ⚠️Forgetting $ when accessing variables: echo HOME (wrong!) vs echo $HOME
  • ⚠️Not understanding PATH determines which commands are found
Was this step helpful?

All Steps (0 / 12 completed)