LPI 102-500 practice test

Exam Title: LPI Level 1

Last update: Dec 30 ,2025
Question 1

When the command echo $$ outputs 12942, what is the meaning of 12942?

  • A. It is the process ID of the echo command.
  • B. It is the process ID of the current shell.
  • C. It is the process ID of the last command executed.
  • D. It is the process ID of the last command which has been placed in the background.
Answer:

B


Explanation:
In bash, the PID of a shell script’s subshell process is stored in a special variable called $$.
This
variable is read-only, and you cannot modify it in a shell script1
.
You can use echo $$ to get the PID of
the current bash shell you are using2
. Therefore, when the command echo $$ outputs 12942, it
means that the PID of the current shell is 12942. Reference:
[LPI Linux Essentials - Topic 103: Command Line Basics]
[Bash Special Parameters]
How to get the process ID (PID) of a shell script
How to know the process id of current bash session?

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 2

What output will the following command produce?
seq 1 5 20

  • C. 1
  • D. 2
  • E. 5
Answer:

B


Explanation:
The seq command in Linux is used to generate a sequence of numbers from FIRST to LAST in steps of
INCREMENT1
. The syntax for the seq command is:
seq [OPTION]… LAST or seq [OPTION]… FIRST LAST or seq [OPTION]… FIRST INCREMENT LAST
In this case, the command seq 1 5 20 has three arguments: FIRST = 1, INCREMENT = 5, and LAST = 20.
This means that the command will produce numbers from 1 to 20 in steps of 5. The output will be:
1 5 10 15
The output will not include 20 because it is not a multiple of 5.
The output will be printed on
separate lines by default, unless a different separator is specified with the -s option2
. Reference:
Seq Command in Linux [Explained With Examples]
seq Man Page - Linux - SS64.com - SS64 Command line reference

vote your answer:
C
D
E
C 0 D 0 E 0
Comments
Question 3

Which of the following words is used to restrict the records that are returned from a SELECT SQL
query based on a supplied criteria for the values in the records?

  • A. CASE
  • B. FROM
  • C. WHERE
  • D. IF
Answer:

C


Explanation:
The SQL WHERE clause is used to restrict the records that are returned from a SELECT SQL query
based on a supplied criteria for the values in the records12
. The WHERE clause follows the SELECT
and FROM clauses and contains one or more conditions that must be true for a record to be included
in the result set. The general syntax of the WHERE clause is:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
The condition can be a comparison, a logical operation, a pattern matching, a subquery, or a
combination of these using various operators12
. For example, the following query selects all the
records from the customers table where the country is ‘USA’:
SELECT * FROM customers
WHERE country = 'USA';
The other words listed in the question are not used to filter records based on values. They have
different meanings and purposes in SQL:
CASE: This is a conditional expression that returns a value based on a set of conditions3
. It can be
used in SELECT, UPDATE, DELETE, or WHERE statements. For example, the following query uses a
CASE expression to assign a rating to each customer based on their credit limit:
SELECT customer_name, credit_limit, CASE WHEN credit_limit > 10000 THEN ‘High’ WHEN
credit_limit > 5000 THEN ‘Medium’ ELSE ‘Low’ END AS rating FROM customers;
FROM: This is a clause that specifies the table (s) or view (s) from which the data is retrieved. It
follows the SELECT clause and precedes the WHERE clause. For example, the following query selects
the customer name and order date from the customers and orders tables:
SELECT customer_name, order_date FROM customers JOIN orders ON customers.customer_id =
orders.customer_id;
IF: This is a control flow statement that executes a block of code based on a condition. It can be used
in stored procedures, functions, triggers, or batch files. For example, the following code snippet uses
an IF statement to check if a variable is positive or negative:
DECLARE @num INT; SET @num = -10; IF @num > 0 BEGIN PRINT ‘Positive’; END ELSE BEGIN PRINT
‘Negative’; END
Reference: 1
:
SQL WHERE Clause - W3Schools 2
:
How to Write a WHERE Clause in SQL |
LearnSQL.com 3
: [SQL CASE Statement - W3Schools] : [SQL FROM Clause - W3Schools] : [SQL IF…ELSE
Statement - W3Schools]

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 4

Which of the following commands lists all defined variables and functions within Bash?

  • A. env
  • B. set
  • C. env -a
  • D. echo $ENV
Answer:

B


Explanation:
The set command lists all defined variables and functions within Bash, including local, environment,
and shell variables, as well as aliases and functions. The output of set can be very long, so it is often
piped to less, grep, or other commands for filtering or paging. The set command can also be used to
set or unset shell options and positional parameters.
The -o posix option to set limits the output to
only variables, as defined by the POSIX standard123
.
The env command lists only the environment variables, which are a subset of the shell variables that
are passed to child processes. The env command can also be used to run a command in a modified
environment, or to print or set environment variables.
The -a option to env is not valid in most
implementations45
.
The echo command prints a line of text to the standard output. The $ENV variable is not a predefined
variable in Bash, but it can be set by the user or by other programs.
If it is not set, echo $ENV will
print a blank line1
. Reference:

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 5

Which of the following SQL queries counts the number of occurrences for each value of the field
order_type in the table orders?

  • A. SELECT order_type,COUNT(*) FROM orders WHERE order_type=order_type;
  • B. SELECT order_type,COUNT(*) FROM orders GROUP BY order_type;
  • C. COUNT(SELECT order_type FROM orders);
  • D. SELECT COUNT(*) FROM orders ORDER BY order_type;
  • E. SELECT AUTO_COUNT FROM orders COUNT order_type;
Answer:

B


Explanation:
The correct SQL query to count the number of occurrences for each value of the field order_type in
the table orders is:
SELECT order_type,COUNT(*) FROM orders GROUP BY order_type;
This query uses the SELECT statement to retrieve the values of the order_type field and
the COUNT(*) function to count the number of rows for each order_type. The GROUP BY clause
groups the rows by the order_type field, so that the count is calculated for each distinct value of
order_type. The result of this query is a table with two columns: order_type and count, where each
row shows the number of orders for a specific order_type.
The other options are incorrect for the following reasons:
A: This query uses a WHERE clause that is always true, since order_type=order_type for every row.
Therefore, this query returns the same result as SELECT order_type,COUNT(*) FROM orders;, which
is a table with one row that shows the total number of orders, regardless of the order_type.
C: This query is syntactically invalid, since the COUNT function cannot take a subquery as an
argument. The correct way to use a subquery with COUNT is COUNT((SELECT order_type FROM
orders));, which returns the total number of orders, regardless of the order_type.
D: This query uses the ORDER BY clause to sort the rows by the order_type field, but it does not
group them by order_type. Therefore, this query returns the same result as SELECT COUNT(*) FROM
orders;, which is a table with one row that shows the total number of orders, regardless of the
order_type.
E: This query is syntactically invalid, since there is no such function as AUTO_COUNT in SQL, and
the COUNT function cannot take a field name as an argument. The correct way to use COUNT with a
field name is COUNT(order_type);, which returns the number of non-null values in the order_type
field.
Reference:
[SQL COUNT Function]
[SQL GROUP BY Statement]
[SQL SELECT Statement]

vote your answer:
A
B
C
D
E
A 0 B 0 C 0 D 0 E 0
Comments
Question 6

What is the purpose of the file /etc/profile?

  • A. It contains the welcome message that is displayed after login.
  • B. It contains security profiles defining which users are allowed to log in.
  • C. It contains environment variables that are set when a user logs in.
  • D. It contains default application profiles for users that run an application for the first time.
Answer:

C


Explanation:
The file /etc/profile is a configuration file that is read by the Bash shell when a user logs in. It contains
commands and settings that apply to all users of the system, such as environment variables, PATH
information, terminal settings, and security commands. Environment variables are variables that
affect the behavior of programs and processes. For example, the PATH variable defines the
directories where the shell looks for executable files, and the JAVA_HOME variable defines the
location of the Java installation. The /etc/profile file can also source other files from the
/etc/profile.d/ directory, which can contain additional scripts for setting environment variables or
other system-wide settings. The /etc/profile file is not the only file that can set environment variables
for a user. There are also user-specific files, such as ~/.profile, ~/.bash_profile, and ~/.bashrc, that are
read by the shell after /etc/profile. These files can override or append to the settings in /etc/profile,
or define new variables for the user. The order and precedence of these files depend on the type of
shell (login or interactive) and the options used to start the shell.
You can learn more about the
difference between these files here1 and here2
. Reference:
https://www.thegeekdiary.com/understanding-etc-profile-configuration-file-in-linux/
https://unix.stackexchange.com/questions/704610/what-does-the-etc-profile-do

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 7

What command displays all aliases defined in the current shell? (Specify the command without any
path information)

Answer:

alias, alias -p


Explanation:
The alias command is used to create, list, or remove aliases in the current shell. An alias is a short
name that refers to another command, usually with some options or arguments. Aliases are useful
for saving typing time, avoiding spelling errors, or customizing the behavior of commands. To list all
the aliases defined in the current shell, we can use the alias command without any arguments.
This
will print the aliases in the format of alias name='command'123
. For example:
$ alias alias cp=‘cp -i’ alias l=‘ls -CF’ alias la=‘ls -A’ alias ll=‘ls -alF’ alias mv=‘mv -i’ alias rm=‘rm -i’
The output shows that some common commands, such as cp, mv, and rm, have aliases that add the -
i option, which prompts the user before overwriting or deleting files.
The l, la, and ll aliases are
shortcuts for different variations of the ls command, which lists files and directories123
.
Reference: 1: List All Available Commands and Aliases in Linux - Baeldung 2: get all aliases in linux
shell - Stack Overflow 3
: How to list all aliases on Linux - Linux Tutorials - Learn Linux Configuration

vote your answer:
Comments
Question 8

Which of the following are requirements in order to run a shell script like a regular command from
anywhere in the filesystem? (Choose THREE correct answers.)

  • A. The user issuing the command must be in the group script.
  • B. The script file must be found in the $PATH.
  • C. The script file must have the executable permission bit set.
  • D. The script must begin with a shebang-line (#!) that points to the correct interpreter.
  • E. The file system on which the script resides must be mounted with the option scripts.
Answer:

B, C, D


Explanation:
In order to run a shell script like a regular command from anywhere in the filesystem, the following
requirements must be met:
The script file must be found in the $PATH. The $PATH is a variable that contains a list of directories
where the shell looks for executable files when a command is issued. If the script file is not in one of
these directories, the shell will not be able to find it unless the full path is specified.
The script file must have the executable permission bit set. This is a file attribute that determines
whether the file can be executed by the user, the group, or others. The executable permission bit can
be set using the chmod command, for example: chmod +x script.sh.
The script must begin with a shebang-line (#!) that points to the correct interpreter. This is a special
line at the beginning of the script that tells the shell which program to use to run the script, such
as #!/bin/bash for bash scripts, or #!/usr/bin/perl for perl scripts. The shebang-line must match the
exact path of the interpreter, otherwise the script will not run.
The other options are not requirements for running a shell script like a regular command. There is no
such group as script, and the file system mount option scripts does not exist. Reference:
[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management]
[LPI Linux Professional - Exam 102 Objectives - Topic 105: Shells and Shell Scripting]

vote your answer:
A
B
C
D
E
A 0 B 0 C 0 D 0 E 0
Comments
Question 9

Which of the following SQL statements will select the fields name and address from the contacts
table?

  • A. SELECT (name, address) FROM contacts;
  • B. SELECT (name address) FROM contacts;
  • C. SELECT name, address FROM contacts;
  • D. SELECT name address FROM contacts;
Answer:

C


Explanation:
The correct syntax for selecting specific columns from a table in SQL is to use the SELECT keyword
followed by a comma-separated list of column names and then the FROM keyword followed by the
table name. Therefore, the only option that follows this syntax is C. SELECT name, address FROM
contacts; The other options are incorrect because they either use parentheses around the column
names, which are not needed, or they omit the comma between the column names, which causes a
syntax error. Reference:
https://www.sqltutorial.org/sql-select/
https://www.w3schools.com/mysql/mysql_select.asp

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 10

Which directory in /etc is used to keep a sample copy of files and directories for when a new user has
a home directory created? (Please provide the full path)

Answer:

/etc/skel,
/etc/skel/


Explanation:
The /etc/skel directory is used to keep a sample copy of files and directories for when a new user has
a home directory created. The /etc/skel directory contains files and directories that are automatically
copied over to a new user’s home directory when such user is created by the useradd or adduser
command. The /etc/skel directory allows the system administrator to create a standard environment
for all new users on the system. For example, the /etc/skel directory may contain a default .bashrc
file that sets some aliases and environment variables for the new user, or a default .profile file that
executes some commands at login. The /etc/skel directory may also contain subdirectories such as
.ssh or .config that store configuration files for various applications or services. The name /etc/skel
comes from the word “skeleton”, as it provides a basic structure for the new user’s home
directory. Reference:
[Linux User Administration]
[Linux Directory Structure]

Comments
Page 1 out of 23
Viewing questions 1-10 out of 234
Go To
page 2