LPI E - Shell Command Test
Answers are included at the end ...
Basic shell commands
- Which command is used to display the contents of a file in the terminal?
- cat
- ls
- mkdir
- pwd
- What command can be used to create a new directory in the current working directory?
- cat
- ls
- mkdir
- pwd
Command line syntax
- What is the syntax for using the "ls" command to display all files in a directory, including hidden files?
- ls -a
- ls -l
- ls -h
- ls -r
- Which symbol is used to redirect the output of a command to a file?
- >
- |
- <
- &
Variables
- How do you declare a new variable in a shell script?
- $my_var="hello"
- my_var="hello"
- var my_var="hello"
- export my_var="hello"
- What is the value of the variable "my_var" in the following command: my_var="hello" && echo $my_var
- hello
- $my_var
- echo $my_var
- my_var="hello"
Quoting
- What is the difference between using single quotes and double quotes to enclose a string in the shell?
- Single quotes prevent variable expansion, while double quotes allow it.
- Double quotes prevent variable expansion, while single quotes allow it.
- Single quotes and double quotes have no difference in the shell.Single quotes expand the string as a command, while double quotes treat it as a regular string.
- How can you include a variable inside a string in the shell using double quotes?
- "The variable is $VAR"
- "The variable is ${VAR}"
- "The variable is %VAR%"
- "The variable is [VAR]"
Answers:
Basic shell commands:
Answer: cat
Answer: mkdir
Command line syntax:
Answer: ls -a
Answer: >
Variables
Answer: my_var="hello"
Answer: hello
Quoting
The correct answer is:
Single quotes prevent variable expansion, while double quotes allow it.
The correct answer is:
"The variable is ${VAR}".
Disclaimer:
The samples provided here are intended to serve as a general guide and reference for individuals preparing for the LPI Linux certifications. These samples are not meant to represent the exact questions that may appear on the actual exam. The LPI certification exams are constantly updated and revised, and the questions on each exam are carefully crafted to assess a candidate's knowledge and skills.
Therefore, while we have made every effort to ensure the accuracy and relevance of the samples provided, we cannot guarantee that they will reflect the content or difficulty level of the actual exam. Additionally, we do not endorse or have any affiliation with the Linux Professional Institute (LPI).
We strongly recommend that candidates use these samples as an additional resource for their exam preparation, in combination with other study materials and practice tests. Ultimately, success on the LPI Linux certification exams will depend on an individual's knowledge, experience, and understanding of the exam objectives.
By using these samples, you agree that neither the provider of these sample questions nor any of its affiliates or employees shall be liable for any damages arising from your use or reliance on these sample questions or any information provided herein.