LPI 102-500 Exam Questions
LPIC-1 Exam 102, Part 2 of 2, version 5.0 (Page 6 )

Updated On: 21-Feb-2026

Which of the following configuration files should be modified to set default shell variables for all users?

  1. /etc/bashrc
  2. /etc/profile
  3. ~/.bash_profile
  4. /etc/.bashrc

Answer(s): B

Explanation:

The /etc/profile file 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 the best option for setting default shell variables for all users, as it is executed before any user-specific files. The other options are not suitable for this purpose, because:
/etc/bashrc is a configuration file that is read by the Bash shell when it is started as an interactive non-login shell. It contains commands and settings that apply to all interactive shells of the system, such as aliases, functions, and prompt settings. It is not executed when the shell is started as a login shell, which is the case when a user logs in. Therefore, it is not a good place to set default shell variables for all users.
~/.bash_profile is a configuration file that is read by the Bash shell when it is started as a login shell for a specific user. It contains commands and settings that apply only to that user, such as environment variables, PATH information, and startup programs. It can also source other files, such as ~/.bashrc, which is read by the shell when it is started as an interactive non-login shell for that user. It is not a good place to set default shell variables for all users, as it only affects the user who owns the file.
/etc/.bashrc is not a valid configuration file for the Bash shell. The dot (.) at the beginning of the file name indicates that it is a hidden file, which means that it is not visible by default in the file system. The Bash shell does not look for this file when it is started, and it does not execute any commands or settings from it. Therefore, it is not a good place to set default shell variables for all users.



Which of the following is the best way to list all defined shell variables?

  1. env
  2. set
  3. env -a
  4. echo $ENV

Answer(s): B

Explanation:

The set command is used to display or modify the shell variables and functions in the current shell.
When used without any arguments, it prints the names and values of all shell variables, including environment variables and user-defined variables, in alphabetical order. The output also includes the shell options and the positional parameters. The set command can be used in any POSIX-compliant shell, such as bash, zsh, ksh, etc123.
The other options are not correct because:
env is used to print or modify the environment variables, not the shell variables. It does not show the user-defined variables or the shell options. It can also be used to run a command in a modified environment45.
env -a is an invalid option for the env command. The -a option is not supported by the env command in any standard or common implementation45.
echo $ENV is used to print the value of the environment variable ENV, not the list of all shell variables. The ENV variable is usually set to the name of a file that contains commands or aliases to be executed by the shell. It is mainly used by the ksh and some versions of bash .


Reference:

1: How can I list all shell variables? - Unix & Linux Stack Exchange
2: 2.1 Command Line Basics - Linux Professional Institute Certification ...
3: set - The Open Group Base Specifications Issue 7, 2018 edition
4: How to set and list environment variables on Linux
5: env - The Open Group Base Specifications Issue 7, 2018 edition : What is the difference between .bash_profile and .bashrc? - Unix & Linux Stack Exchange : ENV - The Open Group Base Specifications Issue 7, 2018 edition



Which command allows you to make a shell variable visible to subshells?

  1. export $VARIABLE
  2. export VARIABLE
  3. set $VARIABLE
  4. set VARIABLE
  5. env VARIABLE

Answer(s): B

Explanation:

The command that allows you to make a shell variable visible to subshells is export VARIABLE. This command turns the variable into a global or environment variable, which means it can be accessed by any child process or subshell that inherits the environment of the parent shell. The syntax of the export command does not require a dollar sign ($) before the variable name, unlike when referencing the value of the variable. The other commands are either invalid or do not affect the visibility of the variable to subshells. The set command can be used to assign values to variables, but it does not export them. The env command can be used to run a command in a modified environment, but it does not change the environment of the current shell.


Reference:

[LPI Linux Essentials - Topic 105: Shells, Scripting and Data Management] [LPI Linux Professional - Exam 102 Objectives - Topic 105: Shells and Shell Scripting] What is a Subshell? - Linux Bash Shell Scripting Tutorial Wiki - nixCraft What is Subshell in Linux? [Explained]



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

  1. LIMIT
  2. FROM
  3. WHERE
  4. IF

Answer(s): C

Explanation:

The correct keyword for restricting the records that are returned from a SELECT query based on a supplied criteria for the values in the records is WHERE. The WHERE clause is used to filter records based on one or more conditions. The syntax of the WHERE clause is:
SELECT column1, column2, ... FROM table_name WHERE condition; The condition can be a logical expression that evaluates to true, false, or unknown. The condition can also use comparison operators, logical operators, and wildcards to specify the criteria. For example, the following query selects all the records from the employees table where the salary is greater than 50000:
SELECT * FROM employees WHERE salary > 50000;
The other options are incorrect because they have different purposes in SQL:
LIMIT is used to specify the maximum number of records to return from a query. For example, the following query returns only the first 10 records from the employees table:
SELECT * FROM employees LIMIT 10;
FROM is used to specify the table or tables from which to retrieve data. For example, the following query selects all the columns from the employees table:

SELECT * FROM employees;
IF is used to execute a block of code conditionally. For example, the following query updates the salary of an employee based on their performance:
UPDATE employees SET salary = IF(performance = `excellent', salary * 1.1, salary) WHERE employee_id = 123;


Reference:

https://bing.com/search?q=SQL+statements+restrict+records+based+on+criteria https://stackoverflow.com/questions/11611931/sql-query-to-select-records-based-on-criteria



What benefit does an alias in bash provide?

  1. It provides faster lookups for commands in the system directory.
  2. It creates a local copy of a file from another directory.
  3. It hides what command you are running from others.
  4. It allows a string to be substituted for the first word of a simple command.

Answer(s): D

Explanation:

An alias in bash provides the benefit of allowing a string to be substituted for the first word of a simple command. This means that you can create a shortcut or alternative name for a command that is already installed on your system, and use the new name to run the command instead of the original name. For example, you can create an alias for the ls -la command, which lists all files and directories in the current directory with detailed information, by running the following command:
alias ll='ls -la'
After defining the alias, you can use the ll command to execute the ls -la command. The alias will be active for the duration of the current shell session, unless you make it persistent by adding it to your shell startup file (such as ~/.bashrc for the Bash shell). The other options are incorrect for the following reasons:
A: An alias does not provide faster lookups for commands in the system directory. The system directory is where the executable files for the commands are stored, and the shell uses the PATH variable to search for them. An alias does not affect the PATH variable or the system directory.
B: An alias does not create a local copy of a file from another directory. An alias is a way to rename a command, not a file. To create a local copy of a file, you can use the cp command.
C: An alias does not hide what command you are running from others. An alias is a way to simplify the use of a command, not to conceal it. Anyone can see what command an alias represents by using the type command or the alias command without any arguments.


Reference:

LPI E - alias
105.1 Lesson 1 - Linux Professional Institute Certification Programs How to Create Bash Aliases | Linuxize
How to create a permanent Bash alias on Linux/Unix - nixCraft bash - How do create an alias in shell scripts? - Stack Overflow






Post your Comments and Discuss LPI 102-500 exam dumps with other Community members:

Join the 102-500 Discussion