Shell Script Quiz Questions With Answers

22 Questions | Attempts: 7717
Share

SettingsSettingsSettings
Shell Script Quiz Questions With Answers - Quiz

What do you know about Unix programming and shell scripting? Try this shell script quiz that includes questions with answers on this topic. Shell scripting is an open-source computer program created to be run by the Unix/ Linux shell. The program devises a series of plans for the shell to execute. The typical operations performed by Shell Scripting include file manipulation, program execution, and printing text. If you choose to learn more about Unix programming and shell scripting, try this quiz.


Questions and Answers
  • 1. 
    How can you append the output of a command to a file?
    • A. 

      Command > file

    • B. 

      Command >> file

    • C. 

      Command <> file

    • D. 

      Command < file

  • 2. 
    With what command you can see what folder you are in?
    • A. 

      Whereami

    • B. 

      Place

    • C. 

      Map

    • D. 

      Pwd

  • 3. 
    How do you delete a file?
    • A. 

      Rm filename

    • B. 

      Dl filename

    • C. 

      Touch filename

    • D. 

      Less filename

  • 4. 
    How do you get all files with on the 3rd place an r, g or i?
    • A. 

      Ls ?3[rgi]*

    • B. 

      Ls *[rgi]*

    • C. 

      Ls [..i*]

    • D. 

      Ls ??[rgi]*

  • 5. 
    What command do you have to use to go to the parent directory?
    • A. 

      Cd -

    • B. 

      Cd /up

    • C. 

      Cd ~

    • D. 

      Cd ..

  • 6. 
    With what command you can see your user name?
    • A. 

      Pwd

    • B. 

      I

    • C. 

      Whoami

    • D. 

      Me

  • 7. 
    With what can you stop a process?
    • A. 

      Kill

    • B. 

      Delete

    • C. 

      Stop

    • D. 

      Shutdown

  • 8. 
    What does the command ls do?
    • A. 

      Shows a calendar

    • B. 

      Display of files and folders, present in the folder where you are

    • C. 

      Opening a file

    • D. 

      Display of the contents of a file

  • 9. 
    What command is used to forward errors to a file?
    • A. 

      2> /dev/null

    • B. 

      &> filename

    • C. 

      1> filename

    • D. 

      2> filename

  • 10. 
    How can you display a list of all files, including the hidden files?
    • A. 

      Ls -a

    • B. 

      Find -a

    • C. 

      Find all

    • D. 

      All

  • 11. 
    How will you list only the empty lines in a file (using grep)?
    • A. 

      Grep “$^” filename.txt

    • B. 

      Grep “$” filename.txt

    • C. 

      Grep “^$” filename.txt

    • D. 

      Grep $^ filename.txt

  • 12. 
    How do you read arguments in a shell program?
    • A. 

      $0 would be the first line argument, $1 would be the Second command line argument, $2 the Third, and so on

    • B. 

      $1 would be the first command line argument, $2 the second, and so on $0 is the name of the script or function

    • C. 

      Both a and b are correct

    • D. 

      Both a and b are incorrect

  • 13. 
    Which of the following is NOT proper shell name?
    • A. 

      Csh : C shell

    • B. 

      Ksh : Korn Shell

    • C. 

      Bash : bourne again shell

    • D. 

      Ssh : sea shell

  • 14. 
    In Shell scripting What does does $? Return?
    • A. 

      $? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.

    • B. 

      $? will return exit status of command .Non-0 if command gets successfully executed ,zero if command failed.

    • C. 

      System error

    • D. 

      Invalid command

  • 15. 
    In Shell scripting What does $# stand for?
    • A. 

      Will return no of error

    • B. 

      # will return the number of parameters that are passed as the command-line arguments.

    • C. 

      Error

    • D. 

      All the above are incorrect

  • 16. 
    In Shell scripting what is  $*?
    • A. 

      Its mainly used for showing up all params. This show few parameter values passed in shell script.

    • B. 

      Its mainly used for showing up all params. This show all values returned.

    • C. 

      Its mainly used for showing up all params. This show all parameter values passed in shell script.

    • D. 

      None of the above is correct.

  • 17. 
    How can you get/set an environment variable from a program?
    • A. 

      Getenv() and putenv()

    • B. 

      Getenv() and setenv()

    • C. 

      Readenv and putenv()

    • D. 

      Readenv() and setenv()

  • 18. 
    To change mode of myfile to 'rwxr–r–'  , the command used is
    • A. 

      Chmod(myfile,0742).

    • B. 

      Chmod(myfile,0474).

    • C. 

      Chmod(myfile,0747).

    • D. 

      Chmod(myfile,0744)

  • 19. 
    All UNIX files have its description stored in a structure called 'inode'. which of the below fields are not part of the inode.
    • A. 

      File access count

    • B. 

      File owner identifier

    • C. 

      File type

    • D. 

      File access permissions

  • 20. 
    Which of the below commands NOT used to view the contents of a file?
    • A. 

      Ls command

    • B. 

      Cat command

    • C. 

      More command

    • D. 

      Disp command

  • 21. 
    How do you find out what’s your shell?
    • A. 

      Whomami

    • B. 

      Pwd

    • C. 

      Echo $SHELL

    • D. 

      $sh

  • 22. 
    Fork() command is used to create a new process. State true or false. 
    • A. 

      True

    • B. 

      False

×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.