If bash is invoked with the name sh
Meaning what?
Meaning what?
$UID variable set somewhere in the filesystem
Meaning what?
Bash being invoked with name sh simply means that when /bin/sh is called, such as within a script, it is the bash shell that executes it as if it were the more POSIX compliant shell known as sh, rather than as the full bash shell with all its capability including its bashisms.
If /bin/sh is a link to /bin/bash, which it is in some distros, it means that bash is supplying the sh capability and there is not a separate executable to execute sh.
In relation to environment variable's origins in the system, some environment variables are set by the shell, some are set in the filesystem, some are set by the system, within the executables.
Examples of environment variable set in the shell are those set as built-in to bash, such as:
Code:
$ echo $MAIL
/var/mail/ben
$ echo $HISTFILE
/home/ben/.bash_history
An examples of an environment variable set in the filesystem is the following:
Code:
$ grep PATH /etc/profile
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
export PATH
An examples of an environment variable set within an executable is UID.
UID is set by the system at login when the user is logged in and it is based on the user's account. There's no need for separate configuration of UID unlike other environment variables. It does not need to be explicitly defined in files like /etc/profile. It's automatically assigned by the system and available in all shells once a user logs in.
If one checks the source code of the login program from here:
https://github.com/util-linux/util-linux/blob/master/login-utils/login.c, one can see that it depends on the header file: unistd.h, which installs at /usr/include/unistd.h if the libc6-dev package is installed. In that header file one finds:
Set the user ID of the calling process to UID
Thus, it appears that UID is built into the login executable from which it's assigned.