Any2Quiz
Quizzes / Computer Science / Languages / Shell

Bash Basics Quiz - Languages Shell

Free practice quiz: Bash Basics (Languages Shell). 49 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

This Languages Shell practice quiz has 49 multiple-choice questions on Bash Basics, and 49 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.

Start quiz: 49 questions, free

Sample questions

  1. Which command is used to display the current working directory in Bash?

    Show answer

    Answer: C. pwd

    The 'pwd' command (print working directory) displays the full pathname of the current directory. 'ls' lists directory contents, 'cd' changes directories, and 'mkdir' creates directories.

  2. What is the purpose of the `alias` command in Bash?

    Show answer

    Answer: B. To define keyboard shortcuts for commands

    The `alias` command allows you to create custom names (aliases) for longer commands, effectively creating shortcuts. This can significantly speed up repetitive tasks.

  3. Which symbol is used to redirect standard output and standard error to the same file?

    Show answer

    Answer: D. &>

    The `&>` operator is a shortcut in Bash to redirect both stdout and stderr to a specified file. `2>&1` explicitly redirects stderr (file descriptor 2) to stdout (file descriptor 1), and then stdout is redirected.

  4. What is the difference between `>` and `>>` for output redirection?

    Show answer

    Answer: B. `>` overwrites, `>>` appends.

    The `>` operator redirects standard output to a file, creating the file if it doesn't exist or overwriting it if it does. The `>>` operator appends standard output to a file, creating it if it doesn't exist, but adding new output to the end if it does.

  5. Which of the following is NOT a standard file permission in Unix-like systems?

    Show answer

    Answer: D. Delete (d)

    The primary file permissions are read (r), write (w), and execute (x). While deleting a file is an operation performed by the filesystem, 'd' is not a standard explicit permission bit like r, w, x.

Take the full quiz

More questions in this quiz

Answers and explanations are in the full quiz.

  1. What is the primary purpose of the `grep` command in Bash?
  2. Which symbol is used to redirect the standard output of a command to a file in Bash?
  3. What does the `chmod` command primarily control?
  4. What is the purpose of the `echo` command in Bash?
  5. Which operator is used for logical AND in Bash conditional expressions?
  6. What does the `*` wildcard character represent in a Bash glob pattern?
  7. Which command is used to concatenate and display file contents?
  8. What is the difference between `rm file.txt` and `rm -r directory`?
  9. Which of the following is NOT a standard stream in Unix-like systems?
  10. How do you comment out a line in a Bash script?
  11. What is the purpose of the `sudo` command?
  12. Which command is used to create a new directory in Bash?
  13. What does the `|` (pipe) operator do in Bash?
  14. Which command is used to display the contents of a file in a paginated format?
  15. What does the `Ctrl+C` keyboard shortcut typically do in a Bash terminal?
  16. Which command is used to rename or move files and directories in Bash?
  17. What is the default shell for most Linux and macOS systems?
  18. What is the correct syntax for a `for` loop in Bash that iterates through a list of items?
  19. Which command is used to display the last few lines of a file?
  20. What is the purpose of the `&&` operator when chaining commands in Bash?
  21. Which command is used to find files and directories based on name, type, or other criteria?
  22. What does the `exit` command do in a Bash script?
  23. Which option is used with `grep` to perform a case-insensitive search?
  24. What is the purpose of the `tar` command?
  25. What does the `$?` special variable represent in Bash?
  26. Which command is used to display the manual pages for other commands?
  27. What does the `ls -l` command display?
  28. Which type of Bash variable is accessible only within the shell where it is defined?
  29. What does the `cd ..` command do?
  30. Which command is used to copy files and directories?
  31. What does the `.` wildcard character represent in a Bash glob pattern?
  32. What is the purpose of the `!` operator in Bash conditional expressions (e.g., `! -f file.txt`)?
  33. Which command is used to display all files and directories, including hidden ones, in Bash?
  34. What is a 'shebang' line in a Bash script, like `#!/bin/bash`?
  35. What is the purpose of the `read` command in Bash?
  36. How do you make a Bash script executable?
  37. What is the purpose of the `cut` command?
  38. Which operator is used for logical OR in Bash conditional expressions?
  39. What does `history` command display in Bash?
  40. What is the purpose of the `sed` command in Bash?
  41. What does `Ctrl+D` typically do in an empty Bash prompt?
  42. Which command allows you to view environment variables in Bash?
  43. What is the special variable `$PATH` used for in Bash?
  44. Which command would you use to create an empty file named `my_file.txt`?

More quizzes

Browse all Shell quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.