Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

The output of ls dir* is ___(a) all files in the current directory(b) all files in the directory having a filename starting with dir(c) no filename is displayed(d) erroneousI had been asked this question in an internship interview.My question is from Listing Directory Contents: Is Command in chapter The File System of Unix

Answer»

Right option is (b) all FILES in the DIRECTORY having a filename starting with dir

For EXPLANATION I would say: The above COMMAND displays those files in the directory, the NAMES of which will be starting with a prefix ‘dir’. Here * is a meta-character which is used for pattern matching.

2.

-t option sorts the files according to ____(a) last modification time(b) last access time(c) ASCII collating sequence(d) file sizeThe question was posed to me during an online exam.Origin of the question is Listing Directory Contents: Is Command topic in section The File System of Unix

Answer»

Correct option is (a) last modification time

For explanation: ls-t displays the FILENAMES based on the value of the last modification time of the FILE i.e. it sorts all the filenames in ACCORDANCE with their last modification time.

3.

-u option sorts the files according to ____(a) last modification time(b) last access time(c) ASCII collating sequence(d) file sizeThis question was posed to me during an online exam.This question is from Listing Directory Contents: Is Command topic in chapter The File System of Unix

Answer»

The correct answer is (b) LAST access time

For explanation: ls-u DISPLAYS the FILENAMES BASED on the value of the last access time of the file i.e. it SORTS all the filenames according to their last access time.

4.

ls -s prints the allocated file size in blocks.(a) True(b) FalseI got this question during an internship interview.My question comes from Listing Directory Contents: Is Command topic in chapter The File System of Unix

Answer»

Correct choice is (a) True

To elaborate: FILES are stored onto the disk in TERMS of BLOCK size. The block size allocated to the file can be displayed using -s OPTION with LS command.

5.

What does the -S option do in ls command?(a) sorts according to modification time(b) sorts according to last access time(c) sorts according to file size(d) sorts according to inode numberI have been asked this question at a job interview.The doubt is from Listing Directory Contents: Is Command in chapter The File System of Unix

Answer»

The correct ANSWER is (c) sorts according to FILE size

Easiest EXPLANATION: ls -S sorts the FILENAMES according to the file size with largest size FIRST.

6.

-r option is same as -R option in ls command.(a) True(b) FalseI have been asked this question by my school teacher while I was bunking the class.The question is from Listing Directory Contents: Is Command in portion The File System of Unix

Answer»

Correct option is (b) False

The best I can explain: Both -r and -R are different options and performs different TASKS. -r is used to sort the filenames in REVERSE order while sorting while -R is used for recursive LISTING of files.

7.

What is the collating sequence of ls command for listing files?(a) Numerals>Uppercase> Lowercase(b) Numerals>Lowercase> Uppercase(c) Lowercase>Uppercase> Numerals(d) Uppercase> Numerals> LowercaseThis question was addressed to me in an online quiz.This interesting question is from Listing Directory Contents: Is Command in division The File System of Unix

Answer»

Right ANSWER is (a) Numerals>Uppercase> Lowercase

Explanation: The OUTPUT of ls commad is arranged in ASCII collating SEQUENCE which is, filenames STARTING with Numerals first, then Uppercase, then lowercase.

8.

How can we identify executables and directories from the output of ls command?(a) using -F option(b) using-x option(c) using -a option(d) using -i optionThis question was addressed to me in an online interview.This interesting question is from Listing Directory Contents: Is Command topic in division The File System of Unix

Answer»

The correct option is (a) USING -F option

Best explanation: The OUTPUT of the ls command simply DISPLAYS filenames without indicating the file type. For identifying the file type we USE -F option. The output of ls-F displays filenames with two symbols * and /, which are type indicators. The filenames containing * are executables while those containing / are directories.

9.

$ ls-R outputs all files and subdirectories in a recursive manner.(a) True(b) FalseThis question was posed to me during an interview.I would like to ask this question from Listing Directory Contents: Is Command in section The File System of Unix

Answer» RIGHT option is (a) True

The best explanation: The above command TRAVERSES the directory tree in a recursive manner until no subdirectories are left. In simple words, we can say that it PRODUCES a recursive listing of files.
10.

Which option is used with ls command to produce multi columnar output?(a) -x(b) -F(c) -a(d) -vI had been asked this question in examination.Question is taken from Listing Directory Contents: Is Command in division The File System of Unix

Answer»

Right CHOICE is (a) -x

Best explanation: If there are multiple FILES PRESENT in a DIRECTORY for listing, it is better that we display these files in multiple COLUMNS. For this purpose -x is used. For example,

11.

-a option is used with ls command for what purpose?(a) for showing hidden files(b) for showing executables(c) for showing directories(d) for multi columnar outputThis question was addressed to me by my college director while I was bunking the class.My question comes from Listing Directory Contents: Is Command in chapter The File System of Unix

Answer»

Right option is (a) for showing hidden files

The best EXPLANATION: -a option when used with ls command displays all the files including hidden files. Files beginning with a ( . ) are listed using -a option. There are certain files (FILENAMES beginning with a. ) These files are not listed without -a option.

12.

Which option is used with ls to display attributes of the directory ?(a) -a(b) -ld(c) -d(d) -oThis question was posed to me during an interview for a job.The question is from Listing Directory Contents: Is Command in portion The File System of Unix

Answer»

Correct option is (c) -d

For EXPLANATION: LS command when USED with directory name as an argument, lists all the files in the directory. To FORCE ls to list the attributes of the directory we use the -LD option.

13.

Which command is used for listing files in a directory?(a) ps(b) list(c) ls(d) wcI had been asked this question during an interview.My enquiry is from Listing Directory Contents: Is Command in division The File System of Unix

Answer»

The correct choice is (c) ls

Easiest EXPLANATION: ls command is one of the most powerful commands USED in UNIX system. It comes available with a BUNCH of options for listing files available in the directory. There are a number of options LIKE -l, -a which are used for listing files in different manners according to user’s need.

14.

Which option is used with ls command for long listing of files with seven attributes?(a) -a(b) -l(c) -x(d) -iThe question was posed to me in final exam.This key question is from Listing Directory Contents: Is Command in portion The File System of Unix

Answer»

Right choice is (b) -l

Explanation: -l is used with ls command for long listing of files in ASCII collating sequence. The attributes DISPLAYED are:

-> File TYPE and permissions

-> Links

-> Ownership

-> Group ownership

-> File size

-> Last modification TIME

-> Filename

15.

For moving two level up in the file hierarchy system using cd command once, we separates ( . . ) by which symbol?(a) ?(b) $(c) *(d) /This question was posed to me in an internship interview.This intriguing question originated from Absolute and Relative Pathnames topic in section The File System of Unix

Answer»

Correct OPTION is (d) /

To EXPLAIN I would say: 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 / .

16.

The output of$HOME is an example of absolute pathname.(a) True(b) FalseThe question was posed to me in a job interview.Asked question is from Absolute and Relative Pathnames topic in portion The File System of Unix

Answer»

Correct answer is (a) True

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.

17.

cd/bin/user/directory/abc is an example of relative pathname.(a) True(b) FalseThis question was addressed to me in a job interview.This interesting question is from Absolute and Relative Pathnames topic in section The File System of Unix

Answer»

The CORRECT ANSWER is (b) False

The explanation is: 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.

18.

$ cd. .is used to move ___ level up in the file hierarchy.(a) two(b) one(c) three(d) zeroThe question was posed to me in an international level competition.My question comes from Absolute and Relative Pathnames in portion The File System of Unix

Answer»

Right choice is (b) ONE

For EXPLANATION: ( . . ) two dots represent the parent DIRECTORY. So cd . . will make US move one LEVEL up. For example,

19.

$ cp file_01.copies the file named file_01 in ____ directory(a) current(b) parent(c) root(d) userThe question was posed to me in an online interview.The doubt is from Absolute and Relative Pathnames in chapter The File System of Unix

Answer» RIGHT option is (a) current

Easiest explanation: The ( . ) represents the current DIRECTORY so the above command will create a copy of file_01 in the current WORKING directory.
20.

Which of the following cryptic symbols are used in relative pathname?(a) ( . )(b) ( . . )(c) $(d) ( . ) and ( . . )I got this question during an online exam.This key question is from Absolute and Relative Pathnames topic in section The File System of Unix

Answer»

The CORRECT choice is (d) ( . ) and ( . . )

The explanation: Relative pathname uses TWO cryptic symbols which are ( . ) and ( . . )

(.)a single dot represent the current directory.

( . . ) two DOTS represent the parent directory.

21.

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 directoryThe question was posed to me in an interview for internship.The question is from Absolute and Relative Pathnames topic in division The File System of Unix

Answer»

Correct choice is (C) PATHNAME RELATIVE to parent and current DIRECTORY

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

22.

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 directoryI got this question at a job interview.My query is from Absolute and Relative Pathnames topic in division The File System of Unix

Answer»

Correct option is (b) pathname relative to the root (/)

To elaborate: 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_01is an example of absolute pathname.

23.

Pathname is a sequence of symbols and directories indicating the location of a file.(a) True(b) FalseThis question was addressed to me by my school principal while I was bunking the class.My question is based upon Absolute and Relative Pathnames topic in portion The File System of Unix

Answer»

Right option is (a) True

Best 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,

24.

pwd and echo $HOME will display the same output.(a) True(b) FalseI got this question in an international level competition.This intriguing question comes from File Handling Commands: pwd, cd topic in chapter The File System of Unix

Answer»

Correct option is (b) False

Explanation: pwd is used for DISPLAYING the absolute pathname of our current WORKING dircectory while $HOME DISPLAYS the absolute pathname of our home directory.

25.

If rmdir dir001 fails, what could be the reason(s)?(a) dir001 doesn’t exist(b) dir001 is not empty(c) permissions of dir001 doesn’t allow to remove it(d) dir001 doesn’t exist, dir001 is not empty and permissions of dir001 doesn’t allow to remove itI had been asked this question at a job interview.I'd like to ask this question from File Handling Commands: pwd, cd in section The File System of Unix

Answer»

Right choice is (d) dir001 doesn’t exist, dir001 is not empty and permissions of dir001 doesn’t allow to REMOVE it

To elaborate: There could be MULTIPLE reasons which could lead to FAILURE while removing a directory. Major reasons could be:

->directory doesn’t exists.

->directory is not empty.

->permissions of directory doesn’t allow to remove it.

26.

For creating or removing directories, the user must be positioned above the directory or in the parent directory of the directory, on which the operation is to perform.(a) True(b) FalseI had been asked this question in an online interview.My doubt stems from File Handling Commands: pwd, cd topic in portion The File System of Unix

Answer»

The correct option is (a) True

For explanation I would say: For performing any OPERATION on the file system, the user must be HIERARCHICALLY above the directory or should be in PARENT directory of the directory on which the operation is to be performed. Without FOLLOWING this rule, the user will not be able to perform any operation on the file system.

27.

Multiple directories can be removed using single rmdir command.(a) True(b) FalseThis question was posed to me in final exam.This key question is from File Handling Commands: pwd, cd topic in section The File System of Unix

Answer»

Correct CHOICE is (a) True

The best explanation: Like MKDIR command, we can delete multiple directories using ONE shot of rmdir command. While deleting directories and subdirectories, a reverse LOGIC is applied i.e. first the subdirectories or the CHILD directories are removed and then their parent directories.

28.

Which command is used for removing an empty directory?(a) mkdir(b) rmdir(c) del(d) removeThe question was asked during an online interview.This key question is from File Handling Commands: pwd, cd in division The File System of Unix

Answer»

The correct answer is (b) RMDIR

The explanation is: rmdir command is used for removing directories provided the DIRECTORY should be empty. For example, to remove a directory named dir_001 in the current directory TYPE the following command on the TERMINAL.

29.

Sometimes we are unable to create a directory because ______________(a) the directory may already exist in the current directory(b) there may be an ordinary file by the same name in the current directory(c) the permissions set for the current directory does not allow the creation(d) the directory may exist, there may be an ordinary file, the permissions set for the current directory does not allow the creationThis question was posed to me in unit test.I need to ask this question from File Handling Commands: pwd, cd topic in division The File System of Unix

Answer»

Right ANSWER is (d) the directory may exist, there may be an ordinary file, the permissions set for the CURRENT directory does not allow the creation

The best I can explain: Sometimes we are not able to create directory because of multiple reasons as STATED above.

30.

We can create multiple directories by single invocation of mkdir command.(a) True(b) FalseThis question was posed to me in an interview.The question is from File Handling Commands: pwd, cd topic in portion The File System of Unix

Answer»

The correct option is (a) True

Explanation: Multiple directories can be CREATED by ONE MKDIR COMMAND.

31.

cd command cannot be used without any argument.(a) True(b) FalseI had been asked this question in an online interview.The question is from File Handling Commands: pwd, cd in section The File System of Unix

Answer» CORRECT choice is (b) False

For EXPLANATION: cd command can be used without any arguments. When it used in such a way, then it CHANGES our current directory to HOME directory.
32.

Which command is used for creating directories?(a) rmdir(b) mkdir(c) cd(d) cpThe question was asked in semester exam.The doubt is from File Handling Commands: pwd, cd in chapter The File System of Unix

Answer»

Right choice is (B) mkdir

To explain: DIRECTORIES in UNIX are created using mkdir command. The NAME of the directory to be created is specified as an ARGUMENT to the mkdir command. For example, to create a dir named dir_01 in the current directory we can use the FOLLOWING command,

33.

Which command is used for printing the current working directory?(a) HOME(b) cd(c) pwd(d) dirThe question was posed to me in class test.I'd like to ask this question from File Handling Commands: pwd, cd topic in portion The File System of Unix

Answer» RIGHT choice is (c) pwd

For explanation I would SAY: pwd command is used for checking our current directory. Current directory is the directory in which we are currently WORKING. pwd DISPLAYS the ABSOLUTE pathname i.e. with respect to the root directory.
34.

Which command is used for changing the current directory?(a) cd(b) cp(c) pwd(d) rmThis question was addressed to me in final exam.My question comes from File Handling Commands: pwd, cd in division The File System of Unix

Answer»

The correct answer is (a) cd

For explanation I would say: cd (change directory) command is used for moving around the file SYSTEM. cd command is usually invoked with a argument. After INVOCATION, it changes the CURRENT directory to the directory SPECIFIED as argument. Cp command is used for copying files while rm command is used for deleting files.

For example: our current directory is /bin/user06 and we want to change our directory to a directory named dir_one which is inside the user06 directory. To do so, TYPE the following:

35.

We should avoid filenames starting with a – (hyphen).(a) True(b) FalseThe question was asked in examination.Question is taken from Categories of Files in chapter The File System of Unix

Answer» RIGHT ANSWER is (a) True

To ELABORATE: 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.
36.

_____ and _____ cannot be used in a filename.(a) /, NULL(b) $,^(c) ., %(d) NULL, $This question was addressed to me during an interview for a job.This interesting question is from Categories of Files topic in section The File System of Unix

Answer»

Right choice is (a) /, NULL

The best I can explain: 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.

37.

Filenames in UNIX are not case-sensitive.(a) True(b) FalseI got this question in a job interview.My enquiry is from Categories of Files in chapter The File System of Unix

Answer»

The CORRECT choice is (b) False

The explanation is: 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.

38.

UNIX imposes no rule for framing filename extensions.(a) True(b) FalseThis question was posed to me in an online quiz.I'd like to ask this question from Categories of Files topic in division The File System of Unix

Answer»

Right answer is (a) True

The BEST 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 .

39.

The root directory is represented by ___(a) \(b) /(c) *(d) $The question was posed to me during an interview for a job.My question is based upon Categories of Files in portion The File System of Unix

Answer»

Right answer is (b) /

For EXPLANATION I WOULD say: 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.

40.

UNIX treats everything as a file.(a) True(b) FalseI got this question in an international level competition.Origin of the question is Categories of Files topic in section The File System of Unix

Answer»

Correct option is (a) True

To explain I WOULD say: 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.

41.

Device files are used by the kernel for operating the device.(a) True(b) FalseI got this question in an interview for job.This interesting question is from Categories of Files topic in chapter The File System of Unix

Answer»

Correct choice is (a) True

For 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.

42.

When we log in, the UNIX places us in a directory, called ______ directory(a) home(b) main(c) parent(d) currentThis question was posed to me in class test.I want to ask this question from Categories of Files in division The File System of Unix

Answer» RIGHT answer is (a) home

The 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.
43.

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 filesI have been asked this question during an online exam.The query is from Categories of Files in chapter The File System of Unix

Answer»

Correct option is (b) a directory containing details of the files and SUBDIRECTORIES it CONTAINS

For explanation I would say: 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.

44.

Each entry of directory file has component(s) namely _____(a) filename(b) inode number(c) filename and inode number(d) file sizeI had been asked this question in an online quiz.My enquiry is from Categories of Files in portion The File System of Unix

Answer»

Correct option is (c) filename and inode number

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).

45.

The most common file type is ___(a) ordinary file(b) directory file(c) device file(d) ordinary file and directory fileThis question was posed to me in an interview for internship.I need to ask this question from Categories of Files in section The File System of Unix

Answer»

The correct option is (a) ordinary file

For explanation I WOULD say: 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.

46.

In how many broad categories, files are divided into UNIX?(a) 2(b) 4(c) 5(d) 3I had been asked this question in an online quiz.Question is taken from Categories of Files topic in chapter The File System of Unix

Answer»

Right ANSWER is (d) 3

Easy 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.

47.

In UNIX, the file name and file size are stored in the file itself.(a) True(b) FalseI got this question in class test.My question is from Categories of Files in division The File System of Unix

Answer» RIGHT CHOICE is (B) False

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.
48.

A file is a container for storing information.(a) True(b) FalseThis question was posed to me by my school teacher while I was bunking the class.The above asked question is from Categories of Files in chapter The File System of Unix

Answer»

Correct choice is (a) True

The 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.