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

Play all 49 questions free

Sample questions

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

    1. ls
    2. cd
    3. pwd
    4. mkdir
    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?

    1. To create new commands
    2. To define keyboard shortcuts for commands
    3. To manage system services
    4. To edit files directly
    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?

    1. >
    2. <
    3. 2>&1
    4. &>
    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?

    1. `>` appends, `>>` overwrites.
    2. `>` overwrites, `>>` appends.
    3. Both overwrite.
    4. Both append.
    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?

    1. Read (r)
    2. Write (w)
    3. Execute (x)
    4. Delete (d)
    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 quizzes

Browse all Shell quizzes