6.1 Directory and File Management Using the Command Line
6.1.7 File and directory naming conventions
In the next section, we will cover the creation of files and directories, so it is important to review the naming of UNIX files and directories before we begin. All operating systems have some basic guidelines or conventions that must be followed. The rules here apply to UNIX files and directories. Refer to the Figure for a summary of the UNIX file and directory naming guidelines or conventions.
  • Maximum Length - The maximum length of files and directories combined is 255 alphanumeric characters.
  • Non-alphanumeric characters - Some alphanumeric characters are allowed - Underscores (_), hyphens (-), and periods (.) can be used multiple times in a file or directory name (For Example, Feb.Reports.Sales). While the shell will allow asterisks (*), ampersands (&), pipes (|), quotes (" "), and dollar signs ($) to be used in a file name, this is not recommended, as these characters have special meaning to the shell.
  • File Name Extensions - File Names may contain one or more extensions. Extensions are usually appended to files by an application. Extensions are usually one to three characters that are appended to the end of a file name and are preceded by a period (.). You may choose to use this convention when naming files, but it is not a necessary part of a file name.
  • Directory Name Extensions - Directory names generally do not contain extensions, but there are no rules against it.

Note: To help distinguish between files and directories, some site administrators prefer their users to start filenames with lowercase letters and directory names with capital letters. They may also recommend including an upper case letter D_ in the first position or include .dir on the end of directory names to distinguish them from file names. If no convention is used to distinguish files from directories, you can always use the ls -F command line to visibly show which is which.