Sikau

Linux and the shell · Day 13 · about 30 min

Environment and shell config

Variables, export, PATH, aliases and ~/.bashrc.

Settings that travel

Apps read their configuration — database URLs, ports, API keys — from environment variables. And PATH decides which program runs when you type a name. Knowing both ends many "command not found" and "works on my machine" mysteries.

Variables, PATH, aliases

NAME=Asha
echo "Hello $NAME"
bash -c 'echo "child sees: [$NAME]"'
export PORT=8080
bash -c 'echo "child sees PORT=$PORT"'
NODE_ENV=production bash -c 'echo $NODE_ENV'
echo $PATH
which ls
type cd
alias ll
alias gs='git status'
echo 'alias ll="ls -alF"' >> ~/.bashrc
source ~/.bashrc

The rest of this lesson

  • How PATH finds programsexplain
  • Secrets in environment variablesexplain
  • Does the script see it?predict
  • Which does what?match
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Linux and the shell