Like all operating systems, UNIX files have names: words (sequences of
characters, whatever) that let you identify a file. Older versions of
UNIX had some restrictions on the length of a filename (14
characters), but modern versions have removed these restrictions for
all practical purposes. Sooner or later you will run into a
limit, but if so, you are probably being unnecessarily
Technically, a filename can be made from almost any group of
characters (including non-printing characters) except a slash
). However, you should avoid filenames containing most
punctuation marks and all non-printing characters. These will usually
be a pain.
To be safe, limit your filenames to the following characters:
Uppercase and lowercase characters.
UNIX is always
That is, uppercase and lowercase letters are always different (unlike
DOS and VAX/VMS, which consider uppercase and lowercase letters the
same). Therefore, myfile
are different files.
It is usually a bad idea to have files whose names differ only in
their capitalization, but that's your decision.
Underscores are handy for separating
"words" in a filename to make them more readable. For example,
is easier to read than
Periods are used by some programs (such as the C
compiler) to separate filenames from
filename extensions (1.17
Extensions are used by these programs
to recognize the type of file to be processed, but they are not
treated specially by the shell, the kernel, or other UNIX programs.
Filenames that begin with a period are treated specially by the
wildcards won't match (1.16
them unless you include the period
). The ls
command, which lists your files, ignores
files whose names begin with a period unless you give it a special
Special configuration files are often
"hidden" in directories by beginning their names with a
Certain other punctuation.
About the only other punctuation mark
that is always safe is the comma (
)-although it isn't part of the
POSIX-portable character set. The other punctuation marks
may have special meanings in one situation or another. Stay away from
them, or you will create filenames that are inconvenient to work with.
I'm so dead-set against using weird, non-printing
characters in filenames that I
won't even tell you how to do it. I will give you some
special techniques for deleting files with weird names (23.11
in case you create some by accident.
Some things to be aware of:
UNIX does not have any concept of a file version
. There are
revision control programs (20.12
that implement their own notion of a
version, but there is nothing analogous to VAX/VMS's version number.
If you are editing a file, don't count on UNIX to save your previous
versions - you can make
scripts to do this (44.11
though, if you want to; the
GNU Emacs editor
makes backups (32.4
Once you delete a file in UNIX,
it is gone forever (23.2
You can't get it
back without restoring it from a tape. Be careful when you delete
files. Later, we'll show you
that will give you
a "grace period" between the time you delete a file and the time it actually