Tuesday, February 19, 2013

File Attributes

The common characteristics of all files are called the attributes of a file. They are as follows:-
  • Name: A filename is a string (i.e., a sequence of characters) that is used to identify a file. File names in Linux can contain any characters other than - a forward slash ( / ) and the null character. The forward slashis reserved for use as the name of the root directory (i.e., the directory that contains all other directories and files) and as a directory separator. The null character is used to terminate segments of text. Spaces are permitted, although they are best avoided because they can be incompatible with legacy software in some cases. Typically, however, file names only use alphanumeric characters (mostly lower case), underscores, hyphens and periods. Other characters, such as dollar signs, percentage signs and brackets, have special meanings to the shell(they are used as shell metacharacters).File names should never begin with a hyphen.A relatively small number of file names on a system consist only of upper case characters, such as README, INSTALL, NEWS and AUTHORS. They are usually plain text files that come bundled with programs and are for documentation purposes.File names were limited to 14 bytes (i.e 14 characters) in early UNIX systems. However, modern Unix-like systems support long file names, usually up to 255 bytes in length. File names can be as short as a single character.File names consist of two parts: a user-designated name and an extension which is determined by the type of file. The two are separated by a period.Although Unix-like operating systems generally do not require the use of file extensions, they can be convenient and useful. In particular, they can make it easy to identify file types at a glance and to facilitate manipulating groups of files. Files can also have multiple extensions.File names must be unique within a directory. However, multiple files and directories with the same name can reside in different directories because such files will have different absolute pathnames (i.e., locations relative to the root directory), and thus the system will be able to distinguish them.On a Unix-like operating system any file or directory can have multiple names because of the operating system's use of inodes instead of names to identify files and directories. Additional names can be provided by using the ln command to create one or more hard links to a file or directory.
  • Location: As files have places inUnix, therefore, paths need to be specified to define the location of a file. There are two methods of specifying paths. The absolute path is a sequence of directories from the root to the directory in which the file is housed. Each directory in the path is separated by a forward slash (/). A relative path is a sequence of directories from any of the directories above the current file and is a part of its parent tree. A path is different from a pathname as a pathname always ends up in an ordinary file whereas a path ends in a directory file. Consider the following directory structure: unix image1 The absolute path for the file file2 is /usr1/a1.dir and the pathname is /usr/a1.dir/file2. The relative path for file 2 is simply a1.dir where the current working directory is usr1 . The relative pathname is a1.dir/file2.
  • Size of a file: This is given in terms of bytes and is limited by the physical capacity of the disk and the disk qoutas assigned by the superuser.
  • Link Count: The link count of a file is a special number attached with each file which counts the number of files with different pathnames that access the same physical file. Links are implemented as hard or soft. (Links will be discussed in the next post).
  • i-node number: It is a unique number that the kernel assigns to each file for identification. An inode structure is defined per file , where inode- number is one of its prime members along with attributes like size of file, ownership, permissions , link count, address of disk blocks etc.
  • Time stamps: There are three time stamps attached to each file :-
    • Time of creation
    • Time of last modification
    • Time of last access
    These time stamps are automatically updated by the Unix system but they can be modified by the user with the help of commands like 'touch'.
These were the file attributes typically assosciated with each file. We shall discuss them in greater detail along with the assosciated commands when we discuss the topic 'Handling File Attributes'. The next post will discuss hard links and soft links.

No comments:

Post a Comment