Unix: How is the initialization of the variable environment during shell-a launch?



  • How's that going? Where the lines come from. var=val? Where? char** environ? What happens when shell is initialized?

    You can just say, "There are system files on configuration." I'll ask, "With what?" ♪ /etc/profile only some of them have been identified, as in /etc/bash.bashrc~/.bashrc (sighs)~/.kshrc~/.zshrc) The sheath itself determines the value of variables based on the system designs? For example, he's making a challenge. ulimitlocale and others, a USERHOMEetc It's a steam. /etc/passwd♪ Are these guesses true?

    I'm not very clear about the footage of the casing, but from the manuals, the interesting information could not be read as well as knowing google.



  • The circumference is an integral part of all Unix processes and it is known that the environment is inherited from all its descendants. The descendants can change something in their copy of the environment, add, remove and launch their descendants by giving them their altered environment. Therefore, in order to understand that creates the environment of any launched launch process, the launch chain must be considered from the outset.

    So the Unix system is starting to launch. The core is loaded. The core starts "process number one," usually. /sbin/init♪ And init is starting all the other processes in the system. /etc/inittab) Watch the reference code. /sbin/init (in the example of sysVinit used by linux). Immediately function init_buildenv - it creates an initial environment for all processes in the system.

    Окружение формируемое /sbin/init:
    RUNLEVEL
    PREVLEVEL
    SHELL=/bin/sh
    CONSOLE
    INIT_VERSION
    

    Furthermore, init launches a system starter (for linux usually /sbin/rc), which loads demons, it creates a primary environment with which demons work. In addition, init begins to support terminals (in linux usually agetty), which makes variables TERM♪ For TERM network connections, the idea should be sshd or another connection. Those in turn launch /bin/login or carry out its work themselves. Here he, by authorizing the user, looks /etc/passwd and forms the primary environment of the user (additions what init):

    Окружение формируемое /bin/login
    HOME
    SHELL
    USER
    LOGNAME
    LANG
    TZ
    HZ
    PATH (см. /etc/login.defs)
    MAIL (см. /etc/login.defs)
    если в /etc/login.defs указан ENVIRONFILE - то добавляется его содержимое
    

    Finally login starts shell defined for the user. There's a lot of shells and everyone works around. They don't add much from themselves, but a lion's share of the environment is read from the files. We need to look at the source of each shell to see who's loaded. For zsh, the indicative list is:

    /etc/profile
    ~/.profile ИЛИ /etc/suid_profile (проверяет привилегии)
    /etc/zshenv (если включен при сборке zsh)
    ~/.zshenv
    /etc/zprofile (если включен при сборке zsh)
    /etc/zshrc (если включен при сборке zsh)
    ~/.zshrc
    /etc/zlogin (если включен при сборке zsh)
    ~/.zlogin
    

    In addition, other processes used in the user ' s inlet may be added to the environment. sshd adds to its variables, PAM modules used in authorization can do the same.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2