Unix Questions and Answers – Absolute and Relative Pathnames

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Absolute and Relative Pathnames”.

1. Pathname is a sequence of symbols and directories indicating the location of a file.
a) True
b) False
View Answer

Answer: a
Explanation: pathname is basically a sequence of symbols and filenames which indicates the location of our file in the hierarchical file system. pathname is of two types – absolute and relative pathnames. For example,

$ pwd
/users09/dir01/documents	// pathname indicating our current directory

2. What is an absolute pathname?
a) pathname relative to a parent directory
b) pathname relative to the root (/)
c) pathname relative to parent and current directory
d) pathname relative to the current directory
View Answer

Answer: b
Explanation: When a file’s pathname is determined with respect to the root(/), such a pathname is called absolute pathname. No two files in a UNIX system can have same absolute pathnames. Two files can be of same name but in different directories hence their pathname would be different from each other. For example, /bin/user06/dir_01 is an example of absolute pathname.
advertisement
advertisement

3. What is a relative pathname?
a) pathname relative to parent directory
b) pathname relative to root (/)
c) pathname relative to parent and current directory
d) pathname relative to current directory
View Answer

Answer: c
Explanation: When a file uses its parent or current directory as a reference for navigation, such a pathname is called absolute pathname.

$ pwd
/user08/kumar/documents/directory001	// absolute pathname

4. Which of the following cryptic symbols are used in relative pathname?
a) ( . )
b) ( . . )
c) $
d) ( . ) and ( . . )
View Answer

Answer: d
Explanation: Relative pathname uses two cryptic symbols which are ( . ) and ( . . )
(.) a single dot represent the current directory.
( . . ) two dots represent the parent directory.
Note: Join free Sanfoundry classes at Telegram or Youtube

5. $ cd . . is used to move ___ level up in the file hierarchy.
a) two
b) one
c) three
d) zero
View Answer

Answer: b
Explanation: ( . . ) two dots represent the parent directory. So cd . . will make us move one level up. For example,

advertisement
$ pwd
/user08/docs/template	         // current working directory
$ cd . .		        // one level up
$ pwd
/user08/docs

advertisement

6. $ cp file_01 . copies the file named file_01 in ____ directory
a) current
b) parent
c) root
d) user
View Answer

Answer: a
Explanation: The ( . ) represents the current directory so the above command will create a copy of file_01 in the current working directory.

7. cd /bin/user/directory/abc is an example of relative pathname.
a) True
b) False
View Answer

Answer: b
Explanation: Whenever the pathname is relative to the root it is an example of relative pathname. The above pathname is also relative to the root, so it is an example of relative pathname.

8. The output of $HOME is an example of absolute pathname.
a) True
b) False
View Answer

Answer: a
Explanation: HOME is a shell variable which prints our home directory. The pathname specified by the output of HOME is an example of absolute pathname.

$ HOME
/home/users/user_06

9. The output of the following command is __________

$ cp  abd/ .user_06

a) copies .user_06 file in current directory
b) copies .user_06 file in parent directory of directory named abd
c) undefined behaviour
d) erroneous output
View Answer

Answer: a
Explanation: ( . ) single dot represents the current directory so the above command will copy the file in the current directory. (.) is a cryptic symbol which represents current working directory and is used in absolute pathname.

10. For moving two level up in the file hierarchy system using cd command once, we separates ( . . ) by which symbol?
a) ?
b) $
c) *
d) /
View Answer

Answer: d
Explanation: For changing your directory to the parent of current directory we can use ( . . ) with cd command. If we want to move more than one level up then we can use the ( . . ) separated by / .

$ cd . . / . .                       -moves two level up

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.