To list all environment variables in Linux, you can use the printenv
command. This command will display all the environment variables and their values.
For example:
$ printenv
This will print all the environment variables and their values, one per line.
You can also use the env
command to list the environment variables. This command allows you to set environment variables as well as list them.
For example:
$ env
This will print all the environment variables and their values, one per line.
You can also use the set
command to list all environment variables. This command is typically used to set shell variables, but it can also be used to list all environment variables.
For example:
$ set
This will print all the environment variables, shell variables, and functions, one per line.
You can also use the export
command to list all environment variables that have been set using the export
command.
For example:
$ export
This will print all the environment variables that have been set using the export
command, one per line.
You can also use the declare
command to list all shell variables and functions.
For example:
$ declare
This will print all the shell variables and functions, one per line.
Finally, you can use the env
command with the grep
command to filter the output and display only the environment variables that contain a certain string.
For example:
$ env | grep PATH
This will print all the environment variables that contain the string "PATH".