O'Reilly logo

Learning the UNIX Operating System, Fourth Edition by Jerry Peek, John Strang, Grace Todino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File and Directory Names

As Chapter 3, explained, both files and directories are identified by their names. A directory is really just a special kind of file, so the rules for naming directories are the same as the rules for naming files.

Filenames may contain any character except /, which is reserved as the separator between files and directories in a pathname. Filenames are usually made of upper- and lowercase letters, numbers, “.” (dot), and “_” (underscore). Other characters (including spaces) are legal in a filename—but they can be hard to use because the shell gives them special meanings. So we recommend using only letters, numbers, dot, and underscore characters.

Unlike some operating systems, UNIX doesn’t require a dot (.) in a filename; in fact, you can use as many as you want. For instance, the filenames pizza and this.is.a.mess are both legal.

Some UNIX systems limit filenames to 14 characters. Most newer systems allow much longer filenames.

A filename must be unique inside its directory, but other directories may have files with the same names. For example, you may have the files called chap1 and chap2 in the directory /users/carol/work and also have files with the same names in /users/carol/play.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required