Linux and Shell Programming

Test on Linux/Unix and shell programming

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which command is used to set permissions like read, write, etc. on a file?

  1. useradd
  2. chmod
  3. changemode
  4. groupadd
  5. cat
Question 2 Multiple Choice (Single Answer)

The ___ command is used to display the path of the current directory.

  1. path
  2. ls
  3. mv
  4. cp
  5. pwd
Question 3 Multiple Choice (Single Answer)

Which of the following commands will print a sorted list of users on the screen?

  1. ls | more
  2. who | sort
  3. who | sort > list.txt
  4. who | wc -l
  5. who | grep STEVE
Question 4 Multiple Choice (Single Answer)

Which key(s) is/are used to delete a single character in Vi editor?

  1. nx
  2. dd
  3. G
  4. x
  5. u
Question 5 Multiple Choice (Single Answer)

Which directory contains all the executable files required during the booting process?

  1. /boot
  2. /etc
  3. /dev
  4. /bin
  5. /usr
Question 6 Multiple Choice (Single Answer)

Each 'if' statement in Linux must be closed with a matching

  1. end if
  2. else if
  3. else
  4. fi
  5. end
Question 7 Multiple Choice (Single Answer)

The _____ command executes the given command and stores the standard output of that command in to one or more files.

  1. wc
  2. tee
  3. top
  4. cal
  5. ln
Question 8 Multiple Choice (Single Answer)

Which of the following statements is the correct way of changing the user ID of a user named ABC to 555?

  1. usermod -u 555 ABC
  2. usermod -u ABC 555
  3. usermod 555 ABC
  4. usermod ABC -u 555
  5. useradd-u 555 jim
Question 9 Multiple Choice (Single Answer)

Which command is used to remove an existing environmental variable?

  1. delete
  2. remove
  3. unset
  4. free
  5. set
Question 10 Multiple Choice (Single Answer)

Which of the following statement is used to accept value from the user and store it in a variable?

  1. print
  2. read
  3. echo
  4. Input
  5. Get
Question 11 Multiple Choice (Single Answer)

Which of the following statements is false regarding user defined variables (UDV)?

  1. The name of a variable can start with an underscore.
  2. Variable names are case sensitive.
  3. Variable names must be unique.
  4. Variable declaration must start with the $ sign.
  5. Variable names can contain '?'.
Question 12 Multiple Choice (Single Answer)

Which of the following is not a valid shell script operator?

  1. -eq
  2. -ne
  3. -le
  4. -gt
  5. -mt
Question 13 Multiple Choice (Single Answer)

What will be the output of the above code?

i=5
while test $i != 0
do
echo "$i"
i=`expr $i - 1`
done

  1. 5 4 3 2 1
  2. 5 4 3 2 1 0
  3. 1 2 3 4 5
  4. 0 1 2 3 4
  5. 5
Question 14 Multiple Choice (Single Answer)

Which of the following is not a pre-defined AWK variable?

  1. FILENAME
  2. OFS
  3. EXIT
  4. NF
  5. NR
Question 15 Multiple Choice (Single Answer)

Which command is used to combine the contents of two files?

  1. merge
  2. comm
  3. sort
  4. join
  5. uniq
Question 16 Multiple Choice (Single Answer)

Which of the following statements is false regarding Shell?

  1. Shell provides user interface.
  2. Shell is a part of the system kernel.
  3. It is a command language interpreter.
  4. Several shells are available for Linux.
  5. Shell opens up automatically on log on.
Question 17 Multiple Choice (Single Answer)

Which of the following is not a part of the 'etc/passwd' file?

  1. Home directory
  2. Command/shell
  3. User ID (UID)
  4. Password
  5. Access Permissions
Question 18 Multiple Choice (Single Answer)

Which command is used to extract a column from a text file?

  1. cut
  2. paste
  3. tee
  4. tr
  5. man
Question 19 Multiple Choice (Single Answer)

Which permission allows you to modify the contents of a file?

  1. read
  2. write
  3. execute
  4. edit
  5. delete
Question 20 Multiple Choice (Single Answer)

Which of the following is not a communication command?

  1. grep
  2. mail
  3. mesg
  4. write
  5. ping
Question 21 Multiple Choice (Single Answer)

The head command writes the first ____ lines of a file on the screen.

  1. 10
  2. 1
  3. 5
  4. 20
  5. 15
Question 22 Multiple Choice (Single Answer)

Which form of the 'ls' command is used to display the list of hidden files?

  1. ls -a
  2. ls -l
  3. ls -f
  4. ls -r
  5. ls -lS
Question 23 Multiple Choice (Single Answer)

Which of the following is not a valid process signal with reference to the 'kill' command?

  1. SIGHUP
  2. SIGQUIT
  3. SIGINT
  4. SIGTSTP
  5. SIGBREAK
Question 24 Multiple Choice (Single Answer)

Which wild card character represents a range of characters during pattern search?

  1. *
  2. ?
  3. < >
  4. { }
  5. [ ]
Question 25 Multiple Choice (Single Answer)

What will be the output of the above code?

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
  1. Compilation error
  2. x
  3. 3
  4. 5
  5. y