This article is a primer which explains various aspects of a login shell.
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 file, and
- for csh/tcsh, by reading /etc/csh.env file.
See the following sections below for more details on these
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:
- The /etc/profile file.
- The /etc/profile.env file.
- Any files under the /etc/profile.d/ directory with a .sh suffix.
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
- Provided by sys-apps/baselayout (or alternatives). Other than reading other files, this file doesn't do many jobs.
- 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. 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".
- 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).
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.
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 files in the following order:
- The /etc/csh.login file.
- The /etc/csh.env file.
- Any files under the /etc/profile.d/ directory with a .csh suffix.
System wide config files for tcsh explained
- Provided by app-shells/tcsh. (This file is distributed by Gentoo, not by the tcsh upstream.)
- 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.
- Similar to /etc/profile.d/*.sh for bash explained above, but there is no standard for
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.
As stated in the article fish, fish can't load system-wide configuration files mentioned above.
- Login manager — presents the user with a graphical login screen to start a GUI session, either X or Wayland.
- login shell - ArchLinux Wiki article, for more general aspects of Unix login shells.
- More precisely, if there's any change in the directory /etc/env.d,
emergewill re-generate /etc/profile.env. (Any change will be caught; it is not limited to changes done by ebuild-helper-commands
newenvd.) Same can be expected for Gentoo official tools like eselect.
- See Linux Standard Base Core Specification, Generic Part, 5.0 Edition