Unix Questions and Answers – Categories of Files

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Categories of Files”.

1. A file is a container for storing information.
a) True
b) False
View Answer

Answer: a
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?
a) 2
b) 4
c) 5
d) 3
View Answer

Answer: d
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.
a) True
b) False
View Answer

Answer: b
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.
advertisement
advertisement

4. The most common file type is ___
a) ordinary file
b) directory file
c) device file
d) ordinary file and directory file
View Answer

Answer: a
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
View Answer

Answer: b
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Each entry of directory file has component(s) namely _____
a) filename
b) inode number
c) filename and inode number
d) file size
View Answer

Answer: c
Explanation: Every entry of the directory file contains information about files and subdirectories and each entry has two components:
-> Filename
-> A unique identification number (called inode number).

7. Device files are used by the kernel for operating the device.
a) True
b) False
View Answer

Answer: a
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.
advertisement

8. When we log in, the UNIX places us in a directory, called ______ directory
a) home
b) main
c) parent
d) current
View Answer

Answer: a
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.
a) True
b) False
View Answer

Answer: a
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.
advertisement

10. The root directory is represented by ___
a) \
b) /
c) *
d) $
View Answer

Answer: b
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.
a) True
b) False
View Answer

Answer: a
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
b) $,^
c) ., %
d) NULL, $
View Answer

Answer: a
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.
a) True
b) False
View Answer

Answer: b
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).
a) True
b) False
View Answer

Answer: a
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.