Adding a directory to command path

To type commands from a command interface, the operating system must know how to find the command. Here's how to add a directory dedicated to executable programs to your command line:

On a Unix

Add PATH=$PATH:/new/path on a line to the ~/.profile file. If needed, add export PATH. System wide, this is added to /etc/profile.

Most GNU/Linux systems source this from /etc/profile.d/ instead of adding to /etc/profile. For instance, Slackware expects a file with a .sh extension, and the x-bit set globally. Look for a . or source command in /etc/profile to be sure. Some shells may have a different user login profile, (e.g. Bash uses ~/.bash_profile or ~/.bash_login, and CSH uses ~/.login).

As a note, the ~ refers to your login directory as defined in the /etc/passwd file, or the CDPATH and HOME variables.

On Windows

Right click the start-menu-thingie, select System, select Advanced Settings, select the Advanced tab, click Environment Variables. Under User variables click ne, give your profile a name, then add %path%;%USERPROFILE%\new\path, where new\path\ is the directory you're adding within your C:\Users\ sub-directory. This updates the registry in HKEY_CURRENT_USER\Environment persistently.

To paraphrase Doug Gwyn on Usenet, GUIs make simple tasks easy, and complex tasks impossible, (22 June 1991, comp.unix.wizards).

©2016 David Egan Evans.