CompTIA Linux+ Practice Exam 2025 – Full Prep Guide

Question: 1 / 1520

Which command would you use to display environment variables in Linux?

env

set

printenv

The command used to display environment variables in Linux is "printenv." This command specifically prints all or part of the environment variables, allowing users to see the current values that have been set in their shell session.

When using "printenv" without any arguments, it will list all environment variables in the current shell. You can also specify a particular variable to view its value. This functionality is beneficial for diagnosing issues or confirming that certain variables are set correctly within the environment.

While "env" can also be used to display environment variables, its primary purpose is to run a command in a modified environment and may not be as straightforward for simply viewing the variables. The "set" command, on the other hand, displays all shell variables, including functions and some shell options, making the output more extensive and possibly more confusing if you're only interested in environment variables. The option "showenv," however, is not a standard command in most Linux distributions and would not provide the desired output for displaying environment variables.

Get further explanation with Examzify DeepDiveBeta

showenv

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy