Interview Questions - UNIX File Management
- owner's user ID ( 16 bit integer )
- owner's group ID ( 16 bit integer )
- File access mode word
(r w x) - (r w x) - (r w x)
(user permission) - (group permission) - (others permission)
To change the access mode, we use chmod(filename,mode).
Example 1:
To change mode of myfile to 'rw-rw-r--' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as:
chmod(myfile,0664) .
Each operation is represented by discrete values
'r' is 4
'w' is 2
'x' is 1
Therefore, for 'rw' the value is 6(4+2).
Example 2:
To change mode of myfile to 'rwxr--r--' we give the args as:
chmod(myfile,0744).
A link is a second name (not a file) for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers.
Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links.
Commands for linking files are:Link "ln filename1 filename2"
Symbolic link "ln -s filename1 filename2"
- kernel assigns new inode,
- sets the file type to indicate that the file is a pipe, directory or special file,
- If it is a device file, it makes the other entries like major, minor device numbers.
If the device is a disk, major device number refers to the disk controller and minor device number is the disk.