Bash & Linux·Bash from first command to automation

Environment and PATH

Understand environment variables and why a command cannot be found.

Beginner 12 min read Lesson 8 of 300 Challenge included
What you will be able to do
  • Use echo $PATH to inspect the search path.
  • Use export KEY=value for child processes.
  • Keep secrets out of shell history.
  • Add local tools to PATH deliberately.

In plain English

PATH is a colon-separated list of directories the shell searches for commands. Environment variables configure programs without editing code. Export a variable to pass it to child processes.

terminalTerminal
echo "$PATH"
export APP_ENV=development
printenv APP_ENV
command -v node
Your turn

Export a variable

Easy

Export APP_ENV with the value staging and print it.

BASH · starter
APP_ENV=
Check your understanding before moving on.
Knowledge checkQuestion 1

Why does ./script.sh work when script.sh alone does not?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: SSH and remote machines
Lesson 8 of 300 · 0% of course