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 freeSample questions
Which command is used to display the current working directory in Bash?
- ls
- cd
- pwd
- 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.
What is the purpose of the `alias` command in Bash?
- To create new commands
- To define keyboard shortcuts for commands
- To manage system services
- 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.
Which symbol is used to redirect standard output and standard error to the same file?
- >
- <
- 2>&1
- &>
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.
What is the difference between `>` and `>>` for output redirection?
- `>` appends, `>>` overwrites.
- `>` overwrites, `>>` appends.
- Both overwrite.
- 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.
Which of the following is NOT a standard file permission in Unix-like systems?
- Read (r)
- Write (w)
- Execute (x)
- 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.