You are on page 1of 114

============TARUN SETS=============

71. Linux kernel is of ________ architecture.


A: Monolithic kernel
B: Micro kernel
C: Modular kernel
D: Nano kernel

72. In x86 architecture system call number can be passed through ____ register.
A: ESP
B: EIP
C: EAX
D: EPB

73. In Linux, compressed kernel image is stored in ____ directory with _____.
A: /boot, vmlinux
B: /boot, vmlinuz
C: /usr/src, vmlinux
D: /lib/modules, vmlinuz

74. ________is an example of CPU instruction to switch from user mode to kernel mode while
invoking system call in
x86 architecture.
A: int 0x80
B: SWI
C: SVC
D: All of the above

75. In Linux process descriptor is stored in ___ header file in _____ structure
A: sched.h, task_descriptor
B: task.h, task_struct
C: sched.h, task_struct
D: task.h, task_descriptor

76. ______command is used to display kernel log buffer.


A: dmesg
B: uname -r
C: cat /proc/sysinfo
D: None of the above

77. _____are real time scheduling algorithms in Linux.


A: SCHED_FIFO, SCHED_OTHER
B: SCHED_RR, SCHED_OTHER ·
C: SCHED_FIFO, SCHED _ RR
D: None of the above
78. ______macro represents address of process descriptor of calling process
A: pcurrent
B: current
C: task_ current
D: current_ task

79. ______API is used to identify errors


A: strerror
B: serror
C: perror
D: None of the above

80. API is used to copy data from user space to kernel space
A: copy_from_user
B: copy_to_user
C: strcpy
D: sprint

81. _____ target of kernel Makefile copies dynamic modules into /lib/modules
A: install
B: modules
C: modules_install
D: install_ modules

82. ________is the versatile command to load modules with dependency resolution.
A: insmod
B: rmmod
C: modprobe
D: lsmod

83. ____ variable holds list of dynamic modules configured in kernel


A: obj-y
B: obj-d
C: obj-m
D: obj-s

84. structure holds attributes of file by VFS


A: struct inode
B: struct file
C: struct dentry
D: struct path

85. is an example of pseudo file system


A: fat32
B: sysfs
C: ext4
D: None of the above

86. ______command is used to map external file system with an empty dir.
A: mmap
B: mkfs
C: mount
D: fdisk

87. ________API is used to inspect stack trace at any check point


A: dump_stack
B: trace_stack
C: dump _functions
D: trace_functions

88. ______is the default log level used by printk


A: KERN_DEBUG
B: KERN_ALERT
C: KERN_CRIT
D: KERN_WARNING

89. ___ system call is used to change read/write offset with in an open file
A: Istat
B: lseek
C: stat
D: seek

91. ____ proc file displays list of all registered character, block devices along with their major
numbers
A: /proc/modules
B: /proc/modlist
C: /proc/devices
D: /proc/devlist

Date: 16-01-2014
Module Name: Embedded Systems Programming

1. For a device driver to access the I/O memory address it must be mapped to virtual address. This can
be done by using the function
A. ioremap();
B. io_map();
C. request_mem_region();
D. both (A) and (B)

2. The major number


A. used by kernel to determine which device is being referred to
B. can be used as an index into a local array of devices
C. identifies the driver associated with the device
D. all of the above

3. Device that can be accessed as a stream of bytes


A. character devices
B. block devices
C. network devices
D. none of these

4. mknod is used for creating


A. character device file
B. block device file
C. FIFO
D. all of the above

5. Which mechanism is not used for delayed code execution?


A. timers
B. ioctl
C. workqueues
D. tasklets

6. In a kernel Makefile, the tag ’obj-m’ compiles the source code as


A. a dynamically loaded module
B. a system call
C. a statically built in module
D. the kernel core component

7. To which directory printk message goes


A. /proc/messages
B. /var/log/messages
C. /proc/kall
D. /var/log/message

8. Using which utility in Linux, will load the kernel module


A. insmod
B. rmmod
C. dmesg
D. load

9. Which of the following macros is used to pass an array as a parameter to the kernel module?
A. module_param_array (name, type, num, perm)
B. module_param(name, type, num, perm);
C. module_param_char[size](name, type, perm);
D. module_param[size](name, type, num, perm);

10. Which of the following is true for the 'dev_t' data type?
A. it is used to hold the driver name
B. it is used to hold the major-minor number
C. it holds the major-minor numbers and the driver name
D. none of the above

11. All I/O memory allocations are listed in


A. /proc/iomem
B. /proc/ioports
C. /proc/meminfo
D. /proc/mem

12. Debugging kernel code can be done by


A. monitoring
B. printk message
C. gdb
D. all of the above

13. Module stacking mean


A. a module will be using symbols exported by other module
B. a module loaded at run time
C. modules to which parameters are passed at insertion time

D. none of the above

14. The field in the file operation structure which is not an operation at all
A. ssize_t read();
B. loff_t *llseek();
C. struct module *owner;
D. int *ioctl();

15. The function which is used to allocate and initialize a character device
A. int register_chrdev_region();
B. void chdev_init();
C. int register_chrdev_region();
D. int register_chrdev();

16. What is the preferred mechanism to dynamically find out the IRQ number of a device?
A. probing
B. seeking
C. polling
D. masking

17. Which of the following should be avoided in the interrupt handlers?


A. calling wait_event/allocating memory
B. calling schedule
C. locking a semaphore
D. all of the above

18. Find the odd function out with reference to short delays inside the kernel
A. ndelay();
B. udelay();
C. mdelay();
D. pdelay();

19. A character device driver is written to access the serial port of the PC. The driver requests a
device number from the kernel by calling the function 'alloc_chrdev_region'. The kernel allocates the
Major-Minor number combination of 253,0.
Using which utility can a user space application create a device node to access the driver? Can two
device nodes be created bearing the same major-minor number combination?
A. mknod, TRUE
B. mknod, FALSE
C. mkdev, TRUE
D. mkdev, FALSE

20. What will happen if the return a negative value from the module initialization function
(init_module)?
A. kernel crashes
B. error during compilation of the module
C. error while inserting the module
D. no problems will arise

21. If a function or variable defined in one driver is to be shared with other drivers, which of the
following functions should be called?
A. module_param
B. EXPORT_SYMBOL()
C. module_param_novers

D. module_param_novers

22. If you export any symbol from your driver, if you want to see the exported symbols, which file you
need to refer ……………….
A. /proc/symbols
B. /proc/ksyms
C. /proc/kcallsyms
D. none of the above

23. In a module if its license is not explicitly specified its default license would be
A. GPL
B. GPLV2
C. Dual BSD/GPL
D. Proprietary
24. The devices that can host a filesystem
A. character device
B. block devices
C. network interfaces
D. none of the above

25. The function which is used to access the i/o memory


A. outb
B. insb
C. insb
D. ioread8

26. For allocating big chunk of memory we use


A malloc
B. lmallo
C. get_free_page
D. none of these

27. Modules run in


A. user space
B. kernel space
C. anywhere
D. all of the above

28. SMP stands for


A. simple machine process
B.Symmetric multiprocessor system
C. symmetric module system
D. none of the above

29 structure used by the kernel internally to represent files


A. mknode
B. inode
C. structdev
D. all of these

30. The function is used to copy a kernel data segment to user data segment
A. get_user
B. put_user
C. write_to_user
D. copy

31. What is kernel module?


A. each piece of code that can be added to the kernel at run time
B. file used to talk to hardware
C. main kernel image that is built as a static image
D. none of these

32. I/O Mapped Memory means


A. the I/O devices are mapped in the same Address Space thereby preventing memory
access to those regions
B. the same address may be used for both I/O as well as Memory
C. only one instruction is required to talk to the hardware
D. none of these

33. Barriers in device drivers are used to


A. tell the compiler to maintain order before and after the barrier
B. tell the compiler to maintain order only after the barrier
C. tell the compiler to ignore code around the barrier
D. tell the compiler to compiler with greatest optimzation

34. Which of the following functions is used for I/O port allocation?
A. request_region();
B. check_region();
C. register_io_region();
D. alloc_io_region();

35. Find the odd option out with reference to f_flags in the file structure
A. O_RDONLY
B. O_NONBLOCK
C. O_SYNC
D. FMODE_READ

36. There is a driver which executes in the kernel. The driver implements the open, read, write and
close functions apart from module initialization and cleanup. In the user space, there are number of
read and write applications working on the driver. Every write should be signaled by the read. In such
scenarios, where should the function 'init_completion' be called?
A. in the init_module of the driver
B. in the open function implemented by the driver
C. does not have to be called. The kernel takes care of it
D. in the read function of the driver

37. In which method of a character driver should the functions 'cdev_init' and 'cdev_add' be called?
Choose the most appropriate answer?
A. module init function and module open function respectively
B. both in module init function
C. both in open function
D. none of the above

38. The loglevel strings in printk are defined in the header file
A. <linux/module.h>
B. <linux/init.h>
C. <linux/kernel.h>
D. <linux/fs.h>

39. Block size in block devices is of


A. 1MB
B. 512 bytes
C. 256 bytes
D. 8 bits

40. PCI peripheral are defined by


A. bus number
B. device number
C. function number
D. all

----SUNBEAM----

1. Which of the following option gives hexcode of executable file in objdump tool?
1. inb(), inw(), inl()
2. outb(), outw(), outl()
3. outb_p(), inb_p()
4. All of the above
5. None of the above

2. Which of the following is not member of struct file_operation{}?


Answers
1. fopen()
2. fread()
3. remove()
4. All of the above
5. None of the above

3. The modprobe tool can not remove multiple modules together.


Answers
1. False
2. True

4. Which of the following low level functions are not used to access the device?
Answers
1. inb(), inw(), inl()
2. outb(), outw(), outl()
3. outb_p(), inb_p()
4. All of the above
5. None of the above

5. While configuring the kernel, which option is set to build as module?


Answers
1. m
2. M
3. y
4. n

6. The following command is


make -j8 -j4 bzImage
Answers
1. Valid
2. Invalid

7. Kernel log messages are stored in _________.


Answers
1. /var/messeges
2. /var/log/msg
3. /var/log/messages--A
4. None of the above

8. In dev_t major number is of _____ bits.


Answers
1. 20
2. 12--A
3. 19
4. None of the above

9. The kernel buffer size of pipe is


Answers
1. 4k to 64k--A
2. 10k to 50k
3. 8k to 32k
4. none of the above

10. inb(), inw(), inl() are used to access devices.


Answers
1. True--A
2. False
----------------------------------------------------------------------------------------------------------------
1. which one of the following is not system V IPC?
Answers
1. Shared Memory
2. Message Queues
3. FIFO--A
4. Semaphores

2. Which of the following verifies that user space buffer can be read/write in kernel space code?
Answers
1. copy_from_user()
2. copy_to_user()
3. access_ok()--A
4. None of these

3. what is not true for private_data?


Answers
1. private_data is void pointer in struct inode.
2. private_data is void pointer in struct file.--A
3. private_data keeps driver specific information.
4. private_data must be initialized in open() operation to make driver functioning.

4. How can you view the used IRQs on a system?


Answers
1. cat /etc/interrupts
2. cat /proc/irq
3. cat /proc/interrupts--A
4. echo 1 > /proc/interrupts

5. The first argument of printk() indicates


Answers
1. message suffixed by priority string
2. message prefixed by priority string--A
3. type of kernel message logger
4. None of the above

6. why we cann't use C standard library function in kernel module?


Answers
1. kernel modules are dynamically linked during insmod.--A
2. kernel modules are statically linked during insmod.
3. kernel modules are dynamically linked during module builds.
4. kernel modules are statically linked during module builds.
7. what is use of container_of() macro?
Answers
1. Used to access struct member from given address of struct variable.
2. Used to access struct variable from given address of structure member.--A
3. Used to access container process in which given thread is running.
4. None of the above

8. An interrupt handler can be registered by using the function


Answers
1. request _irq--A
2. request_region
3. request_mem_region
4. request_irq_region

9. All the details about the module like author, version etc can be viewed by using utility
Answers
1. lsmod
2. modprobe
3. dmesg
4. modinfo--A

10. which function is used to allocated memory for buffer of the USB.
Answers
1. usb_alloc_buffer()
2. usb_buffer_alloc()--A
3. usb_alloc()
4. usb_alloc_urb()

11. which of the following is externel tool for debugging?


Answers
1. Probe
2. LTI
3. Kgdb--A
4. None of the above

12. which of the following registers cdev with kernel?


1. cdev_init()
2. cdev_add()--A
3. cdev_del()
4. None of the above

13. which macro is used to add kernel module functions to kernel symbol table?select one:
Answers
1. MODULE_EXPORT()
2. EXPORT_SYMBOL()--A
3. EXPORT_KERNEL()
4. EXPORT_FUNCTION()

14. "kernel is tained" message will be produced when the module is inserted without____________
Answers
1. MODULE_LICENSE--A
2. MODULE_AUTHOR
3. MODULE_VERSION
4. MODULE_DESCRIPTION

15. In the device driver model the device_driver object contains the
Answers
1. name of the device driver
2. embedded kobjects
3. method for probing a device
4. all of the mentioned--A

16. Choose the incorrect statement


Answers
1. ioctl is a common interface used for device control
2. The implementation of ioctl is mostly done using a switch statement based on the command number
3. The macro _IOR(type,nr,datatype) can be used to setup a ioctl command number with no arguments-
-A
4. The ioctl funtion has the format long ioctl(structure file *flip, unsigned int cmd, unsigned long arg)

17. All I/O memory allocations are listed in


Answers
1. /proc/iomem--A
2. /proc/ioports
3. /proc/meminfo
4. /proc/mem

18. which of the following function is use to wake up a task from wait queue in case of spinlock?
Answers
1. wake_up(&wq)
2. wake_up_interruptible--A
3. wake_spinlock(&wq)
4. none of the above

19. ___________ is used to add a character device to a system


Answers
1. cdevAdd()
2. cdevc_add()
3. cdev_add()--A
4. add_cdev()

20. The function which is used to allocate and initialize a character device
Answers
1. int register_chrdev_region();--A
2. void chdev_init();
3. int unregister_chrdev_region();
4. int register_chrdev();

21. Which of the following should be avoided in the interrupt handlers?


Answers
1. calling wait_event/allocating memory
2. calling scheduler
3. locking a semaphore
4. all of the above--A

22. EXPORT_SYMBOL is used for


Answers
1. export symbols to other modules--A
2. export symbols and hide it from other modules
3. get symbols from other modules

23. To send the external command to a device _______ operation is used.


Answers
1. send file
2. ioctl--A
3. send page
4. none of the above

24. In a module if its license is not explicitly specified its default license would be
Answers
1. GPL--A
2. GPLV2
3. Dual BSD/GPL
4. Proprietary

25. The devices that can host a filesystem


Answers
1. character device
2. block devices--A
3. network interfaces
4. none of the above

26. which of the following bottom half mechanism can sleep or can be scheduled?
Answers
1. softirq
2. tasklet
3. work queue--A
4. None of the above

27. Which of the following functions is used for I/O port allocation?
Answers
1. request_region();--A
2. check_region();
3. register_io_region();
4. alloc_io_region();

28. In which method of a character driver should the functions 'cdev_init' and 'cdev_add' be called?
Choose the most appropriate answer?
Answers
1. module init function and module open function respectively
2. both in module init function--A
3. both in open function
4. none of the above

29. The loglevel strings in printk are defined in the header file
Answers
1. <linux/module.h>
2. <linux/init.h>
3. <linux/kernel.h>--A
4. <linux/fs.h>

30. Select correct option


i. cdev_add() create a device node under /dev
ii. cdev_init() associates major and minor numbers with device file
iii. cdev_add() make device entry in sysfs
Answers
1. only i is correct dev_init() - initialize a cdev structure *cdev: the
2. i and ii is correct
3. i and iii is correct--A
structure to initialize*fops: the file_operations for
4. All are correct this device* Initializes cdev

31. kfifo_free() is used to ____________.


Answers
1. Release statically allocated fifo
2. Release dynamically allocated fifo--A
3. Both of the above
4. None of the above

32. If we use a driver for various device files, then


Answers
1. Minor number will be different for every device file--A
2. Minor number will be same for every device file
3. Minor number can't be allocated for any device file
4. None of the above

33. The device number which is of 32 bit and consist of _________ bits for major and _______ bits for
minor.
Answers
1. 21, 11
2. 11, 21
3. 20, 12
4. 12, 20--A

34. ________ structure used by the kernel internally to represent files


Answers
1. mknode
2. inode--A
3. structdev
4. None of the above

35. In Linux device driver which keyword used to allocate memory


Answers
1. malloc
2. dmalloc
3. lmalloc
4. kmalloc--A

36. Inb&outb are used to read and write


Answers
1. 8bytes
2. 1 bit--A
3. a block
4. 8 bits

37. what does mean unsigned long probe_irq_on(void):


Answers
1. This function returns a bit mask of unasigned interrupts--A
2. This function has requested an interrupts
3. This function has used by driver calls
4. This function returns a negative value

38. In dev_t major number is of _____ bits.


Answers
1. 20
2. 12--A
3. 19
4. None of the above

39. inb(), inw(), inl() are used to access devices.


Answers
1. True--A
2. False

40. Which of the following is not member of struct file_operation{}?


Answers
1. fopen()
2. fread()
3. remove()
4. All of the above--A
5. None of the above

Linux Filesystem Hierarchy Questions & Answers

1. Operating system kernel must be located in


a) /
b) /boot
c) either in / or in /boot
d) none of the mentioned
2. Which one of the following is a mount point for a temporarily mounted filesystem?
a) /mnt directory
b) /media directory
c) /dev directory
d) none of the mentioned

3. What is /root?
a) root filesystem
b) home directory of the root user
c) the directory which contains all the directories of the filesystem
d) none of the mentioned

4. System binaries are stored in


a) /sbin directory
b) /usr/sbin directory
c) /usr/local/sbin directory
d) all of the mentioned

5. The /dev directory contains the


a) device drivers
b) device files
c) kernel modules of device drivers
d) none of the mentioned

6. The contents of root filesystem is responsible to


a) boot the system
b) recover the system
c) repair the system
d) all of the mentioned

7. Static files of the bootloader are installed in


a) /boot directory
b) /root directory
c) /bin directory
d) /sbin directory

8. Linux filesystem contains mainly


a) ordinary files
b) device files
c) directory files
d) all of the mentioned

9. In linux filesystem, the passwords of different users are stored in


a) /etc/passwd file
b) /bin/passwd file
c) /etc/shadow file
d) /bin/shadow file
Explanation: Passwords are visible in encrypted format in the file.
10. Superuser can change the _______ permissions of any file.
a) owner
b) group
c) other
d) all of the mentioned

11. When we install a new package in linux system, then


a) all the files of the packages are installed in a single directory
b) different files are installed at different locations of the file system
c) package works just after extraction, installation is not required
d) none of the mentioned

12. Host specific configuration files are installed in


a) /etc directory
b) /lib directory
c) /root directory
d) /bin directory

13. The directory /media is the


a) mount point for removable media
b) mount point for filesystem
c) mount point for removable media & filesystem
d) none of the mentioned

14. What is /bin/sh ?


a) bourne shell
b) hard or symbolic link to the real shell command
c) bash shell
d) both bash shell and bourne shell

15. The /boot directory stores the data that is used


a) before the kernel begins executing user mode programs
b) after the kernel begins executing user mode programs
c) before the bootloader is loaded in the RAM
d) none of the mentioned

16. Which one of the directory does not contain binary files?
a) /bin
b) /sbin
c) /etc
d) none of the mentioned

17. Kernel modules are present in


a) /lib directory
b) /root directory
c) /boot directory
18. The directory /opt is reserved for
a) installation of add-on application software packages
b) optional booting files
c) optional user specific files
d) none of the mentioned

19. The directory /srv contains


a) site-specific data which is served by the system
b) all the system files
c) all the service files provided by the specific user
d) none of the mentioned
20. Any file or directory present in the ______ directory may not be reserved between the invocation of
the program.
a) /var
b) /tmp
c) /etc
d) all of the mentioned

7)Which of the following is not inode operation?


Select one:
a. link
b. unlink
c. mkdir
d. None of the above

8) Which of the following file system exports kernel objects to user space, also observes
properties of kernel internal data structures and modify them?
Select one:
a. proc
b. sysfs
c. Both
d. None

10)Select correct option ___: __: ___:___ bin:lib:sbin:etc


Select one:
a. libraries, user commands, sys admin commands, configuration files
b. user commands, sys admin commands, libraries, configuration files
c. user commands, libraries, sys admin commands, configuration files
d. user commands, libraries, configuration files, sys admin commands

12) A bootloader is responsible for i. loading an operating system kernel and its ii. loading
supporting infrastructure into memory iii. beginning the kernel's execution
Select one:
a. i and ii
b. i and iii
c. ii and iii
d. All of the above

13) Which one of the following bootloader is not used by linux?


Select one:
a. GRUB
b. LILO
c. NTLDR
d. None of the mentioned

14)Which of the following Utilities found in the binutils package


Select one:
a. as, ld, ar
b. objcopy, objdump
c. Only a
d. Only b
e. Both a and b
15. Which macro is used to add kernel module functions to kernel symbol table?
Select one:
a. MODULE_EXPORT()
b. EXPORT_SYMBOL()
c. EXPORT_KERNEL()
d. EXPORT_FUNCTION()

16) Major number identifies the driver associated with the device and Minor number is used to
identify exactly which device is referred to.
Select one: a. True
b. False

17)Which of the following file operation in device driver allows issuing device specific
commands?
Select one:
a. mmap
b. ioctl
c. write
d. None of the above

Which of the following statement is not true?


Select one:
a. insmod is used to load the kernel module.
b. device drivers are dynamically loadable modules.
c. modprobe is used to load and unload the kernel module
d. None of the above

Select correct option i. cdev_add() Create a device node under /dev ii. cdev_init() associates
major and minor numbers with device file iii. cdev_add() make device entry in sysfs
Select one:
a. only i is correct
b. i and ii are correct
c. i and iii are correct
d. all are correct

The first argument of printk() indicates


Select one:
a. message suffixed by priority string
b. message prefixed by priority string
c. type of kernel message logger
d. None of the above

Which of the following provides a back trace of the execution in system space with respect
to our methods?
Select one:
a. dump_stack()
b. obj_dump()
c. trace()
d. None of the above

Which of the following is external tool for debugging?


Select one:
a. probe
b. LTI
c. kgdb
d. None of the above

23) Each thread has its own user stack and no kernel stack.
Select one:
a. True b. False

24)Which macros are used to read IO ports directly from Linux driver?
Select one:
a. read()
b. readdir()
c. inb()
d. poll()

25) Which of the is invalid name for makefile?


Select one:
a. Makefile
b. makefile
c. GNUmakefile
d. GNUMakefile
e. None of the above

26)Which of the following indicates first dependency from dependencies list?


Select one:
a. $<
b. $>
c. $@
d. $^

27)In the following command, how many jobs will run simultaneously? make -j8 -j4 bzImage
Select one:
a. 8
b. 4
c. 12
d. Both a and b
e. All of the above

28)Select correct option While configuring the kernel, the valid states for a configuration
option are: i. y — the option is enabled. ii. n — the option is not enabled. iii. m — the option
is set to be built as a module.
Select one:
a. Only i and ii
b. Only i and iii
c. i, ii and iii
d. Only ii and iii

29) Which of the following command copies the kernel image from arch/i386/boot/bzImage to
/boot/vmlinuz-version and edits /boot/grub/grub.cfg
Select one:
a. make modules
b. make modules_install
c. make bzImage
d. make install

30)"make modules" compiles all modules and "make modules_install" installs all the compiled
modules to their correct home in /modules.
Select one:
a. True b. False

31) The entries of /sys directory


Select one:
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

32) Which of the following is true?


Select one:
a. native compiler: A compiler where target is the same system as host.
b. cross compiler: A compiler where target is not the same system as host.
c. cross-native compiler: A native compiler where build is not the same as host.
d. All of the above.

33) To configure the kernel you can use which of the following command:
Select one:
a. make xconfig
b. make menuconfig
c. make gconfig
d. All of the above

34) Operating system can not kill any thread at any time but a thread can kill any other thread.
Select one:
a. True b. False

35 i)make ARCH=arm menuconfig ii)make ARCH=arm CROSS_COMPILE=arm-none-linuxgnueabi


Above two lines indicates -->
Select one:
a. The first line defines the host architecture config file, and the second line defines the
toolchain for host machine.
b. The first line defines the host archtecture config file, and the second line defines the
cross compilation toolchain prefix
c. The first line defines the architecture that kernel needs to be built for, and the second line defines the
cross compilation toolchain prefix.
d. The first line defines the architecture that kernel needs to be built for , and the second
line defines the toolchain for host machine.

36) For which of the following offset can be positive or negative?


Select one:
a. SEEK_SET
b. SEEK_END
c. SEEK_CUR
d. All of the above
e. None of the above
Linux Proc Filesystem Questions & Answers

1. Which one of the following is not true about proc filesystem?


a) proc filesystem is a pseudo-filesystem
b) proc filesystem is used as an interface to kernel data structures
c) some files in proc filesystem allow kernel variables to be changed
d) none of the mentioned

2. Proc filesystem provides the information about


a) processes
b) processor
c) proxy server
d) none of the mentioned

3. The /proc directory contains


a) numerical sub-directory for each running process
b) sub-directories for installed buses
c) a text listing of filesystems which are supported by the kernel
d) all of the mentioned

4. The file /proc/[PID]/cgroups


a) describes control groups to which the process belongs
b) contains the information about all groups of the system
c) provides the information about the group which has generated the process
d) none of the mentioned
Explanation: [PID] represents the process ID of the process. Every system has various running processes,
so /proc directory contains various numerical sub-directories and the number shows the PID of the
process.
advertisement

5. The file /proc/[PID]/cmdline holds the complete command line for the process, unless the process is
a
a) child process
b) zombie process
c) orphan process
d) none of the mentioned
Explanation: A zombie process is the process which has completed execution but still has an entry in the
process table.

6. What is /proc/[PID]/cwd?
a) symbolic link to current directory of the process
b) regular file containing the information about the current status of the process
c) directory containing various sub-directories
d) none of the mentioned

7. Which one of the following file contains the environment for the process?
a) /proc/[PID]/environ
b) /proc/[PID]/env
c) /proc/[PID]/path
d) none of the mentioned
8. The entry for each file opened by the process is present in
a) /proc/[PID]/fd
b) /proc/[PID]/file
c) /proc/[PID]/maps
d) none of the mentioned

9. The file /proc/[PID]/limits displays the ______ for each of the process’s resource limits.
a) hard limit
b) soft limit
c) units of measurement
d) all of the mentioned

10. The file /proc/[PID]/maps contains the


a) currently mapped memory regions
b) available memory regions
c) memory regions which are free to map
d) none of the mentioned

11. What is /proc/[PID]/root?


a) symbolic link that points to the process’s root directory
b) regular file which holds all the PID of the system
c) root directory
d) does not exists in the proc filesystem

12. “ps” command uses the file _____ to provide the information.
a) /proc/[PID]/stat
b) /proc/[PID]/smaps
c) /proc/[PID]/oom_score_adj
d) /proc/[PID]/oom_score

13. Which one of the following is not correct?


a) proc filesystem does not contain any directory for thread in the process
b) in multithread process thread details will not be available if the main thread is already terminated
c) proc filesystem contain any directory
d) none of the mentioned

14. Proc filesystem does not contains


a) sub-directories for installed buses
b) device files
c) list of registered DMA
d) none of the mentioned

15. The file /proc/devices is the


a) text listing of major numbers
b) text listing of device groups
c) text listing of major numbers & device groups
d) none of the mentioned

16. The file /proc/cpuinfo is a collection of


a) cpu items
b) architecture independent items
c) both cpu items and architecture independent items
d) none of the mentioned
17. The proc filesystem records the number of interrupts
a) per CPU only
b) per IO device only
c) per CPU per IO device
d) none of the mentioned

18. Which file of the proc filesystem can be used instead of “syslog” system call to read kernel messages?
a) /proc/kmsg
b) /proc/moudle/kmsg
c) /proc/module/msg
d) /proc/msg

19. The file /proc/modules is a text list of


a) static modules
b) dynamic modules
c) modules that have been loaded by the system
d) none of the mentioned

20. /proc/partitions contains


a) major number of each partition
b) minor number of each partition
c) number of block and partition name
d) all of the mentioned

21. Which one of the following operating system does not supports proc filesystem?
a) IBM AIX
b) QNX
c) Solaries
d) None of the mentioned

22. Obtaining of the PID can be done by the utility


a) pgrep
b) pidof
c) ps
d) all of the mentioned

23. Which one of the following contains various bits of information about the state of power
management?
a) /proc/acpi
b) /proc/apm
c) both /proc/acpi and /proc/apm
d) none of the mentioned

24. Which file contains the boot options passed to the kernel?
a) /proc/cmdline
b) /proc/root
c) /proc/boot
d) none of the mentioned

25. Which one of the following is a symlink to the root path as seen by the process?
a) /proc/[PID]/root
b) /proc/[PID]/path
c) both /proc/apm and /proc/[PID]/path
d) none of the mentioned

26. The directory /proc/[PID]/tasks contains


a) hard links to any task that have been started by this process
b) files that containing tasks that have been started by this process
c) sub-direcories of various tasks
d) none of the mentioned

27. The list of available frame buffers are stored in


a) /proc/[PID]/fb
b) /proc/fb
c) /proc/etc/fb
d) none of the mentioned

28. The buddy algorithm handles the


a) Memory fragmentation
b) DHCP server
c) Routing
d) None of the mentioned

29. The file /proc/swaps contains the


a) list of active swap partitions
b) sizes of the swap partitions
c) priorities of the swap partitions
d) all of the mentioned

30. /proc/tty contains the information about


a) current terminal
b) all terminals
c) both current & all terminals
d) none of the mentioned

31. The command “cd /proc/10/cwd” provides the


a) current working directory of process having PID 10
b) current status of the process having PID 10
c) current version of the filesystem
d) none of the mentioned

32. Which one of the following command will print the environement of process 1?
a) cat /proc/1/environ
b) cat /proc/bin/1/env
c) cat /proc/1/var/env
d) none of the mentioned

33. The file /proc/[PID]/mountinfo contains


a) major minor numbers of device files
b) root of the mount within the filesystem
c) mount point relative to the process’s root
d) all of the mentioned
34. With the help of proc filesystem
a) kernel and kernel modules can send the information to processes
b) process information can be accessed
c) kernel modules can send the information to processes & process information can be accessed
d) none of the mentioned

35. Most files and directories within /proc are 0 bytes in size because
a) proc filesystem exists only as a reflection of the in-memory kernel data structure
b) these files contains very only one or two instructions
c) proc filesystem doesn’t exists only as a reflection
d) none of the mentioned

36. Proc files are


a) read-only files
b) read-write files
c) both read-write and read-only files
d) none of the mentioned

37. Accessing the file /proc/meminfo gives the different result each time because
a) memory usages is always fluctuating
b) a new process id is assigned
c) logical address is different from the physical address
d) none of the mentioned

38. The files of /proc directory are


a) stored in secondary memory
b) generated by the kernel
c) stored in secondary memory & generated by the kernel
d) none of the mentioned

39. The directory /proc/net contains information about


a) Different network system compiled into the system
b) IP address of the system
c) MAC address of the system
d) None of the mentioned

40. The command “echo www.sanfoundry.com > /proc/sys/kernel/hostname” will


a) change the hostname
b) print “www.sanfoundry.com”
c) do nothing
d) none of the mentioned

42. Which file is used primarily for diagnosing memory fragmentation issues ?
a) /proc/buddyinfo
b) /proc/meminfo
c) /proc/apm
d) none of the mentioned

43. Which file shows the parameter passed to kernel at the time of starting?
a) /proc/apm
b) /proc/cmdline
c) both /proc/apm and /proc/cmdline
d) none of the mentioned

44. For the system having one processor, the processor identifying number in the file /proc/cpuinfo is
a) 0
b) 1
c) 2
d) 3

45. The file /proc/execdomains lists the


a) execution domains currently supported by the linux kernel
b) all domains of all processes
c) registered ISA DMA channel in use
d) none of the mentioned

46. The file /proc/kcore displays a size of


a) RAM
b) RAM plus 4 KB
c) RAM plus 8 KB
d) None of the mentioned

47. /bin/dmesg picks the messages from


a) /proc/kmesg
b) /sbin/klogd
c) both /proc/kmesg and /sbin/klogd
d) none of the mentioned

48. The file /proc/locks displays the file currently locked by the
a) kernel
b) user
c) superuser
d) none of the mentioned

49. The file /proc version shows the version of ______ used in the system.
a) kernel
b) gcc
c) both kernel and gcc
d) none of the mentioned

50. What is /proc/self ?


a) a directory
b) link to the currently running process
c) it allows a process to look itself without having to know its process ID
d) all of the mentioned

51. The /sbin/sysctl command is used to


a) view kernel settings in the /proc/sys/ directory
b) set kernel settings in the /proc/sys/ directory
c) automate kernel settings in the /proc/sys/ directory
d) all of the mentioned

Linux device driver:


Linux environment:
1. To increase the response time and throughput, the kernel minimizes the frequency of disk access by
keeping a pool of internal data buffer called
a) Pooling
b) Spooling
c) Buffer cache
https://man7.org/linux/man-pa
d) Swapping ges/man2/outb.2.html
View Answer

2. At start of process execution, STDOUT & STDERR


a) Point to current terminal device
b) Are closed This family of functions is
c) Point to special files on the system used to do low-level port
d) None of the mentioned
input and
View Answer
output. The out*
3. wtmp and utmp files contain: functions do port output,
a) Temporary system data the in* functions do
b) User login-logout log port input; the b-suffix
c) The user’s command execution log
d) The user’s su and sudo attempts functions are byte-width
and the w-
4. Which is the core of the operating system? suffix functions
a) Shell word-width; the _p-suffix
b) Kernel
c) Commands
functions pause until
d) Script the I/O completes.
View Answer

5. ILP32 stands for


a) 32 bit Integer, Long & Pointer
b) 32 bit Integrated Long & Pointer
c) 32 bit Intelligent Long & Pointer
d) 32 bit Long & Pointer

6. Single Unix Specification Version 2 provides enhanced support for


a) 16 bit Unix
b) 32 bit Unix
c) 64 bit Unix
d) 8 bit Unix

7. Under UNIX the key board is the default input device and the monitor is the default output device
a) True
b) False

8. Which among the following interacts directly with system hardware?


a) Shell
b) Commands
c) Kernel
d) Applications

9. Applications communicate with kernel by using:


a) System Calls
b) C Programs
c) Shell Script
d) Shell

10. Solaris is the name of a flavor of UNIX from


a) HP
b) IBM
c) Digital Equipment Corp
d) Sun Microsystems

11. Which of the following is “NOT” a UNIX variant ?


a) Solaris
b) AIX
c) IRIX
d) AS400

12. The system calls in UNIX is written using which language


a) C
b) C++
c) Assembly Language

13. Which of the following enables multi-tasking in UNIX?


a) Time Sharing
b) Multi programming
c) Multi user
d) Modularity
View Answer

14. Which of the following is considered as the super daemon in Unix?


a) sysinit
b) init
c) inetd
d) proc

15. Unix is which kind of Operating System?


a) Multi User
b) Multi Processes
c) Multi Tasking
d) All of the mentioned

16. SVR4 stands for?


a) Standard Version Release 4
b) System Version Release 4
c) Standard Five Release 4
d) System Five Release 4

17. Lp0 device file is used to access:


a) Floppy
b) Cdrom
c) Printer
d) Tape drive

18. Syntax of any Unix command is:


a) command [options] [arguments].
b) command options [arguments].
c) command [options] [arguments].
d) command options arguments

19. SVR4 was developed by


a) Sun Microsystems
b) AT&T
c) University of Berkeley
d) Sun and AT&T jointly

20. Which of these is not a Unix Flavor?


a) BSD
b) MAC
c) AIX
d) IRIX

21. Which of the following statement is FALSE ?


a) Unix supports multiple users
b) Linux is an open source operating system and the source code is shared
c) Shell takes care of inter process communication
d) Shell provides the feature of I/O Redirection

22. Which of the following UNIX flavor is from IBM?


a) BSD
b) Solaris
c) HP-UX
d) AIX

23. x86-32 uses which programming model?


a) IP16
b) IP32
c) ILP16
d) ILP32

24. What are the sizes of (Integer/Long/Pointer) in LP64 programming model?


a) 8/8/8
b) 4/4/8
c) 4/8/8
d) 4/8/4

25. Which among the following is used to write small programs to control Unix functionalities?
a) Shell Commands
b) Shell Script
c) Filters
d) C Language

26. What control character signals the end of the input file?
a) ctrl + a
b) ctrl + b
c) ctrl + c
d) ctrl + d

27. How do you get help about the command “cp”?


a) help cp
b) man cp
c) cd ?
d) none of the mentioned
Linux command:
1. The dmesg command
a) Shows user login logoff attempts
b) Shows the syslog file for info messages
c) kernel log messages
d) Shows the daemon log messages
View Answer

2. The command “mknod myfifo b 4 16”


a) Will create a block device if user is root
b) Will create a block device for all users
c) Will create a FIFO if user is not root
d) None of the mentioned

3. Which command is used to set terminal IO characteristic?


a) tty
b) ctty
c) ptty
d) stty

4. Which command is used to record a user login session in a file


a) macro
b) read
c) script
d) none of the mentioned

5. Which command is used to display the operating system name


a) os
b) unix
c) kernel
d) uname

6. Which command is used to display the unix version


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

7. Which command is used to print a file


a) print
b) ptr
c) lpr
d) none of the mentioned

8. Using which command you find resource limits to the session?


a) rlimit
b) ulimit
c) setrlimit
d) getrlimit
View Answer

9. Which option of ls command used to view file inode number


a) –l
b) -o
c) –a
d) –i

10. Find / -name ‘*’ will


a) List all files and directories recursively starting from /
b) List a file named * in /
c) List all files in / directory
d) List all files and directories in / directory

10. Which command is used to display the octal value of the text
a) octal
b) text_oct
c) oct
d) od

11. Which command is used to view compressed text file contents


a) cat
b) type
c) zcat
d) print

12. Which command changes a file’s group owner


a) cgrp
b) chgrp
c) change
d) group
View Answer

13. Which command is used to extract intermediate result in a pipeline


a) tee
b) extract
c) exec
d) none of the mentioned
View Answer

14. Which command is used to extract a column from a text file


a) paste
b) get
c) cut
d) tar

15. Which command is used to display disk consumption of a specific directory


a) du
b) ds
c) dd
d) dds

16. Which command is used to perform backup in unix?


a) backup
b) cpio
c) zip
d) gzip
17. Which command creates an empty file if file does not exist?
a) cat
b) touch
c) ed
d) read

18. Which option of rm command is used to remove a directory with all its subdirectories
a) –b
b) –o
c) –p
d) –r

19. Which command is used to identify file type?


a) Type
b) File
c) Finfo
d) Info

20. Command used to determine the path of an executable file is


a) which
b) where
c) wexec
d) what

21. Command used to count number of character in a file is


a) grep
b) wc
c) count

22. Which of these commands could you use to show one page of output at a time?
a) less
b) sed
c) pause
d) grep

23. Which commands will give you information about how much disk space each file in the current
directory uses?
a) ls -l
b) ls -la
c) du
d) ls -a

24. Which of the following command output contains userid?


a) ls
b) help
c) date
d) ls –l

25. Which command is used to display all the files including hidden files in your current and its
subdirectories ?
a) ls –aR
b) ls –a
c) ls –R
d) ls –l

26. Which of the following commands can be used to copy files across systems?
a) ssh
b) telnet
c) rsh
d) ftp

27. pwd command displays


a) user password
b) password file content
c) present working directory
d) none of the mentioned

28. Which of the following commands can be used to change default permissions for files and directories
at the time of creation
a) Chmod
b) Chown
c) Umask
d) Chgrp
View Answer

29. Which tar command option is used to list the files in a tape archive format?
a) cvf
b) tvf
c) xvf
d) ovf

30. Which of the following commands will allow the user to search contents of a file for a particular
pattern
a) touch
b) grep
c) find
d) ls

31. Write the command to display the current date in the form dd/mm/yyyy.
a) date +%d/%m/%Y
b) date +”%d/%m/%Y”
c) date +/%d/%m/20%y
32. The command syntax to display the file ‘sample.txt’ one page at a time is
a) man sample.txt>more
b) cat sample.txt<more
c) cat sample.txt|more
d) none of the mentioned

33. Which one shows the name of the operating system?


a) uname -n
b) uname -r
c) uname -o
d) uname –m

34. How do you add (append) a file “file1” to the example.tar file
a) no you cannot add a file to example.tar
b) tar -cvf example.tar file1
c) tar -rvf file1 example.tar
d) tar -evf file1 example.tar

35. How to execute ls command inside a vi editor?


a) !ls
b) :ls
c) :!ls
d) we can’t execute

36. Which command gives the first byte where the difference is in the file1 & file2?
a) diff
b) cmp
c) comm
d) ls -a

37. To open a file file1 with cursor at line number 4


a) vi +num file1
b) vi +set num file1
c) vi + “set num” file1
d) vi +/se nu file1

38. sed is a command typically used for


a) Perform complex calculations
b) Perform FIFO based non-blocking I/O
c) Modify/print selective contents of a file
d) None of the mentioned

39. What communication command provides communication to another user logged on by writing to the
bottom of their terminal?
a) talk
b) write
c) chat
d) transmit

40. Which screen manipulation command sets the screen back to normal?
a) tput cup
b) tput smso
c) tput rmso
d) tput blink

41. Which command will you use to see the available routes?
a) show route
b) route status
c) netstat -r
d) none of the mentioned

Linux Questions & Answers – File Management:

1. Which of the following time stamps need not exist for a file on traditional unix file system
a) Access Time
b) Modification Time
c) Creation Time
d) Change Time
View Answer

2. Which command is used to set limits on file size


a) fsize
b) flimit
c) ulimit
d) usize

3. Which option of rmdir command will remove all directories a, b, c if path is a/b/c
a) –b
b) –o
c) –p
d) –t

4. Which represents the user home directory


a) /
b) .
c) ..
d) ~

5. If a file is removed in Unix using ‘rm’ then


a) The file can be recovered by a normal user
b) The file cannot be recovered by a user
c) The file can be fully recovered provided the sytem is not rebooted
d) The file will be moved to /lost+found directory and can be recovered only by administrator’s
intervention

6. Executing the ‘cd ..’ command when at the root level causes
a) Error message indicating the user can’t access beyond the root level
b) Behavior is unix-flavor dependent
c) Results in changing to the ‘home’ directory
d) Nothing happens

7. How do you rename file “new” to file “old”?


a) mv new old
b) move new old
c) cp new old
d) rn new old

8. What command is used to copy files and directories?


a) copy
b) cp
c) rn
d) cpy

9. When mv f1 f2 is executed which file’s inode is freed?


a) f1
b) f2
c) new inode will be used

10. Any file’s attribute information is stored in which structure on the disk
a) Inode
b) Data blocks
c) File blocks
d) Directory file
View Answer

11. By default if any regular file is created, the number of link is displayed as 1 ?
a) True
b) False

12. How many links are created when we creat a directory file?
a) 1
b) 2
c) 3
d) 4

13. A user creates a link to a file file1 using the following command “ln file1 file2”. Which of the
following is not true?
a) file1 and file2 have the same inode numbers
b) The number of links for file1 is displayed as 1
c) The number of links for file1 is displayed as 2
d) The number of links for file2 is displayed as 2

14. There are two hard links to the “file1” say hl and h2 and a softlink sl. What happens if we deleted
the “file1”?
a) We will still be able to access the file with hl and h2 but not with sl
b) We will not be able to access the file with hl and h2 but with sl
c) We will be able to access the file with any of hl, h2 and sl
d) We will not be able to access the file with any of hl, h2 and sl

15. If two files on same partition point to the same inode structure they are called
a) Soft links
b) Hard links
c) Alias
d) Special files

16. Deleting a soft-link


a) Deletes the destination file
b) Deletes both the softlink and the destination file
c) Deletes just the softlink
d) backup of the destination is automatically created

17. Creation of hardlinks that point across partitions


a) is allowed only to root user
b) can be done by all users
c) the effects are unspecified
d) is not allowed

18. Which command is used to change permissions of files and directories?


a) mv
b) chgrp
c) chmod
d) set

19. Where can I find the printer in the file structure?


a) /etc
b) /dev
c) /lib
d) /printer

20. Which of the following statement is true?


a) The cp command will preserve the meta data of the file
b) The sort command by default sorts in the numeric order
c) The mv command will preserve the meta data of the file
d) The command ps will display the filesystem usage

21. What UNIX command is used to update the modification time of a file?
a) time
b) modify
c) cat
d) touch

Linux Questions & Answers – File Types:

1. The soft link will increase the link counter of the file.(T/F)
a) True
b) False

2. When you use the ln command, which of the following occurs?


a) a file is created that points to an existing file
b) a file is created that is a copy of an existing file
c) a file is moved from one location to another
d) a file is renamed

3. srwxr-xrw- is a
a) internet socket file
b) unix domain socket file
c) symbolic link
d) shared file

4. Binary or executable files are:


a) Regular files
b) Device files
c) Special files
d) Directory files

5. The directory file contains:


a) File names & File Sizes
b) File names & Inode Numbers
c) File names & Address
d) File names & Permissions

6. Which directory contain device special files?


a) /etc
b) /etc/dev
c) /root/bin
d) /dev
7. Which of the following is not a valid file type on Linux
a) Socket
b) Softlink
c) Inode
d) FIFO

8. Which of the following is not correct statement regarding file types?


a) Hard links share same inode number
b) Soft links cannot be created across partitions
c) Socket files are Unix domain sockets
d) Character file is a special file

9. Which are the two types of device files?


a) Character & Block
b) Character & Socket
c) Block & FIFO
d) Input & output

10. Which is an example for character special file?


a) Hard disk
b) CD-ROM
c) Terminal
d) Memory

11. Which is an example for block special file?


a) Virtual Terminal
b) CD-ROM
c) Terminal
d) Serial modem

12. All device files are stored in which directory?


a) /etc
b) /bin
c) /dev
d) /usr

Linux Questions & Answers – File Permissions :

1. The file permission 764 means:


a) Every one can read, group can execute only and the owner can read and write
b) Every one can read and write, but owner alone can execute
c) Every one can read, group including owner can write, owner alone can execute
d) Every one can read and write and execute

2. The permission -rwxr–r– represented in octal expression will be


a) 777
b) 666
c) 744
d) 711

3. Effective user id can be set using following permission


a) 0777
b) 2666
c) 4744
d) 1711

4. Effective group id can be set using following permission


a) 0777
b) 2666
c) 4744
d) 1711

5. Sticky bit can be set using following permission


a) 0777
b) 2666
c) 4744
d) 1711

6. The permission -rwSr–r– represented in octal expression will be


a) 0777
b) 2666
c) 4744
d) 4644

7. The permission -rwxr-sr– represented in octal expression will be


a) 0777
b) 2766
c) 2744
d) 2754

8. If user tries to remove (rm) a readonly file (444 permission), what will happen?
a) The file is removed successfully (and silently)
b) The rm command prompts for a confirmation, the command is successful upon confirmation
c) The rm command prompts for a confirmation, however the operation fails because of insufficient
permissions
d) The rm command fails because of insufficient permissions

9. A user does a chmod operation on a file. Which of the following is true?


a) The last accessed time of the file is updated
b) The last modification time of the file is updated
c) The last change time of the file is updated
d) None of the mentioned

10. If the umask value is 0002. what will be the permissions of new directory
a) 777
b) 775
c) 774
d) 664

11. What is the command to set the execute permissions to all the files and subdirectories within the
directory /home/user1/direct
a) chmod –r +x /home/user1/direct
b) chmod –R +x /home/user1/direct
c) chmod –f –r +x /home/user1/direct
d) chmod –F +x /home/user1/direct

12. The permission -rwxr-xr-t represented in octal expression will be


a) 0777
b) 1755
c) 1754
d) 2754

13. With a umask value of 112, what is the default permission assigned to newly created regular file?
a) —x–x-wx
b) -rw-rw-r–
c) -r-xr-x-r–
d) -rw-rw-r–

14. Which command is used to assign read-write permission to the owner?


a) chmod a+r file
b) chmod o+r file
c) chmod u=rw file
d) chmod og-r file

15. Given the command


$ chmod o-w datafile
a) sets write permission to everyone for datafile
b) sets write permission to others for datafile
c) clears write permission to everyone for datafile
d) clears write permission to others for datafile

16. 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

17. If you are a root user, how can you grand execute permission only for the owner of the file project1?
a) chmod +x project1
b) chmod u+x project1
c) chmod a+x project1
d) chmod U+X project1

18. A user executes the following command successfully:


$ chmod +x file1.txt Which of the following is true of the output of this command?
a) The command results in adding execute permission to the user who ran this command
b) The command results in adding execute permission for the owner of the file
c) The command results in an error since the file is not an executable file
d) The command results in adding execute permission for all users (i.e., user,group & others)

19. What does chmod +t do?


a) wrong syntax
b) set effective userid for filename
c) set effective groupid for filename
d) set the sticky bit
20. Which of the following umask settings doesn’t allow execute permission to be set by default on
directory files
a) 222
b) 111
c) 000
d) 444

21. Which of the following umask settings allow execute permission to be set by default on regular files
a) 222
b) 111
c) 000
d) None of the mentioned

22. The command chmod 4777 a.out


a) will set the suid bit of a.out
b) will set the suid bit of a.out only if the command is issued by root
c) is not a valid command
d) will set the sticky bit of a.out

Linux Questions & Answers – Filesystem Overview:

1. Which command is used to check filesystem usage in a system?


a) mount
b) df
c) du
d) dd

2. Which among the following allows fast file system recovery?


a) Ext2
b) Journaling
c) Caching
d) Sysfs

3. Which filesystem can be used to change certain kernel parameters at runtime using sysctl command?
a) Ext3
b) Sysfs
c) Ext4
d) Procfs

4. Filesystem for CDROM is:


a) Ext2
b) Ext3
c) Isofs
d) Procfs

5. Which file system has journaling capability?


a) Ext2
b) Ext4
c) Isofs
d) Procfs
6. Which file contains the filesystems to be automatically mounted during boot?
a) /etc/mount
b) /etc/fstab
c) /etc/inittab
d) /etc/boot

7. ____ is a directory (which should exist), on which to mount the file system?
a) Root
b) Boot
c) Mount-point
d) Partition

8. Which command is used to mount file system read only.


a) mount –a
b) mount –v
c) mount –f
d) mount –r

Linux Questions & Answers – Startup & Shutdown:

1. Which of the following is not a valid run-level


a) S
b) 0
c) 8
d) 1

2. On Linux, initrd is a file


a) Containing root file-system required during bootup
b) Contains only scripts to be executed during bootup
c) Contains root-file system and drivers required to be preloaded during bootup
d) None of the mentioned

3. Which is loaded into memory when system is booted?


a) Kernel
b) Shell
c) Commands
d) Script

4. The process of starting up a computer is known as


a) Boot Loading
b) Boot Record
c) Boot Strapping
d) Booting

5. Bootstrapping is also known as


a) Quick boot
b) Cold boot
c) Hot boot
d) Fast boot

6. The shell used for Single user mode shell is:


a) bash
b) Csh
c) ksh
d) sh

7. Single user mode shell runs as


a) Admin user
b) Root user
c) Normal user
d) Log user

8. Which is the only partition mounted in Single user mode


a) boot
b) usr
c) root
d) tmp

9. Which daemon manages the physical memory by moving process from physical memory to swap
space when more physical memory is needed.
a) Sched daemon
b) Swap daemon
c) Init daemon

10. At the end of kernel bootstrap, which process is started?


a) /etc/init
b) /etc/sched
c) /etc/swap
d) /etc/kernel

11. The process id of init process is:


a) -1
b) 0
c) 1
d) 2

12. Which file is read by init to get the default runlevel


a) /etc/profile
b) /etc/init
c) /etc/boot
d) /etc/inittab

Linux Questions & Answers – Process Management:

1. If a program executing in background attempts to read from STDIN


a) It is terminated
b) It’s execution is suspended
c) STDIN is made available to it
d) None of the mentioned

2. Which command is used to bring the background process to forground?


a) bg
b) fg
c) background
d) forground
3. How to run a process in the background?
a) &
b) *
c) ?
d) |

4. Which command can be executed by a user who is already logged into the system, in order to change
to the root user? (type the command without any parameters)
a) su
b) root
c) chroot
d) user

5. Process information in the current shell can be obtained by using


a) kill
b) bg
c) fg
d) ps

6. Which signal is sent by the command “kill -9 ” ?


a) INT
b) TERM
c) KILL
d) STOP

7. Which of the following values for STAT column of ps command is not true:
a) status R means running
b) Status S means sleeping
c) Status E means exited
d) Status Z means zombie

8. When a child process exits before the parent process exits, which of the following is true:
a) the child process becomes defunct
b) the parent process becomes defunct
c) if the parent process does not handle SIGCHLD, the child process becomes a zombie
d) none of the mentioned

9. A user issues the following command sequence:

$ a.out &
$ bash
$ a.out &
If the user kills the bash process, then which of the following is true?
a) the second a.out process is also terminated
b) the second a.out process becomes a defunct process
c) the first a.out process becomes a zombie process
d) init process becomes parent of second a.out process

10. The signal sent to a process when the Ctrl-C key is pressed is
a) KILL
b) TSTP
c) TERM
d) INT

11. we can change the priority of a running process using


a) nice
b) renice
c) priority cannot be changed for a running process
d) only superuser can change the priority

12. nohup is used to


a) automatically hang up the process after logout
b) continue the process after logout
c) create backgroung process
d) manually hang up the process after logout

Linux Questions & Answers – User Account Management:

1. User’s Primary Group id is listed in which file, at the time of creation of the user (On a standard Unix
system)
a) /etc/passwd
b) /etc/groups
c) /etc/login
d) /etc/profile

2. The encrypted password of a user is stored in


a) /etc/shadow
b) /etc/enpasswwd
c) /etc/.passwd
d) /etc/passwd

3. A user can change the default log-in shell using


a) chmod
b) chsh
c) rmsh
d) tchsh

4. Which of the following identifiers associated with a process decide its privilege level
a) uid
b) suid
c) euid
d) gid

5. The /etc/passwd file doesn’t contain


a) userid
b) home directory for a user
c) login shell name
d) none of the mentioned

6. User id 0 is
a) An innvalid user id
b) The id of the root user
c) The id of a user when the user’s account is deleted
d) None of the mentioned
7. The login shell is
a) The shell program that runs when the user logs in
b) The shell program that authenticates the user while logging in
c) Common shell for all the users that belong to the same group
d) None of the mentioned

8. Which of the following command can be used to change the user password?
a) user can’t change the password
b) passwd
c) passd
d) pwd

9. What does the following command do ?


who | wc –l
a) List the number of users logged in
b) List the users
c) List the number of users in the system
d) Display the content of who command

10. By default, a Linux user falls under which group?


a) staff
b) others
c) same as userid (UPG)
d) system

11. Which of the following files need to be referred for user’s secondary group?
a) /etc/passwd
b) /etc/shadow
c) /etc/group
d) /etc/profile

12. The ls –l output for /etc/passwd and /usr/bin/passwd is as follows:

-rw-rw-r-- 1 root root 2807 Apr 26 13:50 /etc/passwd


-r-s—x—x 1 root root 17008 May 25 02:30 /usr/bin/passwd

If a user, not belonging to the group ‘root’, runs the passwd executable in an attempt to modify his
password, then which of the following is true?
a) password change fails since user does not have permission to update /etc/passwd file
b) password change is successful because the program runs as root
c) passwd change program runs in kernel mode where write access to the /etc/passwd file is possible
d) /etc/passwd is a special file and the system by default allows all users to update it
View Answer

Linux Questions & Answers – Shell Programming:

1. 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 $$$$
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. How do you print the lines between 5 and 10, both inclusive
a) cat filename | head | tail -6
b) cat filename | head | tail -5
c) cat filename | tail +5 | head
d) cat filename | tail -5 | head -10

4. Create a new file “new.txt” that is a concatenation of “file1.txt” and “file2.txt”


a) cp file.txt file2.txt new.txt
b) cat file1.txt file2.txt > new.txt
c) mv file[12].txt new.txt
d) ls file1.txt file2.txt | new.txt

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)

6. What is the output of the following code:


os=Unix
echo 1.$os 2."$os" 3.'$os' 4.$os
a) 1.Unix 2.Unix 3.Unix 4.Unix
b) 1.Unix 2.Unix 3.$os 4.Unix
c) 1.Unix 2.Unix 3.Unix 4.$os
d) 1.Unix 2.$os 3.$os 4.$os

7. What is the return value ($?) of this code:


os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3
a) 0
b) 1
c) 2
d) 3

8. What is the output of the following program?

x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )]
then
echo $x
else
echo $y
fi
a) 1
b) 3
c) 5
d) Error

9. 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

11. The expression expr -9 % 2 evaluates to:


a) 0
b) 1
c) -1
d) 2

12. The statement z = ‘expr 5 / 2’ would store which of the following values in z?
a) 0
b) 1
c) 2
d) 2.5

13. To feed standard output of one command to standard input of another in a single shell session
a) IO redirection can be used
b) Named pipes can be used
c) The pipe operator provided by the shell can be used
d) It can not be done

14. Which of the following commands allows definition and assignment of environment variables under
bash
a) env
b) export
c) environ
d) setenviron

15. While executing a command, the shell


a) Executes it in the same process (as shell)
b) Creates a child shell to execute it
c) Loads a special program to take care of the execution
d) None of the mentioned
16. If a file with execute permissions set, but with unknown file format is executed
a) The file is passed to /bin/sh
b) The system returns an error
c) The current shell will try to execute it
d) None of the mentioned
17. Which of the following is true?
a) Shell is a process and can be started by superuser only
b) Shell is a built-in Kernel functionality
c) Shell is a wrapper for all the commands and utilities
d) None of the mentioned

18. Which is true with regards to the shell prompt


a) It can be accidentally erased with backspace
b) The prompt cannot be modified
c) The prompt can be customized (modified)
d) None of the mentioned

19. What is a shell in UNIX?


a) a program through which users can issue commands to UNIX
b) a window management system
c) the login screen
d) the thing that rides on the back of a turtle in UNIX

20. Which of the following represents an absolute path?


a) ../home/file.txt
b) bin/cat
c) cs2204/
d) /usr/bin/cat

21. The user bhojas logged in and performed the following sequence of command. What will be the
output of the last command?
$ cd project/module1
$ pwd
a) /home/bhojas/project/module1
b) /home/project/module1
c) /usr/bhojas/project/module1
d) project/module1

22. BASH shell stands for?


a) Bourne-again Shell
b) Basic Access Shell
c) Basic to Advanced Shell
d) Big & Advanced Shell

23. Which of the following files will not be displayed by the command cat re* ?
a) reminder
b) receipt
c) Receipt
d) recipe-cake

24. The redirection 2> abc implies


a) Write file 2 to file abc
b) Write standard output to abc
c) Write standard error to abc
d) None of the mentioned

25. cmd 2>&1 > abc will


a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor

26. cmd > abc 2>&1 will


a) Write file2 to file1
b) Write standard output and standard error to abc
c) Write standard error to abc
d) Write standard output to abc & standard error to monitor

27. Which of these is the correct method for appending “foo” in /tmp/bar file?
a) echo foo > /tmp/bar
b) echo foo >> /tmp/bar
c) echo foo | /tmp/var
d) /tmp/bar < echo foo

28. Syntax to suppress the display of command error to monitor?


a) command > &2
b) command 2> &1
c) command 2> &2
d) command 2> /dev/null

29. The following commands gives the output like this


#cat file1 file2
#cat: file1: No such file or directory
hello
If we execute the command “cat file1 file2 1>2 2>&1” the output would be
a) cat: file1: No such file or directory hello
b) No output is displayed
c) Cat: 1>2: No such file or directory
d) hello

30. cat < file1 >> file2 | file3


a) file1 content will be appended to file2 and finally stored in file3
b) file1 content will be appended to file2 and file3 will be ignored
c) file2 and file3 will have same content
d) syntax error

31. Executing cat /etc/password > /dev/sda as superuser will


a) Write data into a regular file called /dev/sda
b) Write data to the physical device sda
c) Create a temporary file /dev/sda and write data to it
d) None of the mentioned

32. From where would the read statement read if the following statements were executed?
exec < file1
exec < file2
exec < file3
read line
a) It would read all the files
b) It would not read any files
c) It would read all the files in reverse order
d) It would read only file3

33. The $ variables in a shell script context designates


a) The runtime of the script
b) Number of command line arguments
c) PID of the shell running the script
d) The exit status of the shell script

34. Which variable is used to display number of arguments specified in command line
a) $0
b) $#
c) $*
d) $?

35. Which variable contains last background job process id


a) $*
b) $?
c) $$
d) $!

36. Which command can be used to test various file attributes


a) if
b) file
c) test
d) type

37. * Specifies
a) one or more character
b) zero or more charecter
c) nothing
d) none of the mentioned

38. ? Specifies
a) one or more character
b) zero or more charecter
c) one character
d) none of the mentioned

39. Which of the following file set in the current directory are identified by the regular expression a?b*
a) afcc, aabb
b) aabb, axbc
c) abbb, abxy
d) abcd, axbb

40. What command would send the output of cmd1 to the input of cmd2?
a) cmd1 | cmd2
b) cmd1 || cmd2
c) cmd1 && cmd2
d) cmd1 ; cmd2
41. What is the output of the following command for bash shell:
echo linux $0
a) linux echo
b) linux linux
c) linux bash
d) linux

41. Which variable will display the list of the positional parameters?
a) $#
b) $*
c) $?
d) $$

42. Which option of grep displays the line number as well?


a) -v
b) -l
c) -n
d) -E

43. How can you search for blank line in a file?


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

44. Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files match
with the pattern file[ABC]?
a) fileA, fileB and fileABC
b) fileABC
c) fileA and fileB
d) fileAB, fileBC and fileABC

45. What will be printed for the command below?


$ grep –c “^echo” abc
a) The count of lines that do not contain the pattern echo in file abc
b) The count of lines which begin with the pattern echo in file abc
c) The count of lines that ends with the pattern echo in file abc
d) None of the mentioned

46. Which one is used to select only one copy of the repeated lines?
a) uniq -u
b) uniq -d
c) uniq -c
d) uniq –I

47. Indicate the right option to search for BOB, Bob, BOb or BoB?
a) grep –i Bob files
b) grep ‘B[oO][bB]’ files
c) grep ‘[BOB]’ files
d) grep -v ‘Bob’ files

48. Indicate the right option to search for anything not a letter or number
a) grep ‘^[a-zA-Z0-9]’
b) grep ‘[^a-zA-Z0-9]’
c) grep ‘[a-zA-Z0-9]’
d) None of the mentioned

49. How do you remove duplicate lines from the file foo using uniq?
a) sort foo | uniq –u
b) sort -u foo | uniq -d
c) sort foo | uniq –c
d) sort foo | uniq –I

50. One of the entry of /etc/passwd file is shown below:


user1:x:1111:2222:Sanfoundry:/home/user1:/bin/bash
Which among the following will print userid and home dir in the following pattern “user1:/home/user1”
a) awk `{print $1 “:” $6}` /etc/passwd
b) awk `{print $1 “:” $7}` /etc/passwd
c) awk `{print $2 “:” $6}` /etc/passwd
d) awk `{print $2 “:” $7}` /etc/passwd

51. who | cut –d ” ” -f1


what is the ouput if the who command displays like this
user1 tty 0 1234
a) user1
b) user1 tty 0 1234
c) tty
d) tty 0 1234

52. What is the command that can print lines of first file matching with second file?
a) printline
b) cmp
c) com
d) comm

53. Which character to use to escape meaning of special characters in search operations?
a) []
b) ^
c) .
d) backslash (\)

54. Which built-in command performs integer arithmetic in bash shell?


a) let
b) get
c) set
d) none of the mentioned

55. Which expression use the value of the enclosed arithmetic expression?
a) $(())
b) $()
c) ${}
d) $[].

56. If a and b are 2 variables then the meaning of a<<=b is


a) b = a << b
b) a = a << b
c) b = b << a
d) a = a << b

57. Which one of the following is bitwise ‘exclusive or’ operator?


a) ^=
b) |=
c) !=
d) none of the mentioned

58. Which one of the following is not a valid operator in bash shell?
a) ||
b) ~
c) =<<
d) -=

59. What is the output of this program?

#!/bin/bash
a=2
b=4
let c=a**b
echo $c
exit 0
a) 8
b) 16
c) 32
d) none of the mentioned

60. What is the output of this program?


#!/bin/bash
a=10; b=20
c=$((++a))
let a=c+a
echo $a
exit 0
a) 21
b) 22
c) program will generate an error message
d) none of the mentioned

61. What is the output of this program?


#!/bin/bash
a=10
b=$(( $a<0?10:$a<100 ))
echo $b
exit 0
a) 10
b) 20
c) 1
d) 0
Explanation: Firstly the ‘$a<0’ condition has been checked. Because it is false hence the right hand side
condition of the colon (:) has been checked and this is true so program output is 1.
Output:
root@ubuntu:/home/sanfoundry# ./test.sh
1
root@ubuntu:/home/sanfoundry#

62. What is the output of this program?


#!/bin/bash
a=10
b=$(( $a<0&&$a<100 ))
echo $b
exit 0
a) 10
b) 0
c) 1
d) none of the mentioned
Explanation: The condition ‘$a<0’ is false so logical and operator provides the output 0.
Output:
root@ubuntu:/home/sanfoundry# ./test.sh
0
root@ubuntu:/home/sanfoundry#

63. What is the output of this program?


#!/bin/bash
a=1; b=2; c=3
d=$(( ++a**b*c++ + a ))
echo $d
exit 0
a) 14
b) 12
c) program will generate an error message
d) none of the mentioned
Explanation: The operators in decreasing order of precedence are ++, **, *, +.
Output:
root@ubuntu:/home/sanfoundry# ./test.sh
14
root@ubuntu:/home/sanfoundry#

64. Which command runs the shell built-in command ‘command’ with the given argument?
a) builtin
b) caller
c) there is no command present for this purpose
d) none of the mentioned

65. Which option of the command ‘cd’ use the actual filesystem path for cd.. and the value of pwd?
a) -l
b) -L
c) -p
d) -P

67. Which command generates possible completions for string according to the and write it to standard
output?
a) compgen
b) complete
c) continue
d) none of the mentioned

68. Which command executes ‘command’ in place of the current process instead of creating a new
process?
a) exec
b) command
c) trap
d) none of the mentioned

Linux Questions & Answers – vi Editor:

1. Which one of the following statement is not true?


a) vim editor is the improved version of vi editor
b) vi editor commands are not case sensitive
c) vi editor has two modes of operation: command mode and insert mode
d) vi stands for visual editor

2. Which command is used to close the vi editor?


a) q
b) wq
c) both q and wq
d) none of the mentioned
Explanation: The command ‘q’ just closes the file and ‘wq’ saves and closes the file.

3. In vi editor, the key combination CTRL+f


a) moves screen down one page
b) moves screen up one page
c) moves screen up one line
d) moves screen down one line

4. Which vi editor command copies the current line of the file?


a) yy
b) yw
c) yc
d) none of the mentioned

5. Which command is used to delete the character before the cursor location in vi editor?
a) X
b) x
c) D
d) d
Explanation: The command ‘x’ is used to delete the character under the cursor locarion.

6. Which one of the following statement is true?


a) autoindentation is not possible in vi editor
b) autoindentation can be set using the command ‘:set ai’
c) autoindentation can be set using the command ‘:set noai’
d) autoindentation is set by default in vi editor

7. Which command searches the string in file opened in vi editor?


a) / or ?
b) f or F
c) t or T
d) none of the mentioned
Explanation: The command ‘/’ searches downward in the file and command ‘?’ searches upward in the
file.

8. In vi editor, which command reads the content of another file?


a) read
b) r
c) ex
d) none of the mentioned

9. Which command shows all the abbreviations in vi editor?


a) ab
b) abb
c) show
d) none of the mentioned

10. Which command sets the number for all lines?


a) :set li
b) :set ln
c) :set nu
d) :set nl

Professional Device Drivers Interview Questions & Answers:

1. The major number identifies the _____ associated with the device.
a) driver
b) protocol
c) port
d) none of the mentioned

a) driver

2. The kernel identifies the driver with its:


a) module
b) major number
c) device file
d) none of the mentioned

b) major number

3. In linux kernel 2.4, we can have:


a) 256 character drivers only
b) 256 block drivers only
c) 256 character drivers and 256 block drivers at the same time
d) none of the mentioned

c) 256 character drivers and 256 block drivers at the same time
4. The connection between the device file and device driver is based on the:
a) name of device file
b) number of device file
c) both (a) and (b)
d) none of the mentioned

b) number of device file

5. Do you know what is the output of this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
char *ptr;
memcpy(ptr,"google",11);
printf("%sn",ptr);
return 0;
}
a) google
b) segmentation fault
c) syntax error
d) none of the mentioned

b) segmentation fault
Explanation:
Memory must be allocated to pointer "ptr".
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Segmentation fault (core dumped)
[root@localhost google]#

6. This program will allocate the memory of ___ bytes for pointer "ptr".

#include<stdio.h>
#include<stdlib.h>

int main()
{
int *ptr;
ptr = realloc(0,sizeof(int)*10);
return 0;
}
a) 0
b) 10
c) 40
d) none of the mentioned

c) 40
Explanation:
If the first argument of realloc() is NULL, then it behaves just like malloc().

7. What is the output of this program?

#include<stdio.h>
#include<stdlib.h>

int main()
{
char *ptr;
free(ptr);
return 0
}
a) this program will print nothing after execution
b) segmentation fault
c) Aborted (core dumped)
d) none of the mentioned

c) Aborted (core dumped)

8. Tell me what is the output of this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
char *ptr;
memcpy(ptr,"google",11);
printf("%sn",ptr);
return 0;
}
a) google
b) segmentation fault
c) syntax error
d) none of the mentioned

b) segmentation fault
Explanation:
Memory must be allocated to pointer "ptr".
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Segmentation fault (core dumped)
[root@localhost google]#

9. What is the output of this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char *ptr;
ptr = (char*)malloc(sizeof(char)*11);
strcpy(ptr,"google");
printf("%dn",*ptr);
return 0;
}
a) s
b) google
c) 115
d) segmentation fault

c) 115
Explanation:
This program will print the equivalent decimal value at location pointed by "ptr".
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
115
[root@localhost google]#

10. Which one of the following in true about this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
char *ptr;
printf("%pn",ptr);
ptr = (char *)malloc(sizeof(char));
printf("%pn",ptr);
return 0;
}
a) this program will give segmentation fault
b) this program will print two same values
c) this program has some syntax error
d) none of the mentioned

d) none of the mentioned


Explanation:
This program will print two different values.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
0x4a77cff4
0x980c008
[root@localhost google]#

11. In this program the two printed memory locations has the difference of ___ bytes.
#include<stdio.h>
#include<stdlib.h>

int main()
{
int *ptr;
ptr = (int*)malloc(sizeof(int)*2);
printf("%pn",ptr);
printf("%pn",ptr+1);
return 0;
}
a) 1
b) 4
c) can not be determined
d) none of the mentioned

b) 4
Explanation:
Pointer will increment by 4 bytes because it is the types of integer.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
0x9b4e008
0x9b4e00c
[root@localhost google]#

12. What is the output of this program?

#include<stdio.h>
#inlcude<stdlib.h>

int main()
{
int *ptr;
double *ptr;
printf("%dn",sizeof(ptr));
return 0;
}
a) 4
b) 8
c) the compiler will give the error
d) segmentaion fault

c) the compiler will give the error


Explanation:
Just see the output carefully.
Output:
[root@localhost google]# gcc -o san san.c
san.c: In function 'main':
san.c:8:10: error: conflicting types for 'ptr'
san.c:7:7: note: previous declaration of 'ptr' was here
[root@localhost google]#
13. What is the output of this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
int ptr;
ptr = (int)malloc(sizeof(int)*10);
return 0;
}
a) syntax error
b) segmentaion fault
c) run time error
d) none of the mentioned

d) none of the mentioned


Explanation:
The memory has been allocated but we can not access rest of the memory other than 4 bytes.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
[root@localhost google]#

14. Which one of the following is not true?


a) dynamic allocation of major numbers is not possible
b) major number can not be shared among drivers
c) both (a) and (b)
d) none of the mentioned

c) both (a) and (b)

15. The minor number range should be:


a) 0 to 15
b) 0 to 63
c) 0 to 255
d) none of the mentioned

c) 0 to 255

16. In we use a driver for N number of files, then we have to create ____ device files.
a) N
b) 1
c) N-1
d) none of the mentioned

a) N

17. In linux, a device driver can work without the:


a) major number
b) minor number
c) device file name
d) none of the mentioned

d) none of the mentioned

18. In linux kernel 2.1, the minor numbers were used to:
a) represent the sub-functionalitites of the driver
b) identify the driver
c) represent the device files
d) none of the mentioned

a) represnt the sub-functionalitites of the driver

19. If we use a driver for various device files, then:


a) minor number will be different for every device file
b) minor number will be same for every device file
c) minor number can not be allocated for any device file
d) none of the mentioned

a) minor number will be different for every device file

Linux questions and answers focuses on Major-Minor


numbers used by the Linux Device Drivers.1. The major
number identifies the _____ associated with the device.
a) driver
b) protocol
c) port
d) none of the mentioned
Answer: a
Clarification: None.
2. The minor number range should be
a) 0 to 15
b) 0 to 63
c) 0 to 255
d) none of the mentioned
Answer: c
Clarification: None.
3. Which one of the following is not true?
a) dynamic allocation of major numbers is not possible
b) major number can not be shared among drivers
c) dynamic allocation of major numbers is not possible &
Write With Confidenc
Check your grammar, spelling, a
Grammarly
Grammarly
also major number can not be shared among drivers
d) none of the mentioned
Answer: c
Clarification: None.
4. In linux kernel 2.4, we can have
a) 256 character drivers only
b) 256 block drivers only
c) 256 character drivers and 256 block drivers at the same
time
d) none of the mentioned
Answer: c
Clarification: c
5. In we use a driver for N number of files, then we have to
create ____ device files.
a) N
b) 1
c) N-1
d) None of the mentioned
Answer: a
Clarification: None.
6. If we use a driver for various device files, then
a) minor number will be different for every device file
b) minor number will be same for every device file
c) minor number can not be allocated for any device file
d) none of the mentioned
Answer: a
Clarification: None.
7. The connection between the device file and device driver
is based on the
a) name of device file
b) number of device file
c) name & number of device file
d) none of the mentioned
Answer: b
Clarification: None.
8. In linux kernel 2.1, the minor numbers were used to
a) represnt the sub-functionalitites of the driver
b) identify the driver
c) represent the device files
d) none of the mentioned
Answer: a
Clarification: None.
9. The kernel identifies the driver with its
a) module
b) major number
c) device file
d) none of the mentioned
Answer: b
Clarification: None.
10. In linux, a device driver can work without the
a) major number
b) minor number
c) device file name
d) none of the mentioned
Answer: d
Clarification: None.

.1. What is /proc/[PID]/root?


a) symbolic link that points to the process’s root directory
b) regular file which holds all the PID of the system
c) root directory
d) does not exists in the proc filesystem
Answer: a
Clarification: None.
2. “ps” command uses the file _____ to provide the
information.
a) /proc/[PID]/stat
b) /proc/[PID]/smaps
c) /proc/[PID]/oom_score_adj
d) /proc/[PID]/oom_score
Answer: a
Clarification: None.
3. Which one of the following is not correct?
a) proc filesystem does not contain any directory for thread
in the process
b) in multithread process thread details will not be available
if the main thread is already terminated
c) proc filesystem contain any directory
d) none of the mentioned
Answer: a
Clarification: None.
4. Proc filesystem does not contains
a) sub-directories for installed buses
b) device files
c) list of registered DMA
d) none of the mentioned
Answer: b
Clarification: None.
5. The file /proc/devices is the
a) text listing of major numbers
b) text listing of device groups
c) text listing of major numbers & device groups
d) none of the mentioned
Answer: c
Clarification: None.
6. The file /proc/cpuinfo is a collection of
a) cpu items
b) architecture independent items
c) both cpu items and architecture independent items
d) none of the mentioned
Answer: a
Clarification: None.
7. The proc filesystem records the number of interrupts
a) per CPU only
b) per IO device only
c) per CPU per IO device
d) none of the mentioned
Answer: c
Clarification: None.
8. Which file of the proc filesystem can be used instead of
“syslog” system call to read kernel messages?
a) /proc/kmsg
b) /proc/moudle/kmsg
c) /proc/module/msg
d) /proc/msg
Answer: a
Clarification: None.
9. The file /proc/modules is a text list of
a) static modules
b) dynamic modules
c) modules that have been loaded by the system
d) none of the mentioned
Answer: c
Clarification: None.
10. /proc/partitions contains
a) major number of each partition
b) minor number of each partition
c) number of block and partition name
d) all of the mentioned
Answer: d

2.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 mentionedAnswer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: None.
4. A device class describes the ____ type of device.
a) physical
b) stuctural
c) functional
d) none of the mentioned
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: None.
7. Which one of the following is not a system device?
a) CPU
b) APIC
c) Timer
d) None of the mentioned
Answer: d
Clarification: 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
Answer: d
Clarification: 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
Answer: d
Clarification: 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
Answer: a

4.1. Relationship between components of device driver


models are expressed in the sysfs as
a) a directory
b) a regular file
c) symbolic links between files and directories
d) none of the mentioned
Answer: c
Clarification: None.
2. What is the main role of the regular files in the sysfs?
a) regular files represent the attributes of devices and drivers
b) regular files represent the kernel objects
c) regular files represent the kernel sets
d) none of the mentioned
Answer: a
Clarification: None.
3. The core data structure of device driver model is
a) kobject
b) kfile
c) kmodule
d) none of the mentioned
Answer: a
Clarification: None.
4. The kset contains
a) pointer to subsystem descriptor
b) pointer to the kobject type descriptor of the kset
c) head of the kobjects included in the kset
d) all of the mentioned
Answer: d
Clarification: None.
5. Which one of the following is a read-write semaphore in
linux that protects all ksets and kobjects included in the
filesystem?
a) rwsem
b) rwsemaphore
c) rws
d) none of the mentioned
Answer: a
Clarification: None.
6. Each device in the device driver model is represented by a
_____ object.
a) driver
b) device
c) node
d) none of the mentioned
Answer: b
Clarification: None.
7. Each driver in the device driver model is described by a
______ object.
a) dev_d
b) device_d
c) dev_driver
d) device_driver
Answer: d
Clarification: None.
8. The channel between the processor and devices is called?
a) bus
b) driver
c) class
d) none of the mentioned
Answer: a
Clarification: None.
9. In which directory every kernel module of the system is
represented?
a) /sys/kernel
b) /sys/module
c) /sys/kernel/module
d) none of the mentioned
Answer: c
Clarification: None.
10. In sysfs the device drivers of same _____ are expected
to provide same functionalities to the user mode application.
a) class
b) kobjects
c) ksets
d) none of the mentioned
Answer: a

3.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 mentionedAnswer: a
Clarification: None.
2. Kernel objects are exported as _____ via sysfs.
a) regular files
b) symbolic links
c) directories
d) none of the mentioned
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: None.
6. sysfs is based on
a) rootfs
b) ramfs
c) initramfs
d) none of the mentioned
Answer: b
Clarification: 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
Answer: a
Clarification: 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
Answer: d
Clarification: 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
Answer: b
Clarification: 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
Answer: a

1.1. Sysfs was originally called


a) device driver filesystem
b) kernel interface filesystem
c) kernel filesystem
d) none of the mentioned
Answer: a
Clarification: 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
Answer: d
Clarification: 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
Answer: a
Clarification: None.
4. The files of sysfs contains the information about
a) devices and drivers
b) memory mapping
c) ports
d) none of the mentioned
Answer: a
Clarification: 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
Answer: b
Clarification: None.
6. In linux sysfs is always mounted at
a) /sys
b) /proc/sys
c) /proc/mounts
d) none of the mentioned
Answer: a
Clarification: None.
7. Libsysfs is a
a) user space library
b) kernel space library
c) not a library
d) none of the mentioned
Answer: a
Clarification: None.
8. Sysfs represents the
a) kernel objects
b) libraries
c) api
d) none of the mentioned
Answer: a
Clarification: None.
9. Sysfs does not contains
a) regular files
b) symbolic links
c) directories
d) none of the mentioned
Answer: d
Clarification: 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
Answer: b

Linux Operating System MCQ pdf Questions and Answers


1. Files normally exist in physical storage devices such as CD-ROMS, hard drives or floppy disks.
(True/False)
Ans. True

2. Hard drives are divided into separate storage spaces called ___.
a) Buffer
b) Cache
c) Partitions
d) VFS
Ans. c) Partitions

3. The Preferences menus on GNOME and KDE exhibit similar desktop configuration tools.
(True/False)
Ans. False. The Preferences menus on GNOME and KDE exhibit different variety of desktop
configuration tools.

4. ___ provides fundamental window functions and skins for a configurable appearance and feel.
Ans. Metacity

5. KDE (K Desktop Environment) is written in C++ and developed on the ___ library.
Ans. Qt toolkit
6. The X Window system was the outcome of research attempts in the early 1980s at Stanford
University and MIT, assisted by IBM, to create a ___ protocol.
Ans. Platform-independent graphics

7. The window may be a ___ where the user executes standard Unix commands or X client
applications such as a web browser, xcalc calculator, or an Emacs session.
Ans. Terminal window

8. Name the three major elements that Xorg Foundation supplies.


Ans. Client programs, X server, and documentation

9. Xorg applications and servers are installed in the ___ directory.


a) /usr/X11R6/lib
b) /usr/bin
c) /usr/include/x11
d) /usr/share/x11
Ans. b) /usr/bin

10. Although it is possible to create and edit the configuration file directly, it is preferable to use the
distribution’s display configuration tool. (True/False)
Ans. True

11. The window manager program handles user logins and provides authentication and beginning
sessions. (True/False)
Ans. False. The X Display manager program handles user logins and provides authentication and
beginning sessions.

12. An original window manager that does not share code with others is ___.
Ans. Blackbox
13. Files like ___ configure how the dialog box is displayed, and ___ helps the user to indicate a root-
window image or other windows to display.
Ans. Xresources and Xsetup

14. Widgets are designed to work independently of the application except through precise interactions,
called as ___ functions.
Ans. Callback

15. A recent, full-featured widget library that has developed as an industry standard is X Toolkit.
(True/False)
Ans. False. A recent, full-featured widget library that has developed as an industry standard is Motif.

16. Tk (tee-kay, libtk.so) is a library that is mainly applied with the ___ language.
Ans. Tcl scripting

17. Identify the widget set that offers a simple choice of basic user interaction components?

a) GTK+
b) Qt
c) LessTif
d) Athena
Ans. d) Athena

18. The RPM packages with source codes will have an extension of ___.
a) .gz
b) .tgz
c) .src.rpm
d) .tar
Ans. c) .src.rpm

19. The process of connecting a file system to a particular directory in order to access files on a storage
device is called ___.
Ans. Mounting the file system
20. The Linux software packages provide all the files required for installing an application in different
___.
Ans. Modules

21. Any Web browser can behave like an FTP client but such programs are suitable for ___ FTP
downloads.
Ans. Anonymous

22. A ___server is required to access Usenet news.


Ans. News

23. The distributions like Debian and Ubuntu are provided with the___ service.
Ans. Blackdown

24. The safest way to use JPackage is to download its Java 2 Software Development Kit repository
configuration file. (True/False)
Ans. False. The safest way to use JPackage is to download its Yellowdog Updater, Modified (YUM)
repository configuration file.

25. Web browsers are used instead of mail clients to access the services provided by the Web-based
Internet mail services. (True/False)
Ans. True

26. Generally, the digital signature is appended at the ___ of the message.
Ans. End

27. The most important type of SSH connection is a ___.


Ans. Remote login

28. Proxies help to control access to some services such as the Web or FTP servers. (True/False)
Ans. True

29. The EncFS uses the ___ library and Linux kernel module to create the filesystem interface.
Ans. FUSE
30. The ___ command helps you to maintain packages, query them, create your own, and verify the
packages which you have.
Ans. rpm

31. Identify the software package that helps to install Microsoft Office applications in the Linux
system.
a) CrossOver Office
b) Informix
c) GNU SQL
d) MySQL
Ans. CrossOver Office

32. PostgreSQL is used as the query language for SQL. (True/False)


Ans. False. SQL is used as the query language for PostgreSQL.

33. Informix is an open-source database application. (True/False)


Ans. False. Informix is a commercial product.

34. DigiKam is a ___ tool.


Ans. Photo management

35. A ___ is essential to play an audio CD.


Ans. Sound card

36. The graphical software package used to display PostScript files or PDF documents is GGv.
(True/False)
Ans. True

37. Linux news clients allow reading newsgroup postings, either in___ or ___ mode.
Ans. Graphically, Text

38. The inventor of Linux is ___.


a. Gary Kildall
b. Linus Torvalds
c. Dennis Ritchie
d. Ken Thompson
Ans. b
39. Which of the following directory contains files such as Grub or Lilo, the Kernel, initrd and system.
map config files?
a. /bin
b. /sbin
c. /boot
d. /dev
Ans. c

40. The ___ command can be used to display contents present in directories.
a. ls
b. ps
c. cd
d. pwd
Ans. a

41. Identify the shell command used to create or list command shortcuts.
a. HISTFILE
b. History
c. Alias
d. Export
Ans. c

42. Which of the following set built-in command is used to read commands but not to execute them?
a. set -m
b. set –n
c. set -t
d. set -h
Ans. b

43. The ___ variable indicates the user’s current working directory.
a. PATH
b. CDPATH
c. HOME
d. PWD
Ans. d

44. Linux is considered a fully functional ___ operating system.


A) Unix
B) Windows
C) DOS
D) MacOS
Ans. a

45. A ___ is a special program that can control a specific type of hardware.
A) Shell
B) Device driver
C) Complier
D) Database
Ans. b

46. ___ is a computer program that translates source code to object code.
A) Translator
B) Boot loader
C) Compiler
D) Interpreter
Ans. c

47. ___ directory has system configuration files, network configuration files, application configuration
files and other installed software.
A) /var
B) /mnt
C) /opt
D) /etc
Ans. c

48. ___ is an open-source Unix shell that is embedded within the Scheme programming language.
A) csh
B) ksh
C) scsh
D) tcsh
Ans. c

49. Which among the following is the command that displays advanced file attributes? .
A) lsattr
B) mkdir
C) chattr
D) lpr
Ans. a

50. Name the init level which represents the Single user mode with networking. .
A) 0
B) 3
C) 6
D) 2
Ans. d

51. The ___ of GNOME’s user admin tool helps to define the user account settings. .
A) Advanced panel
B) User privileges
C) Account properties
D) New user accounts
Ans. a

52. The tree structure of the Linux file system may vary based on the ___
A) System user
B) Hardware devices
C) System directories
D) System administrator
Ans. d

53. ___ command is used to remove a module from the kernel.


A) insmod
B) rmmod
C) depmod
D) rvmod
Ans. b

54. Hard drives are divided into separate storage spaces called ___.
A) Buffer
B) Cache
C) Partitions
D) VFS
Ans. c
55. All the partitions are usually connected to the system through the ___
A) Mount point
B) Directories
C) Links
D) File system
Ans. a

56. To read in a new file starting at the present location, the ___ command is used.
A) :q
B) :wq
C) :r
D) :q!
Ans. c

57. A collection of records is known as ___.


A) Fields
B) Database file
C) Function
D) Attribute
Ans. b

58. ___ command is used to read the sed command from the sed script file.
A) -e
B) -f
C) -n
D) e
Ans. b

59. Identify the widget set that offers a simple choice of basic user interaction components?
A) GTK+
B) Qt
C) LessTif
D) Athena
Ans. d

60. Xorg applications and servers are installed in the ___ directory.
A) /usr/X11R6/lib
B) /usr/bin
C) /usr/include/x11
D) /usr/share/x11
Ans. b

61. Which among the following is the system variable that indicates the name of the user’s computer?
A) BASH_VERSION
B) HOSTNAME
C) CDPATH
D) HISTFILE
Ans. b

62. ___ is an online description of an interactive shell command, system interface, or system object.
A) Manpage
B) NAT
C) PTP
D) SSL
Ans. a

63. Which of the following tools allow modifying the existing images?
A) Display
B) Creation
C) Manipulate
D) Conversion
Ans. c

64. ___ directory includes Kernel, Firmware, and system-related files and ___ the directory contains
system commands and programs called binaries that are needed during bootup.
A) /sys and /bin
B) /boot and /sbin
C) /bin and /sbin
D) /lib and /mnt
Ans. a

65. ___ refers to the configuration of the partition and ___ refers to the hard drive device that is
mounted.
A) Partition, format
B) Format, partition
C) Directory,partition
D) Format,directory
Ans. b

66. Files like ____ configure how the dialog box is displayed, and _____ helps the user to indicate a
root-window image or other windows to display.
A) Xresources and Xsetup
B) Xstartup and Xresource
C) .xsession and .Xauthority
D) Xsetup and Xdm-config
Ans. a

67. Linux news clients allow reading newsgroup postings, either in ____ or _____ mode.
A) Graphically, Text
B) Graphically, sound
C) Text,sound
D) Video, sound
Ans. a

68. The EncFS uses the ____ library and Linux kernel module to create the filesystem interface.
A) FUSE
B) End
C) Module
D) Xbase
Ans. a

69. ____ is the process in which a network device like a firewall assigns a public address to a system
inside a private network.
A) Network Address Translation
B) Mandatory Access Control
C) Daemon
D) Manpage
Ans. a

70. When a system is running in full multiuser with networking mode, in which of the following run
levels is the system running?
a. Runlevel 1
b. Runlevel 2
c. Runlevel 0
d. Runlevel 3
Ans. d

71. For better security, passwords are now stored in the ___ file and only the root user can access this
file.
a. /etc/shadow
b. /etc/passwd
c. /etc/group
d. /etc/bash.bashrc
Ans. a

72. An application program accesses the module’s services with the help of ___ function.
a. cleanup_module()
b. module_ init()
c. module_exit()
d. printk()
Ans. b

73. The ___ command is used to display information about the partitions and their mount point.
a. cat
b. df
c. cd
d. ps
Ans. b

74. Which of the following is a startup script for the user session?
a. .xsession
b. Xstartup
c. Xsession
d. Xreset
Ans. c

75. Identify the X.org directory that deals with documentation.


a. /var/tmp
b. /usr/share/X11/doc
c. /etc/profile
d. etc/init.d/rcN.d
Ans. b
76. The ___ desktop environment serves as a default desktop environment for Red Hat Enterprise
Linux that is based on the GTK + 2 graphical toolkit.
a. KDE
b. Xfce
c. Openbox
d. GNOME
Ans. d

77. Identify which of the following options is a Linux mail client.


a. Firefox
b. Nautllus
c. Thunderbird
d. Konqueror
Ans. c

78. The Debian based Linux systems use a package management system that is based on a tool called
___.
a. RPM
b. dpkg
c. YUM
d. Portage
Ans. b

79. Which of the following is an FTP client?


a. Kontact
b. Evolution
c. Mutt
d. curl
Ans. d

80. Awk utility is a ___ programming language.


a. Object-oriented
b. Scripting
c. Structured
d. Procedural
Ans. B
1.
Which one of the following is not true?

A.) kobjects are included in a hierarchic organisation


B.) kobjects can have a parent
C.) kobjects can be included in a kset
D.) none of these
Answer: Option 'D'

none of these

2.
In sysfs.h which one of the following structure represents the directory entries?

A.) struct sysfs_dirent


B.) struct sysfs_dir
C.) struct sysfs
D.) none of these
Answer: Option 'A'

struct sysfs_dirent

3.
The name pointer of the attribute data structure represents the _____ in sysfs.

A.) directory
B.) file
C.) symbolic link
D.) none of these
Answer: Option 'B'

File
1.
Relationship between components of device driver models are expressed in the sysfs as

A.) a directory
B.) a regular file
C.) symbolic links between files and directories
D.) none of these
Answer: Option 'C'

symbolic links between files and directories

2.
What is the main role of the regular files in the sysfs?

A.) regular files represent the attributes of devices and drivers


B.) regular files represent the kernel objects
C.) regular files represent the kernel sets
D.) none of these
Answer: Option 'A'

regular files represent the attributes of devices and drivers

3.
The core data structure of device driver model is

A.) kobject
B.) kfile
C.) kmodule
D.) none of these
Answer: Option 'A'

kobject

4.
The kset contains

A.) pointer to subsystem descriptor


B.) pointer to the kobject type descriptor of the kset
C.) head of the kobjects included in the kset
D.) all of these
Answer: Option 'D'

all of these
5.
Which one of the following is a read-write semaphore in linux that protects all ksets and kobjects
included in the filesystem?

A.) rwsem
B.) rwsemaphore
C.) rws
D.) none of these
Answer: Option 'A'

rwsem

6.
Each device in the device driver model is represented by a _____ object.

A.) driver
B.) device
C.) node
D.) none of these
Answer: Option 'B'

device

7.
Each driver in the device driver model is described by a ______ object.

A.) dev_d
B.) device_d
C.) dev_driver
D.) device_driver
Answer: Option 'D'

device_driver

8.
The channel between the processor and devices is called?
A.) bus
B.) driver
C.) class
D.) none of these
Answer: Option 'A'

bus

9.
In which directory every kernel module of the system is represented?

A.) /sys/kernel
B.) /sys/module
C.) /sys/kernel/module
D.) none of these
Answer: Option 'C'

/sys/kernel/module

10.
In sysfs the device drivers of same _____ are expected to provide same functionalities to the user mode
application.

A.) class
B.) kobjects
C.) ksets
D.) none of these
Answer: Option 'A'

Class

1.
Sysfs is initialised in ______ file via sysfs_init function.

A.) fs/sysfs/mount.c
B.) sysfs/mount.c
C.) fs/mount.c
D.) none of these
Answer: Option 'A'

fs/sysfs/mount.c

2.
Kernel objects are exported as _____ via sysfs.

A.) regular files


B.) symbolic links
C.) directories
D.) none of these
Answer: Option 'C'

directories

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 these
Answer: Option 'A'

kobjects

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 these
Answer: Option 'A'

regular files
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 these
Answer: Option 'B'

its own attribute structure

6.
sysfs is based on

A.) rootfs
B.) ramfs
C.) initramfs
D.) none of these
Answer: Option 'B'

ramfs

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 these
Answer: Option 'A'

hotplug event

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 these
Answer: Option 'D'

all of these

9.
A ____ is a higher level view of a device that abstracts out low level implementation details/

A.) inode
B.) class
C.) major number
D.) minor number
Answer: Option 'B'

class

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 these
Answer: Option 'A'

files and directories of that device in the sysfs are removed automatically

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 these
Answer: Option 'A'

are created at system startup when the subsystems register themselves with kobject core

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 these
Answer: Option 'A'

sub-directories for each block device

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 these
Answer: Option 'B'

devices and drivers

4.
A device class describes the ____ type of device.

A.) physical
B.) stuctural
C.) functional
D.) none of these
Answer: Option 'C'

functional
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 these
Answer: Option 'A'

/sys/devices

6.
Which type of devices are peripheral devices?

A.) platform devices


B.) system devices
C.) both system and platform devices
D.) none of these
Answer: Option 'B'

system devices

7.
Which one of the following is not a system device?

A.) CPU
B.) APIC
C.) Timer
D.) None of these
Answer: Option 'D'

None of these

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 these
Answer: Option 'D'

none of these

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 these
Answer: Option 'D'

all of these

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 these
Answer: Option 'A'

internal header files for sysfs

1.
Sysfs was originally called

A.) device driver filesystem


B.) kernel interface filesystem
C.) kernel filesystem
D.) none of these
Answer: Option 'A'

device driver filesystem

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 these
Answer: Option 'D'

all of these

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 these
Answer: Option 'A'

kernel’s device model

4.
The files of sysfs contains the information about

A.) devices and drivers


B.) memory mapping
C.) ports
D.) none of these
Answer: Option 'A'

devices and drivers


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 these
Answer: Option 'B'

some files of the sysfs are writable for configuration of devices

6.
In linux sysfs is always mounted at

A.) /sys
B.) /proc/sys
C.) /proc/mounts
D.) none of these
Answer: Option 'A'

/sys

7.
Libsysfs is a

A.) user space library


B.) kernel space library
C.) not a library
D.) none of these
Answer: Option 'A'

user space library

8.
Sysfs represents the
A.) kernel objects
B.) libraries
C.) api
D.) none of these
Answer: Option 'A'

kernel objects

9.
Sysfs does not contains

A.) regular files


B.) symbolic links
C.) directories
D.) none of these
Answer: Option 'D'

none of these

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 these
Answer: Option 'B'

major subsystems that are registered with sysfs

LDD MCQ
1. The major number identifies the associated with the device.
a) driver
b) protocol
c) port
d) none of the mentioned

2. The minor number range should be


a) 0 to 15
b) 0 to 63
c) 0 to 255
d) none of the mentioned

3. Which one of the following is not true?


a) dynamic allocation of major numbers is not possible
b) major number cannot be shared among drivers
c) dynamic allocation of major numbers is not possible & also major number
cannot be shared among drivers
d) none of the mentioned

4. In linux kernel 2.4, we can have


a) 256 character drivers only
b) 256 block drivers only
c) 256 character drivers and 256 block drivers at the same time
d) none of the mentioned

5. we use a driver for N number of files, then we have to create device files.
a) N
b) 1
c) N-1
d) None of the mentioned

6. If we use a driver for various device files, then


a) minor number will be different for every device file
b) minor number will be same for every device file
c) minor number can not be allocated for any device file
d) none of the mentioned

7. The connection between the device file and device driver is based on the
a) name of device file
b) number of device file
c) name & number of device file
d) none of the mentioned
8. In linux kernel 2.1, the minor numbers were used to
a) represent the sub-functionalities of the driver
b) identify the driver
c) represent the device files
d) none of the mentioned

9. The kernel identifies the driver with its


a) module
b) major number
c) device file
d) none of the mentioned

10. In linux, a device driver can work without the


a) major number
b) minor number
c) device file name
d) none of the mentioned

11. Sysfs was originally called


a) device driver filesystem
b) kernel interface filesystem
c) kernel filesystem
d) none of the mentioned

12. 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

13. 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

14. The files of sysfs contains the information about


a) devices and drivers
b) memory mapping
c) ports
d) none of the mentioned
15. 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

16. In linux sysfs is always mounted at


a) /sys
b) /proc/sys
c) /proc/mounts
d) none of the mentioned

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

18. Sysfs represents the


a) kernel objects
b) libraries
c) api
d) none of the mentioned

19. Sysfs does not contains


a) regular files
b) symbolic links
c) directories
d) none of the mentioned

20. 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

21. 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
22. 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

23. 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

24. A device class describes the type of device.


a) physical
b) structural
c) functional
d) none of the mentioned

25. 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

26. Which type of devices are peripheral devices?


a) platform devices
b) system devices
c) both system and platform devices
d) none of the mentioned

27. Which one of the following is not a system device?


a) CPU
b) APIC
c) Timer
d) None of the mentioned

28. 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
29. 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

30. 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

31. Sysfs is initialised in file via sysfs_init function.


a) fs/sysfs/mount.c
b) sysfs/mount.c
c) fs/mount.c
d) none of the mentioned

32. Kernel objects are exported as via sysfs.


a) regular files
b) symbolic links
c) directories
d) none of the mentioned

33. 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

34. 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

35. 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
36. sysfs is based on
a) rootfs
b) ramfs
c) initramfs
d) none of the mentioned

37. 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

38. 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

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

40. 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

41. Relationship between components of device driver models are expressed in the
sysfs as
a) a directory
b) a regular file
c) symbolic links between files and directories
d) none of the mentioned

42. What is the main role of the regular files in the sysfs?
a) regular files represent the attributes of devices and drivers
b) regular files represent the kernel objects
c) regular files represent the kernel sets
d) none of the mentioned
43. The core data structure of device driver model is
a) kobject
b) kfile
c) kmodule
d) none of the mentioned

44. The kset contains


a) pointer to subsystem descriptor
b) pointer to the kobject type descriptor of the kset
c) head of the kobjects included in the kset
d) all of the mentioned

45. Which one of the following is a read-write semaphore in linux that protects all
ksets and kobjects included in the filesystem?
a) rwsem
b) rwsemaphore
c) rws
d) none of the mentioned

46. Each device in the device driver model is represented by a object.


a) driver
b) device
c) node
d) none of the mentioned

47. Each driver in the device driver model is described by a object.


a) dev_d
b) device_d
c) dev_driver
d) device_driver

48. The channel between the processor and devices is called?


a) bus
b) driver
c) class
d) none of the mentioned

49. In which directory every kernel module of the system is represented?


a) /sys/kernel
b) /sys/module
c) /sys/kernel/module
d) none of the mentioned
50. In sysfs the device drivers of same are expected to provide same
functionalities to the user mode application.
a) class
b) kobjects
c) ksets
d) none of the mentioned

51. Which one of the following is not system V IPC?


a) Shared Memory
b) Message Queues
c) FIFO
d) Semaphores

52. Which of the following verifies that user space buffer can be read/write in kernel
space code?
a) copy_from_user()
b) copy_to_user()
c) access_ok()
d) None of these

53. what is not true for private_data?


a) private_data is void pointer in struct inode.
b) private_data is void pointer in struct file.
c) private_data keeps driver specific information.
d) private_data must be initialized in open() operation to make driver functioning.

54. How can you view the used IRQs on a system?


a) cat /etc/interrupts
b) cat /proc/irq
c) cat /proc/interrupts
d) echo 1 > /proc/interrupts

55. The first argument of printk() indicates


a) message suffixed by priority string
b) message prefixed by priority string
c) type of kernel message logger
d) None of the above

56. why we cann't use C standard library function in kernel module?


a) kernel modules are dynamically linked during insmod.
b) kernel modules are statically linked during insmod.
c) kernel modules are dynamically linked during module builds.
d) kernel modules are statically linked during module builds.
57. what is use of container_of() macro?
a) Used to access struct member from given address of struct variable.
b) Used to access struct variable from given address of structure member.
c) Used to access container process in which given thread is running.
d) None of the above

58. An interrupt handler can be registered by using the function


a) request _irq
b) request_region
c) request_mem_region
d) request_irq_region

59. All the details about the module like author, version etc can be viewed by using
utility
a) lsmod
b) modprobe
c) dmesg
d) modinfo

60. which function is used to allocated memory for buffer of the USB.
a) usb_alloc_buffer()
b) usb_buffer_alloc()
c) usb_alloc()
d) usb_alloc_urb()

61. which of the following is externel tool for debugging?


a) Probe
b) LTI
c) Kgdb
d) None of the above

62. which of the following registers cdev with kernel?


a) cdev_init()
b) cdev_add()
c) cdev_del()
d) None of the above

63. which macro is used to add kernel module functions to kernel symbol
table?select one:
a) MODULE_EXPORT()
b) EXPORT_SYMBOL()
c) EXPORT_KERNEL()
d) EXPORT_FUNCTION()
64. "kernel is tained" message will be produced when the module is inserted
without
a) MODULE_LICENSE
b) MODULE_AUTHOR
c) MODULE_VERSION
d) MODULE_DESCRIPTION

65. 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

66. Choose the incorrect statement


a) ioctl is a common interface used for device control
b) The implementation of ioctl is mostly done using a switch statement based on the
command number
c) The macro _IOR(type,nr,datatype) can be used to setup a ioctl command
number with no arguments
d) The ioctl funtion has the format long ioctl(structure file *flip, unsigned int cmd,
unsigned long arg)

67. All I/O memory allocations are listed in


a) /proc/iomem
b) /proc/ioports
c) /proc/meminfo
d) /proc/mem

68. which of the following function is use to wake up a task from wait queue in case
of spinlock?
a) wake_up(&wq)
b) wake_up_interruptible
c) wake_spinlock(&wq)
d) none of the above

69. is used to add a character device to a system


a) cdevAdd()
b) cdevc_add()
c) cdev_add()
d) add_cdev()
70. The function which is used to allocate and initialize a character device
a) int register_chrdev_region();
b) void chdev_init();
c) int unregister_chrdev_region();
d) int register_chrdev();

71. Which of the following should be avoided in the interrupt handlers?


a) calling wait_event/allocating memory
b) calling scheduler
c) locking a semaphore
d) all of the above

72. EXPORT_SYMBOL is used for


a) export symbols to other modules
b) export symbols and hide it from other modules
c) get symbols from other modules

73. To send the external command to a device operation is used.


a) send file
b) ioctl
c) send page
d) none of the above

74. In a module if its license is not explicitly specified its default license would be
a) GPL
b) GPLV2
c) Dual BSD/GPL
d) Proprietary

75. The devices that can host a filesystem


a) character device
b) block devices
c) network interfaces
d) none of the above

76. which of the following bottom half mechanism can sleep or can be scheduled?
a) softirq
b) tasklet
c) work queue
d) None of the above
77. Which of the following functions is used for I/O port allocation?
a) request_region();
b) check_region();
c) register_io_region();
d) alloc_io_region();

78. In which method of a character driver should the functions 'cdev_init' and
'cdev_add' be called? Choose the most appropriate answer?
a) module init function and module open function respectively
b) both in module init function
c) both in open function
d) none of the above

79. The loglevel strings in printk are defined in the header file
a) <linux/module.h>
b) <linux/init.h>
c) <linux/kernel.h>
d) <linux/fs.h>

80. Select correct option


cdev_add() create a device node under /dev
cdev_init() associates major and minor numbers with device file
cdev_add() make device entry in sysfs
a) only i is correct
b) i and ii is correct
c) i and iii is correct
d) All are correct

81. kfifo_free() is used to .


a) Release statically allocated fifo
b) Release dynamically allocated fifo
c) Both of the above
d) None of the above

82. If we use a driver for various device files, then


a) Minor number will be different for every device file
b) Minor number will be same for every device file
c) Minor number can't be allocated for any device file
d) None of the above
83. The device number which is of 32 bit and consist of bits for major and
bits for minor.
a) 21, 11
b) 11, 21
c) 20, 12
d) 12, 20

84. structure used by the kernel internally to represent files


a) mknode
b) inode
c) structdev
d) None of the above

85. In Linux device driver which keyword used to allocate memory


a) malloc
b) dmalloc
c) lmalloc
d) kmalloc

86. Inb&outb are used to read and write


a) 8bytes
b) 1 bit
c) a block
d) 8 bits

87. what does mean unsigned long probe_irq_on(void):


a) This function returns a bit mask of unasigned interrupts
b) This function has requested an interrupts
c) This function has used by driver calls
d) This function returns a negative value

88. In dev_t major number is of bits.


a) 20
b) 12
c) 19
d) None of the above

89. inb(), inw(), inl() are used to access devices.


a) True
b) False
90. Which of the following is not member of struct file_operation{}?
a) fopen()
b) fread()
c) remove()
d) All of the above
e) None of the above

You might also like