Command line operation on Linux, Mac OS X, and Windows

Command line operations on Unix (Linux, Mac OS X)

Command line operation on Unix-derivative systems is easy and natural, as that is the origin of Unix, and Graphical User Interfaces were added later.

To run programs from the command line, open a Terminal window. This will start a program called a shell, that prints out a prompt, accepts input, decodes (parses) that input, and runs the corresponding program. When you type a command like:

fossil update
the shell has to find the program you are referring to (fossil in this case). It does that by looking at a variable called the PATH. To see what the PATH is, type:
echo $PATH

You can put executables either in /usr/local/bin which is probably already in your PATH, or you can create a directory ~/bin and put any executables there (as well as adding it to your path, below). If you can't write into /usr/local/bin because you don't have administrator permissions on the computer, then the ~/bin solution is the only option.

To add a new directory to search (such as the one where you put the fossil command: the directory bin in your home directory), simply execute:

export PATH="$HOME/bin:$PATH"
(Note that there are no spaces except for the one after export, and that elements of the PATH are separated by the colon character.) This will change the PATH in the current window. To make it permanent, add that line to the file ~/.bashrc (which may or may not already exist).

On unix-derived systems, the directory listing command, ls, normally doesn't show files or directories that start with the period character, '.'. To show these, add an option -a:

ls -a
There are many other options which you can see by using the man command.
man ls

Command line operations on Windows

Command line operations have also been available on Windows since the beginning. Windows was derived from MSDOS, which was patterned on Unix - so conceptually command line operations are similar, but with some key differences:

  • most command names are different (like ls is replaced by dir) and outputs are formatted differently
  • file differences including:
    • '/' is replaced with '\'
    • initially much more restrictive file names, although this has improved over the years
    • ':' is a key part of file names, which requires the separater ':' to be replaced with ';' in directory/file lists such as PATH and CLASSPATH).
  • environment variables are referenced as %PATH% rather than $PATH

To run programs from the command line, open a Command window. This will start a program called a shell, that prints out a prompt, accepts input, decodes (parses) that input, and runs the corresponding program. When you type a command like:

fossil update
the shell has to find the program you are referring to (fossil in this case). It does that by looking at a variable called the PATH. To see what the PATH is, type:
echo %PATH%
To add a new directory to search (such as the directory where BlueJ has stashed a java executable and your "Program Files" directory where I suggest you put fossil.exe and plink.exe), simply execute:
set PATH="%PATH%;C:\Program Files\BlueJ\jdk\jre\bin;C:\Program Files"
(Note that there are spaces such as in the directory name, and that elements of the PATH are separated by the semi-colon character.) This will change the PATH in the current window - see below how to make it permanent.

On your own computer you can set up the PATH permanently (but not on the lab machines). The simplest way to do this is to do the command above, except use setx instead of set, and the path should be right the next time you log in. If this doesn't work, go to PC Info -> Advanced Settings -> Environmental Variables -> PATH and click to edit it. Add the semi-colon and the directory you want to add to the end of the PATH.