250+ TOP MCQs on Absolute and Relative Pathnames and Answers

Unix Multiple Choice Questions on “Absolute and Relative Pathnames”.

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

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

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

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

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

Answer: d
Clarification: Relative pathname uses two cryptic symbols which are ( . ) and ( . . )
(.) a single dot represent the current directory.
( . . ) two dots represent the parent directory.

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

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

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

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

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

Answer: b
Clarification: 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

Answer: a
Clarification: 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 __________

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

Answer: a
Clarification: ( . ) 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) /

Answer: d
Clarification: 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

Leave a Reply

Your email address will not be published. Required fields are marked *