[sf-lug] environment variables ... & shell?

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Aug 22 23:41:00 PDT 2016


> From: "Alex Kleider" <akleider at sonic.net>
> Subject: Re: [sf-lug] printenv "vs." set [was: Re: shell, man(1) [was: ...
> Date: Sun, 21 Aug 2016 15:55:03 -0700

> It seems that no variable (shell or environment) can exist except in  
> the context of the shell.  So does that make them all shell variables?

Nope.  No shell required.
execve(2)
E.g.:
We see that PID 1 has an environment:
# ps lwwwep 1
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
4     0     1     0  20   0  15492  1528 -      Ss   ?          2:39  
init [2]           SHLVL=1 HOME=/ init=/lib/sysvinit/init TERM=linux  
drop_caps= BOOT_IMAGE=/vmlinuz-3.16.0-4-amd64  
PATH=/sbin:/usr/sbin:/bin:/usr/bin PWD=/ rootmnt=/root
#
 From the very start, the very first actual process has an environment  
- even if it
may be empty when it's very first started.
... FYI, I think Linux's (distributions / init systems) behavior of setting
TERM in init is really dumb/annoying.  But that's another issue.





More information about the sf-lug mailing list