1. Command Line Without Fear
Permissions, Environment Variables & Shortcuts
Understand file permissions (chmod), environment variables (.env and PATH), useful shell aliases, curl, and SSH basics.
- Understand how PATH locates terminal commands
- Manage environment variables and protect secrets in .env files
- Grant script permissions with chmod and speed up work with shortcuts
Now that you can move around folders comfortably, let's clear up three everyday terminal concepts that trip up almost every self-taught developer: PATH, environment variables, and file permissions. Once these click, error messages like "command not found" or "Permission denied" stop feeling mysterious and take seconds to fix.
How Your Terminal Finds Programs (PATH)
Have you ever wondered why typing git or python3 works from any folder on your computer, even though you didn't type the full path to where the program was installed?
That magic comes from an environment variable called PATH. Think of PATH as your shell's speed-dial contact list of folders. Whenever you type a command name, the terminal scans those folders in order—from left to right—and runs the first matching executable it finds.
# Print the colon-separated list of folders in your PATH
echo $PATH
# Ask the terminal which exact file runs when you type a command
which git
which python3Notice the $ sign in $PATH: when you set a variable, you write its bare name, and when you want the terminal to read its value, you put $ in front of it.
When an installer finishes and says command not found, the tool did install—its folder just isn't in PATH yet. Restarting your terminal reloads your shell configuration (~/.zshrc on macOS or ~/.bashrc on Linux), which usually picks up the newly added path right away.
Environment Variables & .env Files
Programs often need configuration that changes depending on where they run—for example, a local test database URL on your laptop versus a live production database on a server, or secret API keys that should never be visible in source code.
Instead of hardcoding those values inside your Python or JavaScript files, developers pass them in via environment variables. You can test setting one temporarily in your current terminal window using export:
# Set a variable for this terminal session only
export SITE_NAME="Yadav Academy"
echo $SITE_NAMEAs soon as you close that terminal tab, SITE_NAME disappears. For real software projects, typing export manually every morning would be tedious, so teams save their local settings in a plain text file named .env at the root of the project:
DATABASE_URL=postgresql://localhost:5432/academy_dev
STRIPE_SECRET_KEY=sk_test_example_key
NEXT_PUBLIC_SITE_URL=http://localhost:3000Because .env holds private passwords and keys, never commit .env to Git. Add .env to your .gitignore file immediately, and commit a safe .env.example template with blank placeholder values so teammates know which variables they need to fill in on their own machines.
Making Scripts Executable (chmod)
On macOS and Linux, creating a file does not automatically give anyone permission to run it as a program—even if you wrote valid shell commands inside it. This is a built-in safety feature so random downloaded text files cannot execute on their own.
If you write a helper script called deploy.sh and try to run it with ./deploy.sh, you will likely see zsh: permission denied: ./deploy.sh. Use chmod (change mode) with +x to mark the file as executable:
# Inspect current permissions (look for the 'x' letters on the left)
ls -l deploy.sh
# Grant execute permission (+x) to the file
chmod +x deploy.sh
# Now run the script from the current folder
./deploy.shThe ./ prefix before deploy.sh simply tells the shell: "look inside my current working directory for this script, not just inside PATH."
Everyday Terminal Shortcuts Worth Memorizing
You do not need to memorize dozens of flags to be fast in the terminal. Just four daily habits cut typing in half:
Ctrl + R(Reverse History Search): PressCtrl + Rand start typing any part of a command you ran earlier today or last week. PressEnterto run the match, or the right arrow key to edit it first.Ctrl + C(Stop Now): Cleanly cancels a running command, frozen script, or local dev server and gives your prompt back.Ctrl + Lorclear: Wipes visual clutter off the screen without losing your command history or current directory.- Custom Aliases: Short nicknames for long commands you run dozens of times a day, saved inside
~/.zshrc(or~/.bashrc):
# Add short aliases to ~/.zshrc, then reload with: source ~/.zshrc
alias gs="git status"
alias gp="git pull"
alias py="python3"Once reloaded, typing gs runs git status instantly.
Quick Checkpoints
Why should .env files almost always be listed in .gitignore?