${LOGNAME} vs. ${USER}
Tom H
tomh0665 at gmail.com
Fri Jul 31 06:56:16 UTC 2015
On Thu, Jul 30, 2015 at 9:41 AM, <silver.bullet at zoho.com> wrote:
> On Thu, 30 Jul 2015 04:19:44 -0700, Tom H wrote:
>> On Thu, Jul 30, 2015 at 3:23 AM, <silver.bullet at zoho.com> wrote:
>>>
>>> I'm booted to Arch Linux at the moment, but it shouldn't differ
>>> What you need for your usage, depends on what you want to achieve.
>>>
>>> Take a look at the differences, especial how it differs after running
>>> sudo or su.
>>>
>>> $ echo $LOGNAME $USER $(id -un) $EUID $(id -u)
>>> rocketmouse rocketmouse rocketmouse 1000 1000
>>>
>>> $ sudo -i
>>> # echo $LOGNAME $USER $(id -un) $EUID $(id -u)
>>> root root root 0 0
>>>
>>> $ su
>>> # echo $LOGNAME $USER $(id -un) $EUID $(id -u)
>>> rocketmouse rocketmouse root 0 0
>>
>> Sure, using su and sudo changes things but that's not what the OP was
>> asking about - unless I misunderstood the question.
>
> Btw. just setting up a root account for Ubuntu by passwd root, Ubuntu does
> behave different than my Arch.
>
> [weremouse at moonstudio ~]$ echo $LOGNAME $USER $(id -un) $EUID $(id -u)
> weremouse weremouse weremouse 1000 1000
>
> [weremouse at moonstudio ~]$ sudo -i
> [root at moonstudio ~]# echo $LOGNAME $USER $(id -un) $EUID $(id -u)
> root root root 0 0
>
> [weremouse at moonstudio ~]$ su
> [root at moonstudio weremouse]# echo $LOGNAME $USER $(id -un) $EUID $(id -u)
> root root root 0 0
I don't use Arch but I suspect from the above output that its
"/bin/su" is provided by "util-linux", like Fedora/RHEL, rather than
by "login", which is derived from the "shadow" source package.
For util-linux
$HOME, $SHELL
are reset
and
$LOGNAME, $USER
are reset if the target user is not root
For login/shadow
$HOME, $LOGNAME, $PATH, $SHELL, $USER
are reset
AFAIR, in the util-linux case, $PATH used to behave like $LOGNAME and
$USER but it's no longer reset (but there's a login.defs variable for
it to be reset).
More information about the ubuntu-users
mailing list