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

Linux MCQ Set 1

1. Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo

View Answer

Answer: b [Reason:] None.

2. What is the function of bind command in bash shell?
a) defining new macros
b) defining new key bindings for existing commands
c) dumping the installed key bindings
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

3. The command ‘compgen -c’ shows
a) all variable names
b) all system wide aliases
c) full list of all commands
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

4. Which statement resumes the next iteration of a for, while, select, or untill loop?
a) continue
b) break
c) complete
d) command

View Answer

Answer: a [Reason:] None.

5. Which command prints the directory stack?
a) cd
b) dirs
c) popd
d) pushd

View Answer

Answer: b [Reason:] None.

6. The command ‘disown -r’
a) removes all jobs
b) removes all running jobs
c) marks jobs to not receive SIGHUP when bash exits
d) marks all jobs

View Answer

Answer: b [Reason:] None.

7. The command ‘enable -n ‘
a) enables the specified built-in command
b) disables the specified built-in command
c) print the status of the command
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

8. Which command can create environment variable?
a) export
b) set
c) read
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

9. Which command concatenate the specified argument into a single command, then execute the command?
a) fc
b) eval
c) exec
d) getopts

View Answer

Answer: b [Reason:] None.

10. The command ‘hash’
a) manages a internal hash table
b) find and remember the full path name of the specified command
c) displays used command names and the number of hits
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

Linux MCQ Set 2

1. The ‘logout’ built in command is used to
a) shutdown the computer
b) logoff of the computer
c) logout the current user
d) to exit the current shell

View Answer

Answer: d [Reason:] None.

2. The command ‘umask -S’
a) prints the current mask using symbolic notation
b) prints the current mask using octal numbers
c) sets the mask to 000
d) sets the mask to 777

View Answer

Answer: a [Reason:] None.

3. The ‘mapfile’ command
a) reads lines of standard input and assigns each to the element of an indexed array
b) reads lines of standard output file
c) reads lines of standard error file
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

4. Which option of the kill command sends the given signal name to the specified process?
a) -l
b) -n
c) -s
d) -a

View Answer

Answer: c [Reason:] None.

5. Which command removes a directory from directory stack?
a) dirs
b) popd
c) pushd
d) rm

View Answer

Answer: b [Reason:] None.

6. Which command puts a script to sleep untill a signal is recieved?
a) sleep
b) suspend
c) disown
d) break

View Answer

Answer: b [Reason:] None.

7. The command ‘ulimit’
a) set a limit on specified resource for system users
b) set/show process resource limit
c) set a limit on specified resource for system users & set/show process resource limit
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

8. Which command identifies the resource of a command?
a) type
b) typeset
c) select
d) source

View Answer

Answer: a [Reason:] None.

9. Which command wait for the specified process to complete and return the exit status?
a) sleep
b) wait
c) delay
d) stop

View Answer

Answer: b [Reason:] None.

10. Which command prints the accumulated user and system times for processes run from the shell?
a) time
b) times
c) both time and times
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 3

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

View Answer

Answer: a [Reason:] None.

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

View Answer

Answer: d [Reason:] None.

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

View Answer

Answer: a [Reason:] None.

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

View Answer

Answer: a [Reason:] None.

5. After running this program, as you press ‘s’, what will be the output of the program?

  1.    #!/bin/bash
  2.    echo "press 's' to print Aidlo"
  3.    read var
  4.    if $var=s
  5.    then
  6.    echo "Aidlo"
  7.    else
  8.    echo "You did not press s"
  9.    fi
  10.    exit 0

a) Sanfoudry
b) You did not press s
c) Program will generate an error message
d) None of the mentioned

View Answer

Answer: c [Reason:] The condition of if statement must be in square brackets. Output: :/home/aidlo#./test.sh press ‘s’ to print Aidlo s ./test.sh: line 4: s=s: command not found You did not press s

6. After running this program, as your press 4, what will be the output of the program?

  1.    #!/bin/bash
  2.    echo "How many times you want to print 'Aidlo'"
  3.    read value
  4.    for ((i=0;i<$value;i++))
  5.    do
  6.    echo "Aidlo";
  7.    done
  8.    exit 0

a) ‘Sanfoudry’ will print 4 times
b) ‘Sanfoudry’ will print 3 times
c) ‘Sanfoudry’ will print 5 times
d) Program will generate an error message

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh How many times you want to print ‘Aidlo’ 4 Aidlo Aidlo Aidlo Aidlo :/home/aidlo#

7. What is the output of this program?

  1.    #!/bin/bash
  2.    for i in 2 3 7
  3.    do
  4.    echo "Aidlo"
  5.    done
  6.    exit 0

a) ‘Aidlo’ will print 3 times
b) Nothing will print
c) Program will generate an error message
d) None of the mentioned

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh Aidlo Aidlo Aidlo :/home/aidlo#

8. How can you come out of the loop in this program?

  1.    #!/bin/bash
  2.    read x
  3.    while [ $x != "hello" ]
  4.    do 
  5.    echo "Try to come out of the loop"
  6.    read x
  7.    done
  8.    echo "Welcome"
  9.    exit 0

a) by entering “hello”
b) by entering anything except “hello”
c) it is not possible
d) none of the mentioned

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh hi Try to come out of the loop hey Try to come out of the loop hello Welcome :/home/aidlo#

9. What is the output of this program?

  1.    #!/bin/bash
  2.    echo "Which file do you want to check"
  3.    read x
  4.    until [ -e $x ]
  5.    do 
  6.    echo "The file does not exist. Do you want to create? y/n"
  7.    read a
  8.    if [ $a = y ]; then  
  9.    touch $x
  10.    echo "Your file has been created successfully."
  11.    fi
  12.    done
  13.    echo "The file is present in this directory"
  14.    exit 0

a) it checks the existance of your entered file in the present working directory
b) it creates the file if file does not exists
c) program runs untill you create the file
d) all of the mentioned

View Answer

Answer: d [Reason:] None. Output: :/home/aidlo# ./test.sh Which file do you want to check san.c The file does not exist. Do you want to create? y/n n The file does not exist. Do you want to create? y/n n The file does not exist. Do you want to create? y/n y Your file has been created successfully. The file is present in this directory :/home/aidlo# ls san.c test2.txt test2.txt~ test.sh test.sh~ test.txt test.txt~ :/home/aidlo#

10. After running this program, if you enter 1000, then what will be the output of the program?

  1. 	#!/bin/bash
  2. 	echo "Please enter a number"
  3. 	read a
  4. 	if [ $a -lt 100 ]; then
  5. 	echo "It is less than 100"; 
  6. 	elif [ $a -lt 1000 ]; then
  7. 	echo "It is less than 1000"
  8. 	else 
  9. 	echo "It is greater than 1000"
  10. 	fi
  11. 	exit 0

a) It is greater than 1000
b) It is less then 1000
c) It is equal to 1000
d) None of then mentioned

View Answer

Answer: a [Reason:] None. Output: :/home/aidlo# ./test.sh Please enter a number 1000 It is greater than 1000 :/home/aidlo#

Linux MCQ Set 4

1. The correct sequence of GCC compilation process is
a) preprocessing -> compilation -> assemble -> linking
b) assemble -> preprocessing -> compilation -> linking
c) preprocessing -> assemble -> compilation -> linking
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

2. The preprocessor removes the _______ from the source code.
a) comments
b) header files
c) both comments and header files
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

3. The compiler converts
a) assembly code into machine code
b) preprocessed source code into assembly code
c) machine code into assembly code
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

4. The assembly code is converted into the machine code by
a) compiler
b) assembler
c) linker
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

5. What is the role of linker in the compilation process?
a) linker links the object code with the library code
b) linker converts machine code into executable machine code
c) linker generates an executable file
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

6. If aidlo.c is compiled with GCC, then the aidlo.s file will contain the
a) assembly code
b) machine code
c) preprocessed code
d) expanded source code

View Answer

Answer: a [Reason:] None.

7. The object file contains the
a) assembly code
b) machine code
c) modified source code
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

8. If we do not specify the executable file name at the compilation time in GCC, then in linux the compiler creates executable named as
a) a.out
b) a.exe
c) x.out
d) x.exe

View Answer

Answer: a [Reason:] None.

9. The macros specifies in source code are expanded by
a) preprocessor
b) assembler
c) compiler
d) linker

View Answer

Answer: a [Reason:] None.

10. The preprocessor creates the file with extension
a) .a
b) .i
c) .s
d) .o

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 5

1. The a.out file is in the
a) ELF format
b) EXE format
c) Both EXE and ELF format
d) None of the mentioned

View Answer

Answer: a [Reason:] None.

2. Which one of the following command can be used to provide executable permissions for a file?
a) chmod +x <filename>
b) chmod 777 <filename>
c) both chmod +x and chmod 777
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

3. The lines in our code that begin with the “#” character are
a) preprocessor directives
b) macros
c) header files
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

4. Command line parameters are passed by the
a) preprocessor
b) assembler
c) compiler
d) linker

View Answer

Answer: d [Reason:] None.

5. In the preprocessing stage of compilation
a) header files are actually expanded and included in the source code of the program
b) macros are replaced by their respective values
c) all the comments are stripped off
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

6. Which compilation step makes sure that all the undefined symbols in the code are resolved.
a) linking
b) compiling
c) preporcessing
d) none of the mentioned

View Answer

Answer: a [Reason:] An undefined symbol is one for which there is no definition available.

7. Which one of the following is not true?
a) we need to manually go through all intermediate stages to generate an executable in gcc
b) gcc compilation process always contains 4 stages
c) gcc compilation process always contains 3 stages
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

8. Preprocessed files are given the file extension _____ for c++ programs.
a) .i
b) .ii
c) .iii
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

9. The assmebly code generated depends upon the
a) processor archietecture
b) ram size
c) both processor archietecture and RAM size
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

10. The COFF stands for
a) common object file format
b) combined operation for file formats
c) combined object file format
d) none of the mentioned

View Answer

Answer: a [Reason:] None.