next up previous contents
Next: Pathnames Up: The File System Previous: What can I do   Contents

What's in a filename?

Files must be named so that you can identify them to the system (these names are appropriately called filenames). Filenames can be up to about 255 characters, although shorter names are recommended, and can contain many different characters, although we suggest you stick to the standard ones: letters, digits, underscores, dashes, and periods. Some typical filenames are main.c, prog1.C, file.o, a.out, and main.

Note that filenames are case-sensitive; prog1.c is different than pRoG1.C. This is an important thing to get used to, and may cause some confusion.

Filenames which contain shell metacharacters (that is, characters that the shell interprets as something other than plain text) that also have special meaning to the shell should be avoided, as well as spaces to prevent confusion. For more information see section [*].


Table: Common Suffixes
Suffix Meaning
.c C source code
.cc or .C C++ source code
.java Java source code
.html HTML markup
.o object code (not human readable)
.Z compressed file (use uncompress)
.gz gzipped file (use gunzip)
.tar tarred group of files (use tar)


There are several conventions for naming files. For example, you may have noticed above that the file containing the Java program was named Prog1.java. The Java compiler expects its input from files whose names end in .java. In general, a suffix designates a source file (program text) and the absence thereof designates an executable. Table [*] has some of the common suffixes. Note that, unlike in some other operating systems, Unix does not associate a purpose or function based on a filename. Many programs, however, do expect certain suffixes.

The file system separates users' files using a concept called directories. Directories are special files that can contain both files and more directories. Each user on the system has a home directory in which they may create files and directories. Directories are hierarchically organized; that is, a directory has a parent directory ``above'' it and may also have child directories `below' it. Similarly, each child directory can contain other files and also other child directories. Because they are hierarchically organized, directories provide a logical way to organize files. As you read through the next section, refer to figure [*].

Figure: A directory structure
\fbox{\resizebox{.9\textwidth}{!}{\includegraphics{dirs.eps}}}


next up previous contents
Next: Pathnames Up: The File System Previous: What can I do   Contents
Michelle Craft 2008-01-23