World map

 

BM: Baca dalam Bahasa Melayu

World L2: Keys & Staff

Environment variables and PATH

You will learn: to set notes that programs can read, and to teach the shell where your tools live.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

You keep a helper script called menu in ~/tools. You type menu. The shell says -bash: menu: command not found. It is right there! Why?

Pick one answer.

Watch

You are you in /home/you. 1 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~$

Folder ~

  • tools/ (folder)drwxrwxr-xmenu

+ 3 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Notes on the wall: environment variables. $HOME is your room. $PATH lists the rooms the shell searches for commands, split by :.

Predict

You type SHOP=Kancil, then run tools/menu. It prints Today at : nasi lemak. Why is SHOP empty?

Pick one answer.

Try it

Pin the note on the wall: export SHOP=Kancil. Then run tools/menu again.

You are you in /home/you. 1 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~$

Folder ~

  • tools/ (folder)drwxrwxr-xmenu

+ 3 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

Say PATH is /home/you/tools:/usr/local/bin:/usr/bin:/bin. You type menu. Put the rooms in the order the shell searches.

Searched first at the top. Put these in order. Use the arrows, or drag.

  • /home/you/tools
  • /usr/local/bin
  • /bin
  • /usr/bin

Try it

Put ~/tools at the front of the PATH: The list of folders the shell searches, in order, when you type a command name.: export PATH="$HOME/tools:$PATH". Then type just menu.

You are you in /home/you. 1 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~$

Folder ~

  • tools/ (folder)drwxrwxr-xmenu

+ 3 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

Good PATH habit, or risky?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4export PATH="$HOME/tools:$PATH"
export PATH="$HOME/tools:$PATH"

You did it!

You can now share notes with export and tell the shell where tools live.

Go deeper (optional)

These changes last until you log out. To keep them, add the export line to ~/.profile. On Debian, ~/.profile already adds ~/bin to PATH when it exists. env lists every exported note; unset SHOP takes one down.

Real rep (optional): on Linux, echo $PATH, then which ls, then env | wc -l.