2.10.5. The Unix Filename¶
Linux for Programmers and Users, Section 3.26
- Filename limited to 255 characters. Can not contain / or NULL character.
- Filenames are case-sensitive; chap and Chap are two different filenames.
- Group of filenames held together in a directory.
- Directory contains name of the file.
- Both files and directories are subject to access control.
Note
Because a directory contains the filenames, creating or deleting files requires manipulation of the directory. But a directory can be modified only by the kernel. We can’t edit a directory file with an editor but only by running commands (like cp and rm) that make the kernel change the directory entry.
A directory contains filenames not files.
It’s a notable feature of the system that we can access critical resources
not directly, but only by running commands that access them. For instance,
we add an entry to a directory by running the cp command. The passwd
command updates a sensitive file (/etc/shadow
). We can freely run
passwd but we can not edit /etc/shadow
directly.
A file has a unique number as well as other attributes, and only the number and filename are stored in the directory. The other file attributes are stored, not in the file, but in a separate area of the disk not directly accessible to users.