Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Linux MCQ Set 1

1. When the return value of any function is not specified within the function, what function returns?
a) nothing
b) exit status of the last command executed
c) 0
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

2. Parameters can be passed to a function
a) by using the parameter variables $1, $2, $3…….
b) by using the environment variables
c) by using the parameter & environment variables
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

3. Which of the following command provides the list of the functions defined in the login session?
a) declare -f
b) declare -F
c) both declare -f and -F
d) none of the mentioned

View Answer

Answer: c [Reason:]’declare -F’ provides just the name of the functions and ‘declare -f’ provides their definitions also.

4. The keyword ‘local’ is used
a) to define a variable within a function for its local scope
b) to redefine any global variable
c) this is not a valid keyword
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

5. Functions improves the shell’s programmability significantly, because
a) when we invoke a function, it is already in the shell’s memory, therefore a function runs faster than seperate scripts
b) function will not provides a piece of code for repetative tasks
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

6. What is the output of this program?

  1.    #!/bin/sh	
  2.    var="Aidlo"
  3.    san_function() {
  4.        var="Linux"
  5.        echo $var
  6.    }
  7.    san_function
  8.    exit 0

a) Aidlo
b) Linux
c) Command not found
d) None of the mentioned

View Answer

Answer: b [Reason:] If local variable name is same as the global variable, it overlays the variable, but only within the function. Output: :/home/aidlo# ./test.sh Linux :/home/aidlo#

7. What is the output of this program?

  1.    #!/bin/sh
  2.    san_function() {
  3.        echo "Welcome to the Aidlo"
  4.        printf "World of Linuxn"
  5.    }
  6.    unset -f san_function
  7.    san_function
  8.    exit 0

a) Welcome to the Aidlo
b) World of Linux
c) both Welcome to the Aidlo and World of Linux
d) nothing will print

View Answer

Answer: d [Reason:] Function definition was deleted before calling the function. command ‘unset -f function_name’ deletes the function definition. Output: :/home/aidlo# ./test.sh ./test.sh: 6: san_function: not found :/home/aidlo#

8. What is the output of this program?

  1.    #!/bin/bash
  2.    function san_function1 {
  3.        echo "This is first function"	
  4.    }
  5.    san_function2() {
  6.        echo "This is second function"
  7.    }
  8.    san_function1
  9.    san_function2
  10.    exit 0

a) This is the first function
b) This is the second function
c) This is the first function
This is the second function
d) program will generate error because first function definition is not correct

View Answer

Answer: c [Reason:] In bash shell, functions can be defined in both the ways, used in the script. Output: :/home/aidlo# ./test.sh This is first function This is second function :/home/aidlo#

9. What is the output of this program?

  1.    #!/bin/sh
  2.    echo "Just call the function"
  3.    san_function
  4.    san_function() {
  5.       echo "This is a function"
  6.    }
  7.    exit 0

a) only first string will print without any error
b) only second string will print without any error
c) both strings will print
d) none of the mentioned

View Answer

Answer: d [Reason:] Function must be defined prior to call. Hence only first string will print and program will generate an error also. Output: :/home/aidlo# ./test.sh Just call the function ./test.sh: 3: san_function: not found :/home/aidlo#

10. What is the output of this program?

  1.    #!/bin/sh
  2.    san_function1() {
  3.        a=5
  4.        echo "This is the first function"
  5.        san_function2
  6.    }
  7.    san_function2() {
  8.        echo "This is the second function" 
  9.        san_function3
  10.    }
  11.    san_function3() {
  12.        echo "This is the third function"
  13.    }
  14.    san_function1
  15.    exit 0

a) This is the first function
This is the second function
This is the third function
b) This is the first function
This is the third function
This is the second function
c) This is the second function
This is the first function
This is the third function
d) This is the third function
This is the first function
This is the second function

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh This is the first function This is the second function This is the third function :/home/aidlo#

Linux MCQ Set 2

1. In the shell, by default, all variables are considered and stored as
a) string
b) integer
c) character
d) float

View Answer

Answer: a [Reason:] None.

2. Which command reads user input from the terminal and assign this value to a variable name?
a) read
b) get
c) declare
d) set

View Answer

Answer: a [Reason:] None.

3. Which one of the following statement is true about variables in shell?
a) variables do not require declaration before assigning value to them
b) variables are case sensitive
c) to extract the contents of a variable, we have to provide the variable a preceding $
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

4. Which one of the following is not a valid shell variable?
a) _san
b) san_2
c) _san_2
d) 2_san

View Answer

Answer: d [Reason:] The shell variable can contain only letters(a to z or A to Z), numbers(0 to 9), or a underscore character(_) and a variable can not start with a number.

5. To redefine a variable, it can be removed from the list of variables by using the command
a) unset
b) delete
c) remove
d) clear

View Answer

Answer: a [Reason:] None.

6. What is the output of this program?

  1.    #!/bin/bash
  2.    san_var="Aidlo"
  3.    echo "$san_var"
  4.    echo '$san_var'
  5.    echo '"$san_var"'
  6.    echo "'$san_var'"
  7.    echo $san_var
  8.    exit 0

a) Aidlo
$san_var
“$san_var”
‘Aidlo’
$san_var
b) Aidlo
Aidlo
“Aidlo”
‘Aidlo’
Aidlo
c) program will generate an error message
d) program will print nothing

View Answer

Answer: a [Reason:] Using double quotes does not affect the substitution of the variable, while single quotes and backslash do. Output: :/home/aidlo# ./test.sh Aidlo $san_var “$san_var” ‘Aidlo’ $san_var :/home/aidlo#

7. What is the output of this program?

  1.    #!/bin/bash
  2.    var1=10
  3.    $var1=20
  4.    echo $var1
  5.    exit 0

a) program will print 10
b) program will generate a warning message
c) program will print 20
d) program will print 10 & 20

View Answer

Answer: d [Reason:] The doller sign ($) is used to access a variable’s value, not to define it. Output: :/home/aidlo# ./test.sh ./test.sh: line 3: 10=20: command not found 10 :/home/aidlo#

8. What is the output of this program?

  1.    #!/bin/bash
  2.    var[1]=san_1
  3.    var[2]=san_2
  4.    var[3]=san_3
  5.    echo ${var[*]}
  6.    exit 0

a) san_1
b) san_2
c) san_3
d) san_1 san_2 san_3

View Answer

Answer: d [Reason:] All items of an array can be accessed by using ${[*]} or ${[@]}. Output: :/home/aidlo# ./test.sh san_1 san_2 san_3 :/home/aidlo#

9. What is the output of this program?

  1.    #!/bin/bash
  2.    san_var=hello
  3.    readonly san_var
  4.    san_var=hi
  5.    echo $san_var
  6.    exit 0

a) hello
b) hi
c) nothing will print
d) none of the mentioned

View Answer

Answer: a [Reason:] After the execution of the ‘readonly’ command, shell will not provide the permission to overwrite the value stored in variable ‘san_var’. Output: :/home/aidlo# ./test.sh ./test.sh: line 4: san_var: readonly variable hello :/home/aidlo#

10. What is the output of this program?

  1.     #!/bin/bash
  2.     san_var=10
  3.     echo "the value of "san_var" is $san_var"  
  4.     exit 0

a) the value of “san_var” is 10
b) the value of is 10
c) the value of san_var is $san_var
d) the value of “san_var” is $san_var

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh the value of “san_var” is 10 :/home/aidlo#

Linux MCQ Set 3

1. Sysfs was originally called
a) device driver filesystem
b) kernel interface filesystem
c) kernel filesystem
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

2. What is sysfs?
a) it is a virtual filesystem
b) users use it to get the information about the running kernel
c) it is used for exporting kernel objects.
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

3. Sysfs can be considered as the reflection of the
a) kernel’s device model
b) user’s device model
c) network’s device model
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

4. The files of sysfs contains the information about
a) devices and drivers
b) memory mapping
c) ports
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

5. Which one of the following is not true?
a) any file of the sysfs can not be edited
b) some files of the sysfs are writable for configuration of devices
c) any file of the sysfs may not be edited
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

6. In linux sysfs is always mounted at
a) /sys
b) /proc/sys
c) /proc/mounts
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

7. Libsysfs is a
a) user space library
b) kernel space library
c) not a library
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

8. Sysfs represents the
a) kernel objects
b) libraries
c) api
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

9. Sysfs does not contains
a) regular files
b) symbolic links
c) directories
d) none of the mentioned

View Answer

Answer: d [Reason:] None.

10. The directories in the /sys directory represents
a) the device files
b) major subsystems that are registered with sysfs
c) details of buses only
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 4

1. The directories of /sys directory
a) are created at system startup when the subsystems register themselves with kobject core
b) are created when any device is connects with the system
c) are created at the time of kernel compilation
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

2. The directory /sys/block contains
a) sub-directories for each block device
b) symbolic link for each block device only
c) device file for each block device only
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

3. In sysfs, each represented bus type has two directories named as
a) attributes and kobjects
b) devices and drivers
c) devices and kobjects
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

4. A device class describes the ____ type of device.
a) physical
b) stuctural
c) functional
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

5. Which one of the following directory contains every physical device that has been discovered by the bus types registered with the kernel?
a) /sys/devices
b) /sys/bus/devices
c) /devices
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

6. Which type of devices are peripheral devices?
a) platform devices
b) system devices
c) both system and platform devices
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

7. Which one of the following is not a system device?
a) CPU
b) APIC
c) Timer
d) None of the mentioned

View Answer

Answer: d [Reason:] None.

8. Which one of the following is not a platform specific code?
a) x86 BIOS
b) EFI on ia64
c) both x86 BIOS and EFI on ia64
d) none of the mentioned

View Answer

Answer: d [Reason:] None.

9. In device driver model bus_type object contains the
a) name of the bus type
b) set of kobjects of the drivers
c) set of kobjects of the devices
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

10. The file fs/sysfs/sysfs.h contains the
a) internal header files for sysfs
b) function definitions will not shared locally among the sysfs source
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

Linux MCQ Set 5

1. Sysfs is initialised in ______ file via sysfs_init function.
a) fs/sysfs/mount.c
b) sysfs/mount.c
c) fs/mount.c
c) none of the mentioned

View Answer

Answer: a [Reason:] None.

2. Kernel objects are exported as _____ via sysfs.
a) regular files
b) symbolic links
c) directories
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

3. Sysfs internally stores the pointer to the ____ that implements the directory in the file system.
a) kobjects
b) kstructures
c) kinodes
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

4. Attributes can be exported for objects in the form of _______ in the file system.
a) regular files
b) directories
c) symbolic links
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

5. In sysfs every subsystem has
a) a shared attribute structure
b) its own attribute structure
c) a shared & own attribute structure
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

6. sysfs is based on
a) rootfs
b) ramfs
c) initramfs
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

7. Which one of the following is a notification to user space from the kernel that something has changed in the system’s configuration?
a) hotplug event
b) module event
c) attach event
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

8. In the device driver model the device_driver object contains the
a) name of the device driver
b) embedded kobjects
c) method for probing a device
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

9. A ____ is a higher level view of a device that abstracts out low level implementation details/
a) inode
b) class
b) major number
d) minor number

View Answer

Answer: b [Reason:] None.

10. When a device is removed from the system
a) files and directories of that device in the sysfs are removed automatically
b) all the files of sysfs are preserved until the system turn offs
c) it does not create any change in the sysfs
d) none of the mentioned

View Answer

Answer: a [Reason:] None.