You are on page 1of 6

UNIX

Sample Paper-1

1)Which of the following is true?
a)Shell is a process and runs like any user process
b)Shell is a built-in Kernel functionality
c)Shell is a wrapper for all the commands and utilities
d)None of the above

Answer : A.

2)Which is true with regards to the shell prompt
a)It can be accidentally erased with backspace
b)The prompt cannot be modified
c)The prompt can be customized (modified)
d)None of the above

Answer : C.

3)The /etc/passwd file contains
a)User account info
b)User id and password in encrypted form
c)Just the password of the user in encrypted form
d)None of the above

Answer : A.

4)User id 0 is
a)An innvalid user id
b)The id of the root user
c)The id of a user when the user's account is deleted
d)None of the above

Answer : B.

5)If a file is removed in Unix using 'rm' then
a)The file can be recovered by a normal user
b)The file cannot be recovered by a user
c)The file can be fully recovered provided the sytem is not rebooted
d)The file will be moved to /lost+found directory and can be recovered only by administrator's intervention

Answer :B.

6)Executing the 'cd ..' command when at the root level causes
a)Error message indicating the user can't access beyond the root level
b)Behavior is unix-flavor dependent
c)Results in changing to the 'home' directory
d)Nothing happens

Answer : D.

7)The login shell is
a)The shell program that runs when the user logs in
b)The shell program that authenticates the user while logging in
c)Common shell for all the users that belong to the same group
d)All of the above Answer : A.

8)System calls are
a)The interface to the Kernel
b)Like any function call, implemented as part of the shell
c)Privileged calls that only superuser can make use of
d)None of the above

Answer :A.

9)Hidden files are
a)Those whose 'read' bit is set to 'h'
b)Permitted for (can be accessed) only superusers
c)Files that begin with a '.'
d)a & c

Answer : C.

10)Which of the following is true?
a)There is one superblock per system
b)There is one superblock per filesystem
c)There may be more than one superblock per filesystem ( non-redundant )
d)None of the above

Answer : B.
Description: In a typical unix file system, every filesystem has one superblock only. There may be a redundant superblock
to protect against failures

11)A filename is modified using the command mv filea fileb, where fileb already exists. In this scenario, which of the
following is true?
a)filebs inode number is changed to fileas inode number
b)filebs inode number does not change, remains the same the old fileb
c)The inode entry for fileb is not affected by this command
d)None of the above

Answer :A.
Description: fileb has the inode number that filea had earlier and the inode entry of fileb is released to the kernel.

12)Which of the following is true regarding inode number ?
a)Two files in a system may have the same inode number
b)Two files( non-linked) in a filesystem may have the same inode number
c)When a file is deleted, the inode is also deleted, the same inode number is not reused
d)None of the above

Answer :A.
Description: Inodes are unique within a filesystem, the kernel maintains the free inodes list and reallocates them when
needed

13)A user creates a large data file ( ~ 1 MB size). Which of the following is true regarding the storage of this file on disk?
a)The file is stored in contiguous data disk blocks
b)The file is stored in disk blocks that are not contiguous, the disk blocks maintain the pointer to the next storage block
c)The inode information alone is not sufficient to identify all the disk blocks
d)The file is stored in disk blocks that may not be contiguous, the inode keeps track of where the data blocks are

Answer:D.
Description: The file is stored in disk data blocks that may not be contiguous, the details of these are stored in the inode
addressing information



14)The ls l output for /etc/passwd and /usr/bin/passwd is as follows:
-rw-rw-r-- 1 root root 2807 Apr 26 13:50 /etc/passwd
-r-sxx 1 root root 17008 May 25 02:30 /usr/bin/passwd
If a user, not belonging to the group root, runs the passwd executable in an attempt to modify his password, then which
of the following is true?
a)The passwd change fails since the user does not have permission to update the /etc/passwd file
b)The passwd change is successful because the program runs as root
c)The passwd change program runs in kernel mode where write access to the /etc/passwd file is possible
d)/etc/passwd is a special file and the system by default allows all users to update it

Answer:B.
Description: Since the setuid bit is set for /usr/bin/passwd, the program runs as root. Root has access to update the
/etc/passwd file.

15)A user executes the following command successfully:
$ chmod +x file1.txt
Which of the following is true of the output of this command?
a)The command results in adding execute permission to the user who ran this command
b)The command results in adding execute permission for the owner of the file
c)The command results in an error since the file is not an executable file
d)The command results in adding execute permission for all users

Answer:D.
Description:This command can be run only by the owner of the file( or root), and it adds execute permission for all

16)The ls al output on directory /home/user1/temp looks as follows:
$ cd /home/user1/temp
$ ls -al
-rw-rw-r-- 1 user1 usrgrp 17008 May 25 02:30 .
-rw-rw-r-- 1 user1 usrgrp 17008 May 25 02:30 ..
-rrr-- 1 user1 usrgrp 17008 May 25 02:30 file1
$
If user1 executes the command rm file1, then which of the following is true?
a)The file is removed successfully ( and silently )
b)The rm command prompts for a confirmation, the command is successful upon confirmation
c)The rm command prompts for a confirmation, however the operation fails because of insufficient permissions
d)The rm command fails because of insufficient permissions

Answer:B.
Description: For deleting a file, directory write permission is sufficient, irrespective of file write permissions. The system
prompts for user confirmation if there is no file write permission

17)A user creates a link to a file file1 using the following command ln file1 file2.Which of the following is true of a ls ali
output on this directory? The directory does not contain any other files or directories.
a)file1 and file2 have the same inode numbers
b)The number of links for file1 is displayed as 1
c)The number of links for the directory (.) is displayed as 3
d)a & c

Answer:A. Files that are hardlinked have the same inode number.The number of links field is 2 for both file1 and
file2.The number of links displayed for the directory is not incremented because of the links created in files in the
directory.

18)A user does a chmod operation on a file. Which of the following is true?
a)The last accessed time of file is updated
b)The last written time of file is updated
c)The inode access time of file is updated
d)a & c
Answer:C.
Description: The file contents are not accessed or updated, hence file access/write times are not updated. The
permissions info is stored in the inode, hence the inode time is updated.

19)Look at the following code segment.
#include <stdio.h>
int numEntr = 5;
char c;
main()
{
int i = 0;
char *data;
i = GetEntr();
data = malloc ( sizeof(char) * i ));
.
.
}
int GetEntr ()
{
.
..
}
Which of the following is true?
a)Variable numEntr is stored in the heap segment
b)Variable c, being uninitialized, is part of bss segment
c)Variable i is initialized and hence part of data segment
d)a & b

Answer:B.
Description: Initialized global data is stored as part of data segment;Local variables are stored on stack

20)The signal sent to a process when the Ctrl-C key is pressed is
a)KILL
b)TSTP
c)TERM
d)INT

Answer:D.

Sample Paper-2

1)The kill -9 <PID> command sends which of the following signals to the process?
a)INT
b)TERM
c)KILL
d)STOP

Answer: C.

2)If the STAT column of the output of the ps command shows that the process state of a given process is S, then which
of the following is not true:
a)The process has been stopped or suspended from execution
b)The process is waiting for a resource
c)The kernel scheduler has pre-empted the process from execution because it has finished its allotted time slice
d)a & b

Answer: B.
Description: The process state of a suspended process is T;Process waiting for a resource moves to sleep state S;process
pre-empted from kernel because it has run its time slice waits in the run queue, state is R

3)When a child process exits before the parent process exits, which of the following is true:
a)the child process becomes defunct
b)the process state for the parent process is shown as Z
c)if the parent process does not handle SIGCHLD, the child process becomes a zombie
d)none of the above

Answer: A.

4)A user does the following from the command line::
$ a.out &
[1] 8112
$ sh
$ a.out &
[1] 8216
$ ps
PID TTY TIME CMD
8001 tty1 00:00:00 csh
8112 tty1 00:00:00 a.out
8215 tty1 00:00:00 sh
8216 tty1 00:00:00 a.out
If the user executes the command kill -9 8215, then which of the following is true?

a)The a.out instance ( PID = 8216 ) is also terminated
b)a.out(PID=8216) becomes a defunct process
c)a.out(PID=8112) becomes a zombie, with parent as 8001
d)a.out(PID=8216) has parent process as 1

Answer: D.
sh ( PID=8215) is the parent of a.out (PID=8216). Hence when sh is killed, init(PID=1) becomes parent of a.out
(PID=8216)

5)which of these is NOT a valid variable in bash
a)__ (double underscore)
b)_1var (underscore 1 var )
c)_var_ (underscore var underscore)
d)some-var (some hyphen var)

Answer:D.
Description: Hyphen's cant be used in variable name. It is encouraged to use meaningful variables instead of __
etc,though. well, hyphen means subtract in appropriate context.

6)Assuming bash shell, what is the output of the following command:
echo hello $0
a)hello echo
b)hello hello
c)hello bash
d)hello

Answer:C.
Description:"hello bash". The command is internally run in a forked bash & that bash itself is the zeroth argument.
Note, echo is just builtin command to shell Note.

7)Assuming bash shell, what is the oputput of team=Unix
echo 1.$team 2."$team" 3.'$team' 4.\$team
a)1.Unix 2.Unix 3.Unix 4.Unix
b)1.Unix 2.Unix 3.$team 4.$team
c)1.Unix 2.Unix 3.Unix 4.$team
d)1.Unix 2.$team 3.$team 4.$team Answer: B.

8)Assuming bash shell, what is the return value ($?) after running this script :
team=Unix
[ $teamFCG = UnixFCG ] && exit 2
[ ${team}FCG = UnixFCG ] && exit 3
a)0
b)1
c)2
d)3

Answer: D.
Description: $teamFCG does not evaluate since variable $teamFCG doesnt exits. since the first expression was FALSE, it
does not execute the exit 2 (after &&). ${team}FCG evaluates to UnixFCG, hence the script exits with 3

9)which of these is/are the correct method for writing "foo" in /tmp/bar file?
1. echo foo > /tmp/bar
2. echo foo >> /tmp/bar
3. echo foo | /tmp/var
4. /tmp/bar < echo foo


a)1 & 2.
b)all four amount to the same
c)1 and 3
d)3 and 4

Answer: A.
Description: echo foo > /tmp/bar or echo foo >> /tmp/bar are correct

10)To have the errors from the output of a command displayed, which is the correct syntax?
a)command 3> &2
b)command 2> &1
c)command 2> 1&
d)command 2> /dev/null

Answer: B.