Linux/Unix Operating Systems Commands and Shell Scripting

Test your knowledge of Linux/Unix operating systems commands, file operations, process management, and shell scripting basics.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

In vi if we want to replace any string e.g. "NAME" with "name" from line number 1 to 10 only, what command we can use?

  1. :%s/NAME/name/
  2. :1-10s/NAME/name/
  3. :1,10s/NAME/name/
  4. :s/NAME/name/
Question 2 Multiple Choice (Single Answer)

How to check the exit status of the previous command?

  1. $?
  2. $$
  3. $#
  4. $@
Question 3 Multiple Choice (Single Answer)

what is the command to change ownership of a file?

  1. change
  2. setfscl
  3. chown
  4. chmod
Question 4 Multiple Choice (Single Answer)

echo this || echo that && echo other What will be the output?

  1. this
  2. that
  3. this other
  4. this that other
Question 5 Multiple Choice (Single Answer)

How could you check if two strings are equal?

  1. test $a -eq $b
  2. test a -eq b
  3. test $a -equal $b
  4. test $a = $b
Question 6 Multiple Choice (Single Answer)

Which of the following would return the process ID of the sleep command?

  1. sleep 1 & echo $!
  2. sleep 1 & echo $?
  3. sleep 1 & echo $#
  4. sleep 1 & echo $$
Question 7 Multiple Choice (Single Answer)

Which command will create a soft link to a file?

  1. ls -n
  2. ln
  3. ln -s
  4. link -s
Question 8 Multiple Choice (Single Answer)

How to search recursively in the directory structure to list the file named file1?

  1. ls -lrt file1
  2. ls -lR file1
  3. find . -s file1
  4. find . -name file1
Question 9 Multiple Choice (Single Answer)

How can you determine the number of positional parameter passed to the script ?

  1. $# will print the same
  2. $? will print the same
  3. $! will print the same
  4. $$ will print the same
Question 10 Multiple Choice (Single Answer)

"What will be the output of following command var=hello varx=goodbye echo ${var}x"

  1. goodbye
  2. hello
  3. hellox
  4. hellogoodbye
Question 11 Multiple Choice (Single Answer)

How can we know two text files are identical?

  1. if the output of “cmp -s file1 file2” is not zero
  2. if the output of “cmp -s file1 file2” is zero
  3. if the output of “cmp -s file1 file2” is one
  4. if the output of “cmp -diff file1 file2” is zero
Question 12 True/False

The purpose of the nohup command is to prevent programs from closing when you log out. True or False?

  1. True
  2. False
Question 13 Multiple Choice (Single Answer)

Which one of the following PIDs is assigned to the init program?

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

How can the time stamps of a file be preserved while copying a file?

  1. cp -i
  2. cp -r
  3. cp -p
  4. cp -R
Question 15 Multiple Choice (Single Answer)

How to send a running process to background?

  1. ctrl+c then bg
  2. ctrl+z then bg
  3. ctlr+m then bg
  4. ctrl+z then fg
Question 16 Multiple Choice (Single Answer)

"what does the command do? find . -type f -mtime 2"

  1. list all ordinary files in current dir that have been modified within last 24 hours
  2. list all ordinary files in current dir that have been modified within last 4 days
  3. list all ordinary files in current dir that have been modified within last 48 hrs
  4. list all ordinary files in current dir that have been modified within last 2 hrs
Question 17 Multiple Choice (Single Answer)

what is the name of the data structure to maintain file identification?

  1. inode
  2. filter
  3. kernel
  4. shell
Question 18 Multiple Choice (Single Answer)

How to save the output of any command in a file as well as display the same on the VDU?

  1. echo “hello world” > temp.txt
  2. echo “hello world” | tee temp.txt
  3. echo "hello world">tmp.txt|tee tmp.txt
  4. echo "hello world">tmp.txt|print
Question 19 Multiple Choice (Single Answer)

Which of the following will list the directories from the current working path.

  1. ls -l | grep ^d
  2. ls | grep dir
  3. ls | grep ^d
  4. pwd
Question 20 Multiple Choice (Single Answer)

How can you print the first 10 line of a file

  1. head +10 file
  2. cat file
  3. tail -10 file
  4. head -10 file