File Naming Conventions - Linux

Once again Unix is case sensitive which is a difficult area to get used to when you migrate from the DOS environment.

File Name Length

Unix allows up to 255 characters in the file name as opposed to DOS's 8.3 convention. This allows for unique and informative file descriptions rather than the encryptic file names used in DOS.

There is a problem with having long file names if you are working from the command line. Typing in a file name with 255 characters and keeping the case correct can be very frustrating. It is recommended that you keep the file names short and sweet and also use DOS's naming convention if you are going to transfer files between DOS and Unix (very common occurrence).

Allowable Characters in Filename

Only the "/" (forward slash) is not allowed in filenames because it is used as the pathname separator (DOS uses the back slash "\").

Characters to avoid: ? @ # $ ^ * ( ) ` [ ] \ | ; ' " < >

You can use spaces or tabs in filenames if you enclose the names in quotation marks on the command line but they are hard to work with. Use underscores or periods to get visual separation.

Ex. "this is my file" or my_file_is_this_one or

Don't use - or + as the first character of a filename. Many commands use the - or + to introduce options or switches.

Filenames starting with "." are used by the system to make names invisible to normal directory listings. Typically, preferences or configuration files are "hidden" using a "." prefix. An example is ".signature" used for your electronic signature in E-mail.

Pathnames (/)

Unix uses the forward slash "/" as the pathname separator. Unix's top directory is called the root directory and is indicated by "/".

Compatibility with Other Systems

If you are going to use Unix with other systems such as DOS, make sure that you follow a file naming convention that is compatible with both systems. It is possible that characters that are allowed in one system may not be allowed or reserved in the other system.

DOS only allows 8 characters followed by a 3 character extension while Unix allows up to 255 characters. When transferring from DOS to Unix there is no problem. But when transferring from Unix to DOS, the Unix filename becomes truncated and converted to the 8.3 format.

Ex. Unix: "this_file_is_ver01_of_pkzip" becomes "this_fil.e_i" in the DOS world.

Wild Cards

Unix allows wild card characters in the file names similar to DOS. The Wild cards allowed are the asterick "*" and the question mark "?".

For example:

ls *xt 	will list all files ending with xt regardless of filename length. Such as:

cat_text  readme.txt

ls ?xt 	will only list 3 character long filenames that end with xt. Such as:

txt  cxt

If this page has helped you, please consider donating $1.00 to support the cost of hosting this site, thanks.

Return to

TelecomWorld 101

Copyright July 2013 Eugene Blanchard