Next Previous Contents

2. UNIX

2.1 UNIX Pathnames

UNIX files and directories are called up by pathnames. You can visualize just about any computer file system as a tree. The beginning directory is designated as "/", and is generally known as root. Each file has its own unique path. Pathnames can be absolute or relative. An absolute path starts from the root directory, and it selects the same file, regardless of where you are when you use the pathname.

Absolute pathnames...

            /usr/local/bin/gs
            /home/howard/.xinitrc
          
The tilde character (~) has a special meaning in most UNIX shells. It indicates that you are specifying a user's home directory. In the following examples, the pathnames are absolute, starting at the current user's home directory, and at the home directory of a user named ``howard'', respectively.
            ~/readme
            ~howard/readme
          

A relative path starts from the current directory. The file selected by the pathname depends on what the current directory is.

Relative pathnames...

            projects/linux/UnixCommandLine-HOWTO.sgml
            readme
      ./readme
      ../readme
          
In the last two lines above, we are using special codes to specify the current directory, and the directory the next level down from current, respectively. If we were sitting in /usr/local/src/sgml-tools, the latter two pathnames would give us /usr/local/src/sgml-tools/readme, and /usr/local/src/readme, respectively.

2.2 File Extensions

File extensions are not formally a part of a UNIX pathname. Dots are just another character. For the sake of clarity, a number of applications, commands and users use extensions, or at least they use strings of characters that look like file extensions.

2.3 What is all this about foo?

It is traditional in UNIX to use the filename foo or foobar when giving examples of commands that affect files. This probably comes from the acronym FUBAR which, according to the Jargon Dictionary at http://www.netmeg.net/jargon/, means The Failed UniBus Address Register in a VAX. More likely it is a military term meaning Fouled Up Beyond All Recognition. Of course, military types would never never say ``fouled''.

2.4 Pathname Wildcards

In many cases, you want to specify a group of files with similar pathnames. UNIX has a sophisticated system of wildcards to let you do this.

foo*bar

The asterisk is a substitute for a string of characters of any length, including zero. The pathname specified above is anything starting with foo and ending in bar, including foobar. You can embed several asterisks in the pathname. The pathname *foo* is anything containing the sequence foo, including foobar, barfoo, and foo.

foo?bar

The question mark substitutes for one character, no more, no less. The pathnames foo1bar, foolbar, foo-bar and foo.bar all conform to this description.

foo[1-5]bar

The square brackets and their contents substitute for one character. Any filename, where that character ranges from ``1'' to ``5'' will be selected.

I rarely use anything other than the asterisk wildcard.

2.5 UNIX Commands

A UNIX command line contains up to three different kinds of element --- the command itself, command line switch which provide additional instructions to the command, and command information, such as pathnames.

Eg

            rm -ri foobar
          
The above UNIX command is rm, which is the command for deleting files. There are two switches, ``r'' and ``i''. Switches are usually (but not always) indicated by a dash ``-''. The ``r'' tells rm to recurse into subdirectories to search for files. The ``i'' tells rm to prompt you before deleting files. The name foobar is a pathname, which in this case would probably be a directory.

2.6 Getting Help (man)

The standard help resource on any UNIX machine is man, which stands for manual. The actual manual files are often called ``man pages''. To read the help files on how to delete files you type...

            man rm
          
On the Sun SPARCstations I learned UNIX on, man just dumped its text out to the screen. On any Linux machine I have ever used, man's output was run through less. This text reader is described below under Reading Text Files .

A more recent help resource, at least on Linux systems, is the info command. A number of Linux man pages state that the man pages are no longer being maintained, and that the help files are now in info format.

            info info
          
This is how you check the help files on the info command. It's worth a look.


Next Previous Contents