我的环境变量是什么?

我想在 bash 中找到我的环境变量。它们存储在什么地方吗?

80576 次浏览

Type export without any parameters.

I am not sure if thats what you want, but try printenv
This will show you all your environment variables.

About where they are stored
Linux: where are environment variables stored?

How to set Shell Environment Variables
http://www.codecoffee.com/tipsforlinux/articles/030.html

Happy reading :-)

Just execute env in a terminal.

Example output:

$ env
TERM=xterm
SHELL=/bin/bash
USER=joksnet
USERNAME=joksnet
DESKTOP_SESSION=gnome
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/joksnet
GDM_KEYBOARD_LAYOUT=us
LANG=en_US.utf8
HOME=/home/joksnet
DISPLAY=:0.0
COLORTERM=gnome-terminal
_=/usr/bin/env

Or set:

SET(P)                                                                  POSIX Programmer’s Manual                                                                  SET(P)


NAME
set - set or unset options and positional parameters


SYNOPSIS
set [-abCefmnuvx][-h][-o option][argument...]


set [+abCefmnuvx][+h][+o option][argument...]


set -- [argument...]


set -o


set +o


DESCRIPTION
If  no  options or arguments are specified, set shall write the names and values of all shell variables in the collation sequence of the current locale. Each name
shall start on a separate line, using the format:


"%s=%s\n", <name>, <value>


The value string shall be written with appropriate quoting; see the description of shell quoting in Quoting . The output shall be  suitable  for  reinput  to  the
shell, setting or resetting, as far as possible, the variables that are currently set; read-only variables cannot be reset.