Unix Questions and Answers – Listing File and Directory Attributes

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

Answer: a
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?
a) cp
b) list
c) ls
d) attr
View Answer

Answer: c
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
c) links
d) word count of file
View Answer

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

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

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

Answer: b
Explanation: There are basically two types of links; hard link and soft links.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Hard linked files are provided with the same inode number as the original one.
a) True
b) False
View Answer

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

Answer: a
Explanation: Soft linked files are provided with a separate inode number each of which points to the original file location.
advertisement

8. Which option is used with ls command to list the directory attributes rather than its contents?
a) -b
b) -a
c) -l
d) -d
View Answer

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

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

10. A file contains 1026 bytes. How many bytes of disk space will it consume if size of a disk block is 1024 bytes?
a) 1026
b) 1024
c) 2048
d) 4096
View Answer

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

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.