LPIC 1 Shells and Shell Scripting Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 11 | Questions: 20 | Updated: Aug 16, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What does the 'test' command (or [ ]) evaluate in shell scripts?

Explanation

In shell scripts, `test` (also written as `[ ... ]`) evaluates expressions that determine whether a condition is true or false. These commonly check file properties, such as whether a file exists, and compare strings or numbers, allowing scripts to make decisions based on the results.

Submit
Please wait...
About This Quiz
LPIC 1 Shells and Shell Scripting Quiz - Quiz

This quiz evaluates your understanding of Linux shells and shell scripting fundamentals required for LPIC 1 certification. You'll test knowledge of shell types, scripting syntax, variables, control structures, and command-line operations essential for system administration and automation.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. In shell scripting, what is the purpose of the 'read' command?

Explanation

The `read` command waits for input from the user or standard input, then stores the entered value in one or more shell variables for use by the script.

Submit

3. Which command lists all available shells on a system?

Explanation

`cat /etc/shells` displays the contents of the `/etc/shells` file, which typically lists the shells available or approved for use on a Unix-like system. The other options are not standard commands for retrieving this list.

Submit

4. What does 'set -e' do in a bash script?

Explanation

`set -e` makes a Bash script exit when a command fails, helping prevent it from continuing after an unexpected error. Some commands used in conditional or other special contexts are exceptions.

Submit

5. In a shell script, how do you capture command output into a variable?

Explanation

Command substitution captures a command’s standard output and stores it in a variable. Write the command inside `$()` with no spaces around the assignment operator, as in `var=$(command)`. For example, `current_date=$(date)` saves the output of `date` in `current_date`.

Submit

6. What does the 'sed' command do?

Explanation

`sed` is a command-line stream editor that processes text from files or input streams. It can search for patterns and apply transformations—such as replacing, deleting, or inserting text—without requiring you to edit the original content manually. It is commonly used in scripts and pipelines to automate text-processing tasks.

Submit

7. Which shell configuration file is sourced for interactive login shells?

Explanation

Bash reads the user’s `~/.bash_profile` when an interactive login shell starts, if the file exists. It commonly sets environment variables and may also load `~/.bashrc`. The `.bashrc` file is typically used for interactive non-login shells, while `.bash_logout` is run when a login shell exits.

Submit

8. In bash, how do you execute a command stored in a variable?

Explanation

In Bash, `eval` combines its arguments into a command string, then parses and executes that string, allowing shell syntax stored in a variable to run. Use it cautiously: variable expansion can cause word splitting and pathname expansion, and `eval` may execute unintended or malicious input. Prefer safer alternatives when possible.

Submit

9. What does the 'grep' command primarily do?

Explanation

The `grep` command searches text in files for lines that match a specified pattern, such as a word or regular expression. It can display matching lines and is commonly used to find information quickly in files or command output.

Submit

10. Which operator tests if a file exists?

Explanation

In shell conditionals, `-e` checks whether a specified path exists, whether it refers to a file, directory, or another filesystem object. By contrast, `-f` checks for a regular file, `-d` for a directory, and `-x` for executable permission.

Submit

11. Which shell is the default interactive shell on most modern Linux systems?

Explanation

Bash, or the Bourne Again Shell, is the default interactive shell on many Linux systems. It is widely used because it supports familiar Unix shell commands along with features such as command history, tab completion, and scripting, making it a practical choice for both everyday terminal use and automation.

Submit

12. In shell scripting, which special variable contains the script's filename?

Explanation

`$0` contains the name or path used to invoke the shell script. By contrast, `$1` is the first argument, `$#` is the number of arguments, and `$@` represents all arguments.

Submit

13. What does the 'source' command do in bash?

Explanation

The `source` command reads and runs commands from a specified file in the current shell. This lets the commands affect the existing shell environment, such as setting variables or defining functions, rather than running in a separate process.

Submit

14. Which loop construct repeats a block while a condition is true?

Explanation

A `while` loop checks its condition before each iteration and repeats the block as long as the condition remains true. When the condition becomes false, the loop ends.

Submit

15. What keyword starts a conditional block in bash?

Explanation

In Bash, `if` begins a conditional block. It evaluates a command or condition, then runs the following commands when the condition succeeds; `fi` marks the block’s end.

Submit

16. In a shell script, how do you define a variable named 'name' with value 'John'?

Explanation

In shell scripts, assign a value using the variable name, an equals sign, and the value, with no spaces around the equals sign. Quotes preserve the value as a single string: `name='John'`.

Submit

17. Which variable represents the process ID of the current shell?

Explanation

In shells such as Bash, `$$` expands to the process ID (PID) of the current shell. By contrast, `$!` gives the PID of the most recently started background job, `$0` contains the shell or script name, and `$PID` is not a standard special parameter.

Submit

18. What does the pipe operator (|) do in shell commands?

Explanation

The pipe operator (`|`) connects two commands, passing the standard output of the first command as the standard input of the next. This lets you combine commands to process data in stages.

Submit

19. In bash, which symbol is used to redirect standard output to a file, overwriting it?

Explanation

In Bash, the `>` operator redirects a command’s standard output to a file. It creates the file if it does not exist and truncates it if it already exists, replacing its contents.

Submit

20. What command displays the current shell environment variable?

Explanation

In a Unix-like shell, `$SHELL` refers to the environment variable containing the user’s configured shell path. The `echo` command prints its value to the terminal, so `echo $SHELL` displays that path.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What does the 'test' command (or [ ]) evaluate in shell scripts?
In shell scripting, what is the purpose of the 'read' command?
Which command lists all available shells on a system?
What does 'set -e' do in a bash script?
In a shell script, how do you capture command output into a variable?
What does the 'sed' command do?
Which shell configuration file is sourced for interactive login...
In bash, how do you execute a command stored in a variable?
What does the 'grep' command primarily do?
Which operator tests if a file exists?
Which shell is the default interactive shell on most modern Linux...
In shell scripting, which special variable contains the script's...
What does the 'source' command do in bash?
Which loop construct repeats a block while a condition is true?
What keyword starts a conditional block in bash?
In a shell script, how do you define a variable named 'name' with...
Which variable represents the process ID of the current shell?
What does the pipe operator (|) do in shell commands?
In bash, which symbol is used to redirect standard output to a file,...
What command displays the current shell environment variable?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!