User Tools

Site Tools


This is an old revision of the document!

PATH Variables

I'm not sure how one first gets exposed to path variables, only that it can be confusing at first glance. This document tries to remedy that without going into the history of everything.

The linux file system

What you need to know:

There are various directories that follow this pattern [not limited to]:

  • bin: binaries (actual commands you execute: e.g. git and ssh)
  • lib: libraries
  • include: source code
  • share: other, usually documentation
  • man: manual pages

The directories can exist inside of any directory path. There are the usual ones you may have seen already:

  • /bin
  • /usr/bin
  • /usr/local/bin
  • /lib
  • /usr/lib
  • /usr/local/lib

If you are aiming to use (command-line) programs that are not within one of these canonical bin directories, then you should edit the PATH environment variable in your shell. The PATH variable is a list of directories, delimited by : colons, in which the shell will look in, in order, when you type a command name at the shell prompt. For example, when you type ls to list the contents of the current working directory, the shell is running ls because it found the ls program in your PATH. You can run which ls to see that your shell is (likely) running the /bin/ls executable, and you can run echo $PATH to see that /bin is in your path.

To add new directories to your path, you need to add them to $PATH. Assuming that the command-line programs you want to use do not have the same name as programs in the canonical location, it is best to add new directories to the end of the path. You can do this with:

export PATH=${PATH}:/new/path/to/add

where /new/path/to/add is the directory containing the programs you want to run.

… FINISH: can do this per-shell, but then doesn't persist to other login shells

… thus, have to add setting PATH to what? file

/var/lib/dokuwiki/data/attic/nix/pathvars.1578345157.txt.gz · Last modified: 2020/01/06 15:12 by glk