Linux/UNIX: Rules for naming file and directory names
Following are general rules for both Linux. BSD, Unix like systems:
* File names are case sensitive. So filename vivek.txt Vivek.txt VIVEK.txt all are three different files.
*You can use upper and lowercase letters, numbers, "." (dot), and "_" (underscore) symbols.
* You can use other special characters such as blank space, but they are hard to use and it is better to avoid them.
* In shot, filenames may contain any character except /, which is reserved as the separator between files and directories in a pathname.
* No need to use . (dot) in a filename. Some time dot improves readability of filenames. And you can use dot based filename extension to identify file. For example
- .sh = Shell file
- .tar.gz = Compressed archive
* Most modern Linux and UNIX limit filename to 255 characters. However, some older version of UNIX system limits filenames to 14 characters only.
* A filename must be unique inside its directory. For example, inside /home/vivek directory you cannot create demo.txt file and demo.txt directory name. However, other directory may have files with the same names. For example, you can create demo.txt directory in /tmp.
See also:
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- Linux Rules for file names
- Tape drives naming convention under Linux
- Howto: Use tar command through network over ssh session
- How do I search my Linux / UNIX server for a file?
- Linux partition naming convention and IDE drive mappings
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



February 19th, 2007 at 8:23 pm
i can not execute the following shell command…
“cd directory name with spaces”
June 27th, 2007 at 5:25 pm
Escape the spaces with “\”.
eg.
“cd Directory\ Name\ With\ Spaces”
August 27th, 2007 at 10:24 am
Thank You Very Much Vivek Sir For All Such Given Information Above…!
SD/-
RoHaN.
February 29th, 2008 at 6:16 pm
alternatively, you can use double quotes for the directory name like
cd “directory name with spaces”