QUIZ Answer Merged
QUIZ Answer Merged
QUIZ-2
1. Which of the following command doesn’t create a process?
a) pwd
b) fork
c) cd
d) pwd and cd
Answer: d
Explanation: When we run a command, a process representing the command is started by the shell
process but all commands don’t set up processes. Built-in commands of the shell like pwd, cd etc do
not create processes.
2. Which command shows some attributes of a process?
a) pid
b) $$
c) ps
d) HOME
Answer: c
Explanation: ps command is used to show some attributes of a process. This command reads through
the kernel’s data structures and process tables to fetch the characteristics of a process. By default, ps
command displays the processes owned by the user running the command.
3. Which of the following attribute is not shown by ps command?
a) PID
b) PPID
c) tty
d) size
Answer: d
Explanation: ps command displays the processes owned by the user running the command. If we
execute the command immediately after logging in, it may produce an output like this:
$ ps
PID TTY TIME CMD
291 console 0:00 bash // login shell of this user
4. Which option is used by ps command to get a detailed listing of process attributes?
a) -u
b) -f
c) -l
d) –x
Answer: b
Explanation: ps is a highly variant command; its actual output varies across different flavours. To get
a detailed listing of process attributes along with PPID and owner (UID), we have to use the -f option
with ps command. For example,
$ ps -f
UID PID PPID C STIME TTY TIME CMD
Abd 367 291 0 12:35:16 console 0:00 vi create_user.sh
Ryan 291 1 0 10:24:58 console 0:00 -bash
5. Which option is used by the system administrator for displaying processes of a user?
a) -f
b) -u
c) -a
d) –e
Answer: b
Explanation: The system administrator needs to use the -u (user) option to know the activities of a
user. For example,
$ ps -u
PID TTY TIME CMD
378? 0:05 Xsession
339 pts/3 0:00 bash
460 pts/5 0:00 dtsession
478 pts/5 0:00 vi
QUIZ-3
1. Which command is used to display the octal value of the text
a) octal
b) text_oct
c) oct
d) od
Answer: d
2. Which command is used to view compressed text file contents
a) cat
b) type
c) zcat
d) print
Answer: c
3. Which command changes a file’s group owner
a) cgrp
b) chgrp
c) change
d) group
Answer: b
4. Which command is used to extract intermediate result in a pipeline
a) tee
b) extract
c) exec
d) none of the mentioned
Answer: a
5. Which command is used to extract a column from a text file
a) paste
b) get
c) cut
d) tar
Answer: c
6. Which command is used to display disk consumption of a specific directory
a) du
b) ds
c) dd
d) dds
Answer: a
7. Which command is used to perform backup in unix?
a) backup
b) cpio
c) zip
d) gzip
Answer: b
8. Which command creates an empty file if file does not exist?
a) cat
b) touch
c) ed
d) read
Answer: b
9. Which option of rm command is used to remove a directory with all its subdirectories
a) –b
b) –o
c) –p
d) –r
Answer: d
10. Which command is used to identify file type?
a) Type
b) File
c) Finfo
d) Info
Answer: b
QUIZ-4
1. In how many broad categories, files are divided into UNIX?
a) 2
b) 4
c) 5
d) 3
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.
2. The most common file type is ___
a) ordinary file
b) directory file
c) device file
d) ordinary file and directory file
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.
3. 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
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.
4. Each entry of directory file has component(s) namely _____
a) filename
b) inode number
c) filename and inode number
d) file size
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).
5. When we log in, the UNIX places us in a directory, called ______ directory
a) home
b) main
c) parent
d) current
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.
6. The root directory is represented by ___
a) \
b) /
c) *
d) $
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.
7. _____ and _____ cannot be used in a filename.
a) /, NULL
b) $,^
c) ., %
d) NULL, $
Answer: a
Explanation: UNIX imposes no rules in framing filename extensions but there are some special
characters that cannot be used while naming a file. / and NULL are the characters that cannot be used
in a filename.
8. Which command is used for changing the current directory?
a) cd
b) cp
c) pwd
d) rm
Answer: a
Explanation: 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:
$ cd dir_one
$pwd
/bin/user06/dir_one
9. Which command is used for creating directories?
a) rmdir
b) mkdir
c) cd
d) cp
Answer: b
Explanation: 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,
$ mkdir dir_01
10. What does the following command do? $ mkdir dir dir/dir_01/dir_02
a) create dir, dir_01 and dir_02
b) creates dir_02
c) creates dir only
d) throws an error
Answer: a
Explanation: The above command first creates a directory named dir and after that it creates a
subdirectory dir_01 under dir. At last, it creates another subdirectory dir_02 under dir_01. Thus a
directory tree is formed in which directory dir is the parent directory and dir_01, dir_02 are
subdirectories.
11. 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 creation
Answer: d
12. Which command is used for removing an empty directory?
a) mkdir
b) rmdir
c) del
d) remove
Answer: b
Explanation: 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.
$ rmdir dir_001
13. 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 it
Answer: d
Explanation: 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.
14. All UNIX and LINUX systems have one thing in common which is ____
a) set of system calls
b) set of commands
c) set of instructions
d) set of text editors
Answer: a
Explanation: As we know UNIX and LINUX systems have one thing in common; they use the same
set of system calls.
15. Which of the following mode is used for opening a file in both reading and writing?
a) O_RDONLY
b) O_WRONLY
c) O_RDWR
d) O_WDR
Answer: c
Explanation: There are three modes of opening a file namely:
O_RDONLY - opens files for reading
O_WRONLY - opens file for writing
O_RDWR - opens file for reading and writing
QUIZ-5
1. Which command is used to display and create files?
A. cat
B. vi
C. ed
D. lyrix
Answer: Option A
3. Which column contains all details of the permissions of a file when you issue the ls -l
command?
A. second
B. fourth
C. third
D. first
Answer: Option D
A. dir
B. prompt $p$g
C. pwd
D. path
Answer: Option C
5. The command used to compare the files is known as
A. comp
B. cmp
C. do
D. ccp
Answer: Option B
6. Which command is used to terminate a process?
A. shutdown
B. haltsys
C. cancel
D. kill
Answer: Option D
7. The cp command uses:
A. standard input file
B. standard output file
C. both input and output file
D. neither standard input nor standard output file
Answer: Option D
8. Which of the following special shell variables is used to process number of the last
background job?
A. $!
B. $#
C. $0
D. $*
Answer: Option A
9. Which of the following is not a filter?
A. cat
B. grep
C. wc
D. sort
E. None of the above
Answer: Option E
10. Which command is used to change directory to the name beginning with a 'p'?
A. cd p
B. cd p?
C. cd p*
D. cd [p]
Answer: Option C
11. The Unix shell is both _______ and _______ language.
a) interactive, responsive
b) interpreter, executing
c) scripting, interpreter
d) high level, low level
Answer: c
Explanation: The UNIX shell is both an interpreter and scripting language. We can also say that shell
can be interactive or non-interactive. When we log in to our system, interactive shell presents a
prompt and wait for our requests while a non-interactive shell is managed by an interactive shell
while executing a shell script.
a. Many people can use a UNIX based computer at the same time; hence UNIX is called as a
multiuser system
b. A user can run multiple programs at the same time; hence UNIX is called a multitasking
environment.
Answer: (c).
13. Which part of the Unix operating system interacts with the hardware?
a) Kernel
b) Shell
c) vi editor
d) application program
Answer: a
Explanation: The kernel is the core of the operating system. It is a collection of routines written
in C which directly communicates with the hardware. User programs that need to interact with
the hardware access the services of the kernel. There is only one kernel running on a system,
unlike shells which can be multiple.
QUIZ-6
Ans : B
5. Which command is used to arranges lines of text alphabetically or
numerically?
A. sort
B. psort
C. asort
D. series
Ans : A
6. Which option is used ignores first x fields when sorting?
A. -x
B. +x
C. -X
D. +X
Ans : B
7. If there are special characters in a pattern, then we've to enclose them in
______
A. single quotes
B. double quotes
C. Without any quotes
D. None of the above
Ans : B
8. POSIX identifies regular expressions as belonging to ____ categories.
A. 2
B. 3
C. 4
D. 5
Ans : A
9. Which of the following is not filter in unix?
A. cat
B. head
C. tail
D. cd
Ans : D
10. Which of the following filter is used to remove duplicate lines?
A. cat
B. sed
C. uniq
D. grep
Ans : C
11. The basic building blocks of Unix permissions are ____________.
A. read
B. write
C. execute
D. All of the above
Ans : D
12. How many types of permissions a file has in UNIX?
A. 2
B. 3
C. 4
D. 5
Ans : B
13. What is group ownership?
A. group of users who can access the file
B. group of users who can create the file
C. group of users who can edit the file
D. group of users who can delete the file
Ans : A
Ans: C
Blank for loop with ; ; is always infinite loop. printf() will never executed in this program.
return 0;
}
(A) Compilation Error
(B) Runtime Error
(C) Hello is printed one time
(D) Hello is printed infinite times
Ans: D
Always remember, a for loop with only two ; is infinite loop. And it is because there is no
initialization, condition & increment/decrements
3. What is the meaning of below lines?
void sum (int, int);
Ans: B
4. The concept of two functions with the same name is known as?
Ans: B
(A) Yes
(B) No
(C) Depends on Compiler
(D) Yes but run time error
Ans: B
(A) #include<stdio.h>
(B) return 0
(C) void main(int argc , char ** argv)
(D) None of above
Ans: A
(A) Yes
(B) No
Ans: B
Function can return only one value. If you want to return group of values then create a structure
and return it.
(A) Yes
(B) No
Ans: B
Ideally No but remember pragma directives allows few function to be executed before and after
main() function
9. What is sizeof() in C?
(A) Operator
(B) Function
(C) Macro
(D) None of these
Ans: A
10. Is it true that a function may have several declaration, but only one definition?
(A) True
(B) False
Ans: A
Declaration like int sum(int, int); is allowed number of times but definition int sum(int a, int b) {
return a+b; } is allowed only one time. Multiple definition of same function is compilation error
( redefinition error )
11. Will compiler produce any compilation error if same header file is included two times?
(A) Yes
(B) No
Ans: B
(A) #pragma
(B) #error
(C) #ifndef
(D) #elseif
Ans: D
13. Which compilation unit is responsible for adding header files contained in the source code?
(A) Linker
(B) Compiler
(C) Assembler
(D) Preprocessor
Ans: D
Explanation: The num[9] is the last element of the array number because the total element in this
array is 10, and the array starts with 0, so the last element of the array is the num[9].
15. If p is an integer pointer with a value 1000, then what will the value of p + 5 be?
a) 1020
b) 1005
c) 1004
d) 1010
Ans: a)
Ans: A
5. p++ executes faster than p+1 because
a) p uses registers
b) p++ is a single instruction
c) ++ is faster than +
d) None of these
Ans: B
6. Which of the following statements is true?
a) C Library functions provide I/O facilities
b) C inherent I/O facilities
c) C doesn’t have I/O facilities
d) Both (a) and (c)
Ans: A
7. Which pair of functions below are used for single character I/O.
a) Getchar() and putchar()
b) Scanf() and printf()
c) Input() and output()
d) None of these
Ans: A
8. If one or more structure are other structures, then the structure is known as
(A) Nested structure
(B) Structured structure
(C) Invalid structure
(D) Self referential structure
Ans: A
9. Every string must be terminated by
(A) Linefeed character
(B) Null character
(C) Newline character
(D) Carriage return character
Ans: B
10. The __ is a program that links the object code of the program with the library function
code that is necessary for the program to run.
(A) C linker
(B) Compiler
(C) C compiler
(D) Editing
Ans: A
11. Which of the following statement about functions of false?
(A) A function can call itself.
(B) A function can call another function.
(C) Constants can appear in the formal argument list.
(D) More than one function is allowed in a program unit.
Ans: C
12. A pointer is
A. A keyword used to create variables
B. A variable that stores address of an instruction
C. A variable that stores address of other variable
D. All of the above
Ans: C
13. Point out the error in the program?
struct emp
{
int ecode;
struct emp *e;
};
a. Error: in structure declaration
b. Linker Error
c. No Error
d. None of above
Ans: C
This type of declaration is called as self-referential structure. Here *e is pointer to a struct
emp.
14. What should be the expression return value for a do-while to terminate
a) 1
b) 0
c) -1
d) NULL
Answer: (b)
15. When the main function is called, it is called with the arguments
a) argc
b) argv
c) None of these
d) both a & b
Answer: (d)
QUIZ -9
1. In a system call
i. A service request to the operating system
ii. The normal flow of the operating system is interrupted
iii. The control is given to the operating system
iv. The system is calling for resources
a) iii and iv only
b) i and iii only
c) i, ii and iii
d) all of the above
Ans: c
2. #include <unistd.h>
int pipe(int fildes[2]);
Describe pipe()
a) If successful, pipe returns 1. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
b) If successful, pipe returns 0. If unsuccessful, pipe returns 1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
c) If successful, pipe returns 0. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for write and fields[1] used for read
d) If successful, pipe returns 0. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
Ans: d
3. Choose the correct statements.
a) Any process has an associated owner ID and group ID
b) Effective ID defines who you are for the duration of a process
c) Real ID defines who you are for the duration of a process
d) Both (a) & (b)
Ans: d
4. To simulate any of the system commands, which of the system calls - fork, wait, and excel are
required to be used?
a) fork and wait
b) fork, wait, and execl
c) fork and excel
d) wait and excel
Ans: b
5. Choose the correct statements.
a) C programs can directly make system calls
b) Library functions use system call
c) Both (a) and (b)
d) Only (a) not (b)
Ans: c
6. In which cases(s) fork system call will fail.
a) The limit on the maximum number of processes in the system would be exceeded.
b) The limit on the maximum number of processes that can be under execution by a single user
would be exceeded.
c) Both (b) & (c)
d) Neither (a) nor (b)
Ans: c
7. Select the correct statement(s)
(i) An open file descriptor in a Unix process is an integer.
(ii) Two Unix processes may simultaneously have open file descriptors that refer to the same
open file description.
(iii) Two open file descriptions in the same Unix processes may refer to the same file.
(iv) When a file is closed the corresponding open file description is de-allocated.
a) All are correct
b) (i), (ii) and (iii) are correct
c) (i) and (ii) are correct
d) (ii) and (iii) are correct
Ans: b
8. When a process is forked the child process inherits some properties. Which of the following
properties are inherited?
i. The process id.
ii. The process code
iii. All the defined program variables
iv. The stack
a) Everything
b) All except i and iii
c) All except i
d) All except iv
Ans: c
9. Which of the following is correct for pipe()
(i) When a pipe is defined – its either end can be utilized for reading / writing
(ii) The named pipes are behaving like a file, where you can read or write data trough some
process.
a) All are correct
b) Only (i)
c) Only (ii)
d) Neither (i) nor (ii)
Ans: c
10. Which one of the following is different than the other?
a) Shared Memory
b) Semaphore Set
c) Pipe
d) Message Queue
Ans: c
11. The Blocked process comes in running state through which state?
a) New
b) Ready
c) Done
d) None of the above
Ans: b
12. A semaphore is an variable with_________ atomic operations.
a) One
b) Two
c) Three
d) Four
Ans: b
13. WNOHANG in waitpid() means
a) Parent will wait for any arbitrary child
b) Parent will wait for a specific child
c) Parent does not wait if child does not terminate just check and return waitpid()
d) None of the option
Ans: c
14. Which of the following system calls does not return control to the calling Point, on
termination?
a) fork()
b) wait()
c) waitpid()
d) exec
Ans: d
15. To run the script, we should make it executable first by using _____
a) chmod +x
b) chmod +w
c) chmod +r
d) None of the above
Ans: a
1. How key can be generated in IPC in POSIX standard.
(i) IPC_PRIVATE
(ii) Pick a key randomly
(iii) Using ftok()
a) Using (i) and (ii)
b) Using (i) and (iii)
c) Only (iii)
d) All of the above
Ans: D
10. What will be the numberic equivalent of the following file permission:
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
a) 464
b) 446
c) 644
d) 640
Ans: C
1. To enforce ………………….. two functions are provided enter-critical and exit-critical,
where each function takes as an argument the name of the Resource that is the
subject of competition.
a) Starvation
b) Synchronization
c) Deadlock
d) Mutual Exclusion
Ans: D
5. Which IPC is nonvolatile (in the sense that they do not disappear even if no process
has them open?)
a) Pipes
b) FIFO
c) Semaphore
d) Message Queue
Ans: B
7. Choose the option that happens after executing dup2(int fildes, int fildes2); //
a) fildes is closed
b) fildes2 is closed
c) both file descripters are closed
d) none of the file descripters are closed
Ans: B
8. A FIFO is
a) A file with a name and permissions
b) A file with name but without permissions
c) A file without name but with permissions
d) A file without name and permissions
Ans: A