Updating the PATH Variable in the Shell

Introduction

The PATH environment variable is a critical component in Unix-like operating systems, including Linux and macOS. It helps the shell identify where to find executable files when commands are entered. Updating the PATH variable allows users to run software from any directory without specifying the full path to its executable.

Example: Adding the Flutter SDK to the PATH

Consider you have installed the Flutter SDK to ~/Documents/development/flutter. To use the Flutter commands from anywhere in your terminal, you need to add the Flutter SDK's bin directory to your PATH.

For Bash users, edit ~/.bashrc.

For Zsh users, edit ~/.zshrc.

Add the following line at the end of your configuration file:

export PATH="$PATH:$HOME/Documents/development/flutter/bin"

Apply the changes

source ~/.bashrc  # If using Bash
source ~/.zshrc   # If using Zsh

Verify the Update

echo $PATH