To set or change the $PATH
variable on macOS, you can use the export
command in a terminal window. The $PATH
variable is a system-wide environment variable that specifies the directories that the system will search for executables when you run a command in the terminal. By modifying the $PATH
variable, you can add or remove directories from the search path, which can make it easier to run executables that are not in the default search path.
To set the $PATH
variable, you can use the export
command in the following format:
export PATH=$PATH:/path/to/directory
This will add the /path/to/directory
directory to the existing $PATH
variable. You can specify multiple directories by separating them with a colon (:
). For example, to add the /usr/local/bin
and /usr/local/sbin
directories to the $PATH
variable, you can use the following command:
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
To make the changes to the $PATH
variable persistent across terminal sessions, you can add the export
command to your shell's configuration file. The location and name of the configuration file depends on the shell that you are using. For example, if you are using the Bash shell, you can add the export
command