( ) - -, Linux . . , , , . , . . - , , , . , , , -, . .

Merion Academy


? Linux: , "/>

25%

🚀


📌

( ) - -, Linux . . , , , . , . . - , , , . , , , -, . .

, , .


:

KEY=value
KEY="Some other value"
KEY=value1:value2

:

  • (). (UPPER CASE).
  • :
  • =

:

  • (Environmental Variables) - , . , .
  • (Shell Variables) - , , . , , .

, env printenv. :

SHELL=/bin/bash
TERM=xterm
USER=demouser
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca:...
MAIL=/var/mail/demouser
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PWD=/home/demouser
LANG=en_US.UTF-8
SHLVL=1
HOME=/home/demouser
LOGNAME=demouser
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/printenv	

env, printenv. . , printenv :

printenv SHELL

:

/bin/bash

?

set. set - , , , :

BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extglob:extquote:force_fignore:histappend:interactive_comments:login_shell:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
. . .

, less, :

set | less

echo:

echo $ BASH_VERSION

:

4.4.19 (1) -release

Linux

, .

  • USER: ,
  • EDITOR:
  • HOME:
  • PATH: , ,
  • PS1: ( )
  • PWD:
  • _: ,
  • MAIL:
  • SHELL: , , (, bash, sh, zsh )
  • LANG: ,
  • DESKTOP_SESSION: , (GNOME, KDE)
  • HISTFILESIZE: ,
  • HISTSIZE: ,
  • UID: UID
  • HOSTNAME:
  • TERM:
  • OLDPWD:
  • BASHOPTS: , bash.
  • BASH_VERSION: bash, .
  • BASH_VERSINFO: bash .
  • COLUMNS: , .
  • DIRSTACK: , pushd popd.
  • IFS: . .
  • SHELLOPTS: , set.

Linux

Linux , .

- export.

export VAR="value"	

, .

NEW_VARIABLE "test", :

export NEW_VARIABLE='test'

:

printenv NEW_VARIABLE

test

export, . , , .


Linux

, . : , .

.bashrc

- .bashrc.

.bashrc - , , . , GNOME screen , .bashrc.

, .bashrc:

export TZ="America/New_York"

source bashrc .

source ~/.bashrc	

printenv , Linux, TZ.

$ printenv TZ
America/New_York

$ date
Sat 19 Jan 2020 10:03:00 AM EDT

, !

.bash_profile

, login , .bash_profile.

$ export TZ="America/New_York"

$ source ~/.bash_profile

etc/environment

, . Linux, /etc/environment.

, , , EDITOR .

$ export EDITOR="vi"

, , EDITOR .

, , , .

.bashrc:

echo "export VAR="value"" >> ~/.bashrc && source ~/.bashrc

.bash_profile:

echo "export VAR="value"" >> ~/.bash_profile && source ~/.bash_profile

/etc/environment:

echo "export VAR="value"" >> /etc/environment && source /etc/environment

Linux

, , , . Linux : unset .

unset

, unset :

unset <variable>

:

unset USERNAME

printenv USERNAME
<nothing>

set -n

, , set -n-n.

set -n USERNAME

printenv USERNAME
<nothing>

PATH Linux

Linux PATH, .

PATH, printenv:

printenv PATH

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

PATH, export .bashrc source:

echo "export PATH=":$PATH"" >> ~/.bashrc && source ~/.bashrc

printenv PATH
:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

! PATH Linux.


, Linux : export, , .

, PATH.




>