Login

From Gentoo Wiki
Jump to: navigation, search

Various aspects of login are (will be) explained in this Article.

Login shell in Gentoo

The most important job of a login shell in Gentoo is to set system-wide environment variables. This is done

  • for Bash and variants, by reading /etc/profile.env, and
  • for csh/tcsh, by reading /etc/csh.env.

See below for the details.

This section describes Gentoo specific matters of login shells. For login shells general in Unix, see the pointer(s) in #external links.

Default: Bash and variants

For Bash and variants, a login shell runs special configuration file(s), e.g. /etc/profile (and others) for bash. In Gentoo, it reads (= sources) other system-wide configuration files. These configuration files set environment variables, and do some other setups. These settings will be inherited by other shells, say opened in terminal emulators.

Load order of system-wide config files for Bash

A (bash) login shell reads:

  • first /etc/profile.
  • It then reads (sources) /etc/profile.env, and
  • files /etc/profile.d/*.sh.

If the shell is bash, /etc/bash/bashrc is also sourced. This does not configure Gentoo itself; it rather provides the Gentoo-default of bash look-and-feel.

System wide config files for Bash explained

/etc/profile
Provided by sys-apps/baselayout (or alternatives). Other than reading other files, this file doesn't do many jobs.
/etc/profile.env
This file sets environment variables. Some packages require environment variables to be set, and in Gentoo, such environment variables are collected here.
This file is generated from files /etc/env.d/*. These files are installed by some packages (or created by config tools like eselect). For example /etc/env.d/30gnupg is provided by app-crypt/gnupg.
This file is usually automatically updated.[1] You can also manually update it by calling env-update.
For the details of how /etc/profile.d is generated, see Handbook -> Environment variables -> section "Defining variables globally".
/etc/profile.d/*.sh
Some packages install files here, to be sourced by the login shell, to provide per-package configurations . It is a Unix custom, and part of the Linux Standard Base, 5.0 (2015).[2]

When these files are updated, typically /etc/profile.env, you have to re-read them again from your shell(s), for your shell to function correctly.

Tcsh

If tcsh is run as a login shell, it reads one system-wide configuration file /etc/csh.login. It reads (= sources) other system-wide configuration files. These configuration files set environment variables, and do some other setups. These settings will be inherited by other shells, say opened in terminal emulators.

A login shell of tcsh also reads /etc/csh.cshrc. It provides tcsh-specific default behavior, and does not configure Gentoo itself.

Load order of system-wide config files for tcsh

A tcsh login shell reads:

  • first /etc/csh.login.
  • It then reads (sources) /etc/csh.env,
  • and files /etc/profile.d/*.csh.

System wide config files for tcsh explained

/etc/csh.login
Provided by app-shells/tcsh. (This file is distributed by Gentoo, not by the tcsh upstream.)
/etc/csh.env
This file corresponds to /etc/profile.env for bash, explained above. This file is also maintained by env-update, even if any csh-variants is not installed.
/etc/profile.d/*.csh
Similar to /etc/profile.d/*.sh for bash explained above, but there is no standard for *.csh.

If these files are updated, typically /etc/csh.env, you have to re-read them again from your shell(s), for your shell to function correctly.

Fish

As stated in the article fish, fish can't load system-wide configuration files mentioned above.

Footnotes

  1. More precisely, if there's any change in the directory /etc/env.d, emerge will re-generate /etc/profile.env. (Any change will be caught; it is not limited to changes done by ebuild-helper-commands doenvd or newenvd.) Same can be expected for Gentoo official tools like eselect.
  2. See Linux Standard Base Core Specification, Generic Part, 5.0 Edition

See also


External links

  • login shell - ArchLinux Wiki article, for more general aspects of Unix login shells.