Google Analytics

Friday 19 August 2011

FRP UNIX PAPER 2 SAMPLE QUESTION WITH ANSWERS


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.

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java EE Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.



    Java Online Training

    ReplyDelete