File Attributes
On path: Filing | 1: Filing System • 2: File Systems • 3: Files • 4: File Attributes • 5: File Types • 6: File Permissions • 7: File Access • 9: Filing System Implementation • 10: I-nodes • 11: Links • 12: File Descriptor |
---|
Depends on | Files • Security |
---|
A file contains data but typically has some associated metadata, or “attributes”. These are things about the file – such as its size – rather than things in the file.
Note: this is ‘permanent’ information about the file; it is not the same as the file descriptor which is the information about a file in use by a particular process.
There are various ways to see file attributes; in Unix an easy way to see some important ones is “ls
-l
”. You can get more information about a particular file with “stat <filename>
”.
Some people may classify “attributes” differently from other metadata properties. (Others don’t.) We won’t bother about such semantics here.
File permissions
If there are any attributes, it is normal to include permission. Permission says what can be done to a file – e.g. can it be written to? This provides some simple protection against clumsy programming, etc.
Unix provides independent control over whether a file can be read, written or executed. There is also some control over who can do what. For example, example files we provide for you must be readable by you, but we only give write permission to the staff!
This system is similar to the system used in memory protection, although it is performed on a ‘user’ rather than a ‘process’ basis.
File ownership
In a multi-user system it is useful to know who ‘owns’ which file. An associated, unique identifier can provide this information. (The user’s name can be looked-up from this if necessary.)
In Unix, a file also belongs to a ‘group’; this allows another access setting for members of that group – typically more liberal than for ‘others’.
Exercise: See some metadata. In a Unix terminal, use the command
stat
<filename>
to see a file’s status. (It works for directories etc. too.) This will reveal quite a lot of information; some of this is explained a bit more in some other articles.