This article covers logging in to a shell, and setting up the default environment. See display manager for graphical logins.
Login consists of several steps:
- Authentication - See Category:Authentication
- Provision of services with privilege - PAM organizes services, and also works in several other cases.
- Login shell invocation
On effective shell invocation, the UID is set to that of the logged in user, then any shell initialization scripts are invoked, as described below.
Login shell startup scripts and environment variables
One important job of a login shell is to set system-wide environment variables. In Gentoo this is done:
- for Bash and variants, by reading /etc/profile.env file
- for csh/tcsh, by reading /etc/csh.env file.
The following sections concentrate on Gentoo login shells. For general information about login shells in Unix, see the #external links.
Bash and variants - default
For Bash and variants, starting a login shell sources (executes in current process, conserving environment) configuration scripts, e.g. /etc/profile, among others. These configuration files set environment variables, and perform some setup. These settings will be inherited by other shells, say opened in terminal emulators.
A bash login shell reads, in order:
- Any files under the /etc/profile.d/ directory with a .sh suffix.
/etc/bash/bashrc is also sourced - this does not configure Gentoo itself, but provides the Gentoo-default bash look-and-feel.
System wide config files for Bash
- 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., but can also be manually updated by calling env-update.
- For 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 (often after updating /etc/profile.env, then running env-update), they must be sourced again from currently running shell(s), for the shell instances to continue functioning correctly - for example by running source /etc/profile.
When tcsh is run as the login shell, it reads one system-wide configuration file, /etc/csh.login, which then sources other system-wide configuration files. These configuration files set environment variables, and do some other setup. These settings will be inherited by other shells, say opened in terminal emulators.
A tcsh login shell also reads /etc/csh.cshrc, which provides some tcsh-specific default behavior, but does not configure Gentoo itself.
A tcsh login shell reads files in the following order:
- Any files under the /etc/profile.d/ directory with a .csh suffix.
System wide config files for tcsh
- 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 when no csh, or variant, is installed.
- Similar to /etc/profile.d/*.sh for bash explained above, but there is no standard for
When these files are updated, typically /etc/csh.env, they must be sourced again from currently running shell(s), for the shell instances to continue functioning correctly.
As stated in the article fish, fish can't load system-wide configuration files mentioned above. To use fish as a user's default shell, there is a good workaround detailed in the fish article.
- Display manager — presents the user with a graphical login screen to start a GUI session, either X or Wayland.
- Shell — command-line interpreter that offers a text-based interface to users.
- Terminal emulator — emulates a video terminal within another display architecture (e.g. in X).
- 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