Linux File Names

Discuss everything about Linux here!

Moderator: Community Moderator

Post Reply
User avatar
MrNiitriiX
Premium Uploader
Premium Uploader
Posts: 2197
Joined: 19 Apr 2010, 14:52
Location: between space and time
Has thanked: 24 times
Been thanked: 164 times

Linux File Names

Post by MrNiitriiX »

What Are The Rules for Linux File Names?

What's in a File Name? Linux file names can be up to 256 characters long, but you really have to enjoy typing to get to that extreme. You can name a file panda-corporation-financial-reports.y96 if you wish, but you'll probably find that shorter names (and intelligent use of directories) will save lots of time and keystrokes in the course of a day. When naming files, you can use uppercase and lowercase letters, numbers, and certain special characters. It's a really good idea to stick with letters, numbers, and the dash, dot, and underscore characters to avoid trouble and confusion.

Note: Don't use asterisks, backslashes, or question marks in Linux file names--these characters have special meaning to the shell and could cause your commands to do something quite different from what you intended. Also avoid using a dash as the first character of a file name, since most Linux commands will treat it as a switch.

Files starting with a dot are hidden files. They behave just like any other file, except that the ls (list files) command will not display them unless you explicitly request it to do so. Your .profile file is an example of a hidden file.

Also remember that Linux file names are case sensitive, which can be difficult to get used to if you have a DOS background. Linux allows you to have unique files named goodstuff, GOODSTUFF, and GoodStuff in the same directory.

It's best to always use lowercase in Linux unless you can think of a good reason to use uppercase or mixed case. Most Unix people use lowercase almost exclusively, but aside from this "cultural" point, there's another good reason to use lowercase. If you're sharing or accessing a DOS file system with Linux, DOS will not be able to see the files that have uppercase or mixed-case file names.

Unlike under DOS, the dot character (.) has no special meaning. You're not limited to the eight dot three (xxxxxxxx.yyy) style of naming because Linux treats the dot just like any other character; you can name a file Some.Yummy.CHEESECAKE.Recipes if you're so inclined.
Along these lines, Linux executables do not need or use a special extension such as .exe or .bat. Linux will happily run a program file named zippity just as readily as it will run DOODAH.EXE.

And here's another slight difference between Linux and DOS filesystems. Linux uses the forward slash (/) in path names, and DOS uses the backslash (\). Don't blame this little quirk on Linux though . . . the DOS filesystem was originally modeled after Unix! In fact, the popular rumor is that Bill Gates and Company implemented the DOS filesystem just differently enough from the Unix filesystem to avoid being criticized for stealing the idea. The same charge is made about the DOS batch file (.BAT) utility, since it bears striking similarities to the Unix shell scripting languages, but I digress. . . .

Leason 1: The Linux File System
Leason 2: Linux File Names
Leason 3: Linux Directories
Leason 4: Directory Terminology
Leason 5: Navigating the File System
Leason 6: Listing Linux Files
Leason 7: Displaying Linux Files
Leason 8: Copying and Renaming Files
Leason 9: Creating Files and Directories
Leason 10: Deleting Files and Directories
Leason 11: Linux Files - Wildcards
Leason 12: The Nine Deadly Keystrokes
Leason 13: Linux File Permissions
Leason 14: Changing File Permissions
Last edited by MrNiitriiX on 30 Sep 2010, 14:57, edited 1 time in total.
"Injustice anywhere is a threat to justice everywhere." - Martin Luther King
Image
Upload List
Post Reply

Return to “Everything Linux”