This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Categories of Files”.
1. A file is a container for storing information.
Explanation: We can define a file as a stream of characters or a container for storing information. While working in a UNIX environment, we came across three categories of files which are classified as- ordinary file, directory file and device file.
2. In how many broad categories, files are divided into UNIX?
Explanation: Files are divided into three major categories i.e. ordinary file, directory file and device file. The characteristics of these three categories of files differ from each other and each category has a predefined use.
3. In UNIX, the file name and file size are stored in the file itself.
Explanation: A UNIX file’s size is not stored in the file, nor its name. All this information is stored separately in a separate area of hard disk which is not directly accessible to humans, but only to the kernel.
4. The most common file type is ___
a) ordinary file
b) directory file
c) device file
d) ordinary file and directory file
Explanation: The most common file type is an ordinary file or a regular file. It contains data as a stream of characters. Ordinary files are also of two types, text file and binary file.
5. What is a directory file?
a) a directory containing data
b) a directory containing details of the files and subdirectories it contains
c) a directory contains files
d) a directory containing data and files
Explanation: A directory file contains no data but some details of the subdirectories and files that it contains. Directory files contain an entry for every file and subdirectory in it and each entry has some necessary information regarding files and subdirectories.
6. Each entry of directory file has component(s) namely _____
b) inode number
c) filename and inode number
d) file size
Explanation: Every entry of the directory file contains information about files and subdirectories and each entry has two components:
-> A unique identification number (called inode number).
7. Device files are used by the kernel for operating the device.
Explanation: Device files are nothing but special files which does not contain a stream of characters but some attributes related to the devices which govern the operation of a device. The kernel reads this file for the attributes to perform operations on any device.
8. When we log in, the UNIX places us in a directory, called ______ directory
Explanation: When we log in, the system automatically places us in a directory called Home directory. We can change our directory if we want and can also view our home directory using the shell variable, HOME.
9. UNIX treats everything as a file.
Explanation: All physical devices such as printers, hard disk are treated as files by the UNIX system. Even the kernel, shell and main memory is treated as a file by UNIX operating system.
10. The root directory is represented by ___
Explanation: The root directory (/) serves as a reference point for all the files. All the files are hierarchically below it. All files in UNIX are related to one another. The file system in UNIX is a collection of all these related files (ordinary, directory and device files) organized in a hierarchical manner.
11. UNIX imposes no rule for framing filename extensions.
Explanation: UNIX imposes no rules for framing filename extensions. For example, a shell script doesn’t need to have the .sh implication, even though it helps in identification. In all cases, it’s the application that imposes the restriction. For example, C compiler expects C program filenames to end with .c .
12. _____ and _____ cannot be used in a filename.
a) /, NULL
c) ., %
d) NULL, $
Explanation: UNIX imposes no rules in framing filename extensions but there are some special characters which cannot be used while naming a file. / and NULL are the characters which cannot be used in a filename.
13. Filenames in UNIX are not case-sensitive.
Explanation: Since UNIX is sensitive to case, filenames are also. Hence, chap01, Chap01 and CHAP01 are three different files and can exist in the same directory.
14. We should avoid filenames starting with a – (hyphen).
Explanation: Those files which have filename starting with a (-) are difficult to remove and many commands can interpret such filename as an option which could lead to a miserable situation.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.