What are my environment variables? [closed]

2019-03-08 04:36发布

I would like to find out my environment variables in bash. Are they stored somewhere?

4条回答
淡お忘
2楼-- · 2019-03-08 05:09

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 :-)

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-08 05:19

Type export without any parameters.

查看更多
戒情不戒烟
4楼-- · 2019-03-08 05:23

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.
查看更多
男人必须洒脱
5楼-- · 2019-03-08 05:34

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
查看更多
登录 后发表回答