# How the Shell Finds Things

Variables, the environment, `PATH` and permissions: the reasons behind the two most common error messages.

Updated: November 10, 2026

## [Variables](https://www.ask-codey.com/courses/bash-in-depth/topics/bash-variables)

1. [Variables in the Shell](https://www.ask-codey.com/lessons/bash-shell-variables) (Apprentice): A shell variable is a name the shell keeps a value under, so owl_folder=… stores a long path once and $owl_folder hands it back in any command until you close the window.
2. [Environment Variables: export and env](https://www.ask-codey.com/lessons/bash-environment-variables) (Apprentice): Programs you start can't see your shell variables, only environment variables, so export shares a variable with them, env and printenv show what they'll see, and NAME=value in front of a command sets one for that command alone.
3. [PATH: How a Command Is Found](https://www.ask-codey.com/lessons/bash-path) (Apprentice): When you type a command's name, the shell looks for a program file of that name in each folder of PATH, in order, so "command not found" means none of them has it, and adding a folder to PATH lets you run its programs by name from anywhere.

## [Permissions](https://www.ask-codey.com/courses/bash-in-depth/topics/bash-permissions)

1. [Permissions: Read, Write and Run](https://www.ask-codey.com/lessons/bash-permissions) (Apprentice): Every file says who may read it, change it and run it, for its owner, its group and everyone else; ls -l shows it as letters such as rwxr-xr-x, chmod +x lets a program run, and chmod 644 or 600 sets all nine at once with numbers.
2. [sudo and Who Owns a File](https://www.ask-codey.com/lessons/bash-sudo-and-ownership) (Journeyman): Every file has an owner and a group, and only root, the computer's administrator account, may change anything; sudo runs one command as root after asking for your password, and chown gives a file a new owner, so both are used rarely and on purpose.

## [Exercise: The Workshop's Machines](https://www.ask-codey.com/courses/bash-in-depth/topics/exercise-bash-the-workshops-machines)

1. [Exercise: The Workshop's Machines](https://www.ask-codey.com/lessons/exercise-bash-the-workshops-machines) (Apprentice): Get an inventor's machines running with ls -l and chmod, an environment variable and a folder added to PATH, keep the broken one switched off, answer seven questions about permissions, owners and commands, and let a check script tell you what's done.

Source: https://www.ask-codey.com/courses/bash-in-depth/chapters/bash-how-the-shell-finds-things
