RHEL Linux - Red Hat System Administration Practice Exam

Disable ads (and more) with a membership for a one time $4.99 payment

Study for the RHEL Linux - Red Hat System Administration Exam. Enhance your knowledge with flashcards and multiple-choice questions, complete with hints and explanations. Prepare for your certification!

Practice this question and more.


To list all environment variables in a Linux shell session, which command would you use?

  1. env

  2. set

  3. printenv

  4. All of the above

The correct answer is: All of the above

All provided options—env, set, and printenv—are valid commands that can be used to display environment variables in a Linux shell session. The env command is specifically designed for displaying environment variables. When executed without any arguments, it lists all the current environment variables in the session. The set command, on the other hand, displays not only environment variables but also shell functions and variables defined in the current shell. Thus, it gives a more comprehensive view of the shell's state, including both environment variables and local shell variables. The printenv command is another command explicitly used to print environment variables. It can also display the value of a specific variable if provided with an argument. When executed without arguments, it lists all environment variables. Since all three commands provide methods to view environment variables, using any of these commands achieves the same general outcome, making it accurate to say that all listed options can be utilized for this purpose.