This is a mock Exam for the Unix programmers. It is created by Genesis InSoft Limited
(admin@genesisinsoft.com)
and may be freely distributed so long as it is unmodified. Please email us if you
have any corrections or comments.
How will you separate one command from another if you want to put several commands
on the same line?
- :
- ||
- -a
- ;
Answer to Question 1
If the following echo command is used, what would be the output
Echo This is a test of * meta character in Unix operating system
- This is a test for * meta character in Unix operating system
- The meta character * is replaced by a list of all your files
- Improper usage of meta character in echo command
- Syntax error
Answer to Question 2
Contents of file "test" are as follows
Echo ${1? "This is a test for argument"} is the only
argument
What is the output, if you execute the following file
- Bad substitution
- This is a test for argument
- Test is the only argument
- This is a test for argument is the only argument
Answer to Question 3
Which of following shell variables provides information of the command being executed
and its PID?
- $! and $0
- $0 and $$
- $$ and $!
- $$ and $-
Answer to Question 4
What is the output of the following command if file one is undefined?
sort one > one.sort 1>&2 two
- throws an error on the standard output and writes to file called two, stating
file or directory does not exist
- throws an error only on the standard output, stating file or directory does not
exist
- the standard error is redirected to the file called two, stating file or directory
does not exist
- None of the above
Answer to Question 5
What is the output of the following command assuming the variable called name is
defined as
Name=Genesis
: ${name?' is the name of our organization'}
- Syntax error
- Genesis is the name of our organization
- Nothing, because it is a do nothing command
- Wrong usage of : , $ and ? in one statement
Answer to Question 6
Which of the following shell command is used as a comment in Unix
- //
- :
- #
- Both A and B
Answer to Question 7
To find the files containing word "printf" in the system
- find / -name * -exec grep "printf"
- find / -name "*" -exec grep "printf" {} \;
- find / -name "*" -exec grep -l "printf" {} \;
- find / -name "*" -exec ls -l {} \;
Answer to Question 8
What is the significance of fork function
- Kills an existing process
- Temporarily half an existing process
- Create a new process, killing the previous process
- Create a new process
Answer to Question 9
On successful completion of fork()
- It returns a value of 0 to the child process and also returns process ID of the
child process to the parent process
- It returns a value of -1 to the parent process, with no creation of child process
- It returns a value of 0 to the parent process and also returns process ID of the
child process to the parent process
- It returns a value of -1 to the child process and also returns process ID of the
child process to the parent process
Answer to Question 10
What is the output of the following code
main()
{
printf("Line1 ");
fork();
printf("Line2 ");
}
- Line1 Line2
- Line1 Line2 Line2
- Line1
- Line2 Line1
Answer to Question 11
What is the output of the following code
main()
{
printf("Line1 ");
execl("/bin/date","date",0);
printf("Line2 ");
}
- Line1 followed by date
- Line1, date followed by Line2
- Line1 followed by Line2
- Syntax error
Answer to Question 12
The /etc/passwd file can be updated only by superusers. But a ordinary user can
update his password through /bin/passwd executable file, because
- The owner can change his password
- Temporary permission is given to update /etc/passwd
- Superuser gives permission to change his passwd
- None of the above
Answer to Question 13
Which command waits until all background processes known to the current shell have
been terminated?
- sleep
- stop
- wait
- continue
Answer to Question 14
What does wait() system call return to all parent process, when a child process
is created by fork()?
- PID of the child process
- Exit status of the child process
- Returns zero or one
- Both A and B
Answer to Question 15
Which command compares two text files?
- diff
- compare
- write
- tell
Answer to Question 16
What is the output of the following statement?
echo */*
- displays all files in all directories
- displays only the files in the current directory
- displays only the directories
- syntax error
Answer to Question 17
If you want to display message at the time of login, which of the following files
do you edit?
- /etc/passwd
- /etc/motd
- /etc/news
- /etc/msg
Answer to Question 18
Which of the following category of user can send message at the time of login?
- Only the superuser
- Only the users
- Only the groups
- Others
Answer to Question 19
What is the output of the following shell script?
t=`cat /etc/passwd | grep -s $1`
echo $t
if [ $? -eq 1 ] then
Echo " $1 is not created"
else
Echo " $1 is created"
fi
- Syntax error
- Improper usage /etc/passwd, because you cannot edit /etc/passwd (read permission
is denied)
- Searches for the name given at the command line in the /etc/passwd and on success
displays the message name is not created
- Searches for the name given at the command line in the /etc/passwd and on success
displays the message name is created
Answer to Question 20
Answers
Answer 1 - D
Back to question 1
Answer 2 - B
Back to question 2
Answer 3 - B
Back to question 3
Answer 4 - B
Back to question 4
Answer 5 - A
Back to question 5
Answer 6 - C
Back to question 6
Answer 7 - A
Back to question 7
Answer 8 - C
Back to question 8
Answer 9 - D
Back to question 9
Answer 10 - A
Back to question 10
Answer 11 - B
Back to question 11
Answer 12 - A
Back to question 12
Answer 13 - B
Back to question 13
Answer 14 - C
Back to question 14
Answer 15 - D
Back to question 15
Answer 16 - A
Back to question 16
Answer 17 - A
Back to question 17
Answer 18 - B
Back to question 18
Answer 19 - A
Back to question 19
Answer 20 - D
Back to question 20