This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Listing File and Directory Attributes”.
1. An attribute is a specification of an object that defines its property.
Explanation: An attribute defines the property of an object. In UNIX, every file has a set of attributes which defines the specification of the file.
2. Which command is used to list the attributes of a file?
Explanation: ls command is used for listing the attributes of a file or directory. ls command when used with -l displays all the seven attributes of a file.
3. Which one of the following is not an attribute displayed by ls command?
a) file permissions
b) file ownership
d) word count of file
Explanation: When -l option is used with ls command it simply displays seven attributes of a file which are file type and permissions, links, ownership, group ownership, file size, last modification time, filename.
4. What are links referred to as in file attributes?
a) number of filenames of a single file that are maintained by the system
b) number of duplicates of a single file
c) number of copies of a single file
d) number of files present in a directory
Explanation: Links are defined as the number of filenames of a single file that are maintained by the system. This file can be accessed through as many filenames as there is a number of links to that file.
5. In how many categories are links divided?
Explanation: There are basically two types of links; hard link and soft links.
6. Hard linked files are provided with the same inode number as the original one.
Explanation: Hard linked files are provided with the same inode number as the original file so they refer to the same physical location of the file.
7. Soft linked files are provided with different inode number as the original one.
Explanation: Soft linked files are provided with a separate inode number each of which points to the original file location.
8. Which option is used with ls command to list the directory attributes rather than its contents?
Explanation: ls command when combined with -d option displays the attributes of a directory rather than its contents.
$ ls -ld dir01
9. File attributes are of major concern as compared to directory attributes while performing operations on file system.
Explanation: Directory attributes are of major concern as compared to file attributes when performing any operation on file system because files are a part of directory or we can say that files are stored under the directory in the directory tree. So if directory attributes does not allow us to perform a particular operation on the directory than that operation can never be performed on the file which is stored inside that directory.
10. A file contains 1026 bytes. How many bytes of disk space will it consume if size of a disk block is 1024 bytes?
Explanation: Sine files are written to the disk in terms of block size, the size consumed by the file vary from the original size of the file. Suppose, if a file size is 800 bytes but the block size on the system is 1024 bytes, then that file will consume 1024 bytes on diskspace i.e. 1 block.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.