R4RIN
Articles
Java 8
MCQS
Unix/Lunux MCQ Quiz Hub
Linux Mcqs Questions Set 4
Choose a topic to test your knowledge and improve your Unix/Lunux skills
1. Which of the following identifiers associated with a process decide its privilege level
uid
suid
euid
gid
2. The /etc/passwd file doesn’t contain
userid
home directory for a user
login shell name
none of the mentioned
3. User id 0 is
An innvalid user id
The id of the root user
The id of a user when the users account is deleted
None of the mentioned
4. The login shell is
The shell program that runs when the user logs in
The shell program that authenticates the user while logging in
Common shell for all the users that belong to the same group
None of the mentioned
5. Which of the following command can be used to change the user password?
user cant change the password
passwd
passd
pwd
6. What does the following command do ? who | wc –l
List the number of users logged in
List the users
List the number of users in the system
Display the content of who command
7. By default, a Linux user falls under which group?
staff
others
same as userid (UPG)
system
8. Which of the following files need to be referred for users secondary group?
/etc/passwd
/etc/shadow
/etc/group
/etc/profile
9. How do you print the lines between 5 and 10, both inclusive
cat filename | head | tail -6
cat filename | head | tail -5
cat filename | tail +5 | head
cat filename | tail -5 | head -10
10. Create a new file new.txt that is a concatenation of file1.txt and file2.txt
cp file.txt file2.txt new.txt
cat file1.txt file2.txt > new.txt
mv file[12].txt new.txt
ls file1.txt file2.txt | new.txt
11. which of these is NOT a valid variable in bash
__ (double underscore)
_1var (underscore 1 var )
_var_ (underscore var underscore)
some-var (some hyphen var)
12. The expression expr -9 % 2 evaluates to:
0
1
-1
2
13. The statement z = expr 5 / 2 would store which of the following values in z?
0
1
2
2.5
14. To feed standard output of one command to standard input of another in a single shell session
IO redirection can be used
Named pipes can be used
The pipe operator provided by the shell can be used
It can not be done
15. Which of the following commands allows definition and assignment of environment variables under bash
env
export
environ
setenviron
16. While executing a command, the shell
Executes it in the same process (as shell)
Creates a child shell to execute it
Loads a special program to take care of the execution
None of the mentioned
17. Which variable contains current shell process id
$*
$?
$$
$!
18. Which command is used to debug a shell script program
set
set -x
debug
db
19. For every successful login, which script will be executed?
/etc/inittab
/etc/profile
/etc/login
/etc/init
20. Hidden files are
Those whose ‘read’ bit is set to ‘h’
Permitted for (can be accessed) only superusers
iles that begin with a ‘.’
Files that cannot be opened by ordinary user for writing
21. Shell is ?
Command Interpreter
Interface between Kernel and Hardware
Interface between user and applications
Command Compiler
22. If a file with execute permissions set, but with unknown file format is executed
The file is passed to /bin/sh
The system returns an error
The current shell will try to execute it
None of the mentioned
23. Which of the following is true?
Shell is a process and can be started by superuser only
Shell is a built-in Kernel functionality
Shell is a wrapper for all the commands and utilities
None of the mentioned
24. Which is true with regards to the shell prompt
It can be accidentally erased with backspace
The prompt cannot be modified
The prompt can be customized (modified)
None of the mentioned
25. What is a shell in UNIX?
a program through which users can issue commands to UNIX
a window management system
the login screen
the thing that rides on the back of a turtle in UNIX
26. Which of the following represents an absolute path?
../home/file.txt
bin/cat
cs2204/
/usr/bin/cat
27. BASH shell stands for?
Bourne-again Shell
Basic Access Shell
Basic to Advanced Shell
Big & Advanced Shell
28. Which of the following files will not be displayed by the command cat re* ?
reminder
receipt
Receipt
recipe-cake
29. The redirection 2> abc implies
Write file 2 to file abc
Write standard output to abc
Write standard error to abc
None of the mentioned
30. cmd 2>&1 > abc will
Write file2 to file1
Write standard output and standard error to abc
Write standard error to abc
Write standard output to abc & standard error to monitor
31. Which of these is the correct method for appending “foo” in /tmp/bar file?
echo foo > /tmp/bar
echo foo >> /tmp/bar
echo foo | /tmp/var
/tmp/bar < echo foo
32. Syntax to suppress the display of command error to monitor?
command > &2
command 2> &1
command 2> &2
command 2> /dev/null
33. cat < file1 >> file2 | file3
file1 content will be appended to file2 and finally stored in file3
file1 content will be appended to file2 and file3 will be ignored
file2 and file3 will have same content
syntax error
34. Executing cat /etc/password > /dev/sda as superuser will
Write data into a regular file called /dev/sda
Write data to the physical device sda
Create a temporary file /dev/sda and write data to it
None of the mentioned
35. The $ variables in a shell script context designates
The runtime of the script
Number of command line arguments
PID of the shell running the script
The exit status of the shell script
36. Which variable is used to display number of arguments specified in command line
$0
$#
$*
$?
37. Which variable contains last background job process id
$*
$?
$$
$!
38. Which command can be used to test various file attributes
if
file
test
type
39. * Specifies
one or more character
zero or more charecter
nothing
none of the mentioned
40. ? Specifies
one or more character
zero or more charecter
one character
none of the mentioned
41. Which of the following file set in the current directory are identified by the regular expression a?b*
afcc, aabb
aabb, axbc
abbb, abxy
abcd, axbb
42. What command would send the output of cmd1 to the input of cmd2?
cmd1 | cmd2
cmd1 || cmd2
cmd1 &amp;&amp; cmd2
cmd1 ; cmd2
43. What is the output of the following command for bash shell: echo linux $0
linux echo
linux linux
linux bash
linux
44. Which variable will display the list of the positional parameters?
$#
$*
$?
$$
45. Which option of grep displays the line number as well?
-v
-l
-n
-E
46. How can you search for blank line in a file?
$ grep “ “ file
$ grep “^$” file
$ grep [“ “] file
$ grep [^$] file
47. Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files match with the pattern file[ABC]?
fileA, fileB and fileABC
fileABC
fileA and fileB
fileAB, fileBC and fileABC
48. What will be printed for the command below? $ grep –c “^echo” abc
The count of lines that do not contain the pattern echo in file abc
The count of lines which begin with the pattern echo in file abc
The count of lines that ends with the pattern echo in file abc
None of the mentioned
49. Which one is used to select only one copy of the repeated lines?
uniq -u
uniq -d
uniq -c
uniq –I
50. Indicate the right option to search for BOB, Bob, BOb or BoB?
grep –i Bob files
grep ‘B[oO][bB]’ files
grep ‘[BOB]’ files
grep -v ‘Bob’ files
Submit