0% found this document useful (0 votes)
878 views8 pages

Answers - OS LAB QUIZ

The document contains a 30 question quiz on Linux/Unix commands and concepts. The questions cover topics like the who, pwd, uname, vi, test, expr and rmdir commands, file permissions, variables, condition tests and more. The correct answers are provided as multiple choice options a, b, c or d for each question.

Uploaded by

ad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
878 views8 pages

Answers - OS LAB QUIZ

The document contains a 30 question quiz on Linux/Unix commands and concepts. The questions cover topics like the who, pwd, uname, vi, test, expr and rmdir commands, file permissions, variables, condition tests and more. The correct answers are provided as multiple choice options a, b, c or d for each question.

Uploaded by

ad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

UCS303 OS LAB QUIZ

1. What does the following command do?


who | wc –l

a) List the users


b) Display the content of who command
c) List the number of user logged in
d) List the number of users in the system

2. What would be the current working directory at the end of the following command sequence?
$ pwd
/home/user1/proj
$ cd src
$ cd generic
$ cd .
$ pwd

a) /home/user1/proj
b) /home/user1/proj/src
c) /home/user1
d) /home/user1/proj/src/generic

3. Which command is used to get the kernel version in Linux?

a) uname –r
b) uname –n
c) uname –t
d) kernel

4.For saving a file in vi editor, which command is used

a) :q
b) :s
c) :w
d) None of these
5. Which of the following can be used as shorthand for test?

a) ( )
b) esac
c) [ ]
d) fi

6. The statement z=`expr 5.0 / 2.0` would store which of the following values in z?

a) 1
b) 2
c) 2.5
d) Gives Error

7.Which variable is used to display number of arguments specified in command line?

a) $0
b) $#
c) $*
d) $?
8.With a umask value of 202, what is the default permission assigned to newly created regular
file in bash shell?

a) –rwxr--rwx
b) -r--rwx-r--
c) -r-xrwx-r-x
d) –r--rw-r--

9.Which of these commands will set the permissions on file textfile to read and write for the
owner, read for the group, and nothing for everyone else?

a) chmod 046 textfile


b) chmod 640 textfile
c) chmod 310 textfile
d) chmod rw r nil textfile

10.What will be output of following command?


$ echo "The process id is" $$$$

a) The process id is $$
b) The process id is $<pid>$<pid>
c) The process id is <pid><pid>
d) The process id is $$$$
11. Which variable contains last background job process id?

a) $*
b) $?
c) $$
d) $!
12. With a umask value of 202, what is the default permission assigned to newly created
directory in bash shell?

a) drwxr--rwx
b) dr--rwx-r--
c) dr-xrwx-r-x
d) dr--rw-r--
13.Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files
match with the pattern “file[ABC]”

a) fileA, fileB, fileABC


b) fileABC
c) fileA, fileB
d) fileAB, fileBC, fileABC

14.Which command is used to count the number of directories in the current directory?

a) ls -d | wc –c
b) ls –l | grep -c “^d”
c) ls –l | grep “^d”
d) All of these
15. The statement z=`expr 5 / 2` would store which of the following values in z?
a) 1
b) 2
c) 2.5
d) Gives Error

16. Which variable will display the list of the positional parameters?

a) $@
b) $*
c) $?
d) None of these

17. Which option of rmdir command will remove all directories a, b, c if path is a/b/c

a) –r
b) –o
c) –p
d) –t

18. Which command is used to count the number of directories in the current directory?
a) ls -d | wc –c
b) ls –l | grep -c “^d”
c) ls –l | grep “^d” | wc –l
d) ls –d | grep -c

19. When trying to compare two files using cmp, if the files differ; what is the output?

a) tells the first byte where they differ


b) tells the line number where they differ
c) tells the first byte and line number where they differ
d) it displays the files

20. Which of the following is a shell?

a) ksh
b) tcsh
c) csh
d) echo
e) All of these
21. Which command is used to count the number of directories in the current directory?
a) ls -d | wc –c
b) ls –l | grep -c “^d”
c) ls –l | grep “^d” | wc –n
d) ls –l | grep “^d” | wc –l

22. Suppose I am in /etc directory, after executing cd. where am I now?

a) /etc
b) /
c) /home
d) None of these
23. Execution of the command “mkdir test” at dollar prompt results into the following “mkdir: Failed to
make directory “test” ”; Permission denied.
This can happen due to which reason.

a. directory test may already exists


b. there may be an ordinary file by that name in the current directory
c. the permissions set for the current directory don’t permit the creation of files and
directories by the user
d. none of the above

24. When we enter the password, the system performs the encryption. Where, encryption generates a
string of seemingly random characters that UNIX/LINUX subsequently uses to determine the authenticity
of a password. This encryption is stored in a file named shadow in the directory titled.

a. /etc
b. /bin
c. /var
d. /lib
25.echo in Bash Linux interprets the escape sequences with which of the following options.
a. e
b. m
c. l
d. x

26. What is the output of the following program?


b=
[ -n $b ]
echo $?
[ -z $b ]
echo $?

a) 0
0
b) 1
0
c) 1
1
d) 0
1
27. How can you search for blank line in a file?

a) $ grep “ “ file
b) $ grep “^$” file
c) $ grep [“ “] file
d) $ grep [^$] file

28. What is the output of the following program?


[ -n $HOME ]
echo $?
[ -z $HOME ]
echo $?
a) 0
1
b) 1
0
c) 0
0
d) 1
1
29. What will be the output of the following commands when executed at dollar prompt serially?
$ x=50; y=100
$ test $x –eq $y ; echo $?

a. 0
b. 1
c. 2
d. none of the above

30. Suppose currently I am in directory /home/csed/labquiz/os. After executing cd ../. where am I now?

a) /home
b) /home/csed
c) /home/csed/labquiz
d) /home/csed/labquiz/os

You might also like