Discussion:
${LOGNAME} vs. ${USER}
Johnny Rosenberg
2015-07-12 12:32:52 UTC
Permalink
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?

In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?


Kind regards

Johnny Rosenberg
ゞョニヌ・ロヌれンバヌグ
Colin Law
2015-07-12 12:49:01 UTC
Permalink
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?
In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?
I think https://help.ubuntu.com/community/EnvironmentVariables
suggests they are both the same. Though why it uses the word
'similar' rather than something less ambiguous I don't know. I always
use USER.

Colin
Kind regards
Johnny Rosenberg
ジョニー・ローゼンバーグ
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinf
Johnny Rosenberg
2015-07-12 13:03:33 UTC
Permalink
Post by Colin Law
Post by Johnny Rosenberg
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?
In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?
I think https://help.ubuntu.com/community/EnvironmentVariables
suggests they are both the same. Though why it uses the word
'similar' rather than something less ambiguous I don't know. I always
use USER.
Colin
And it also says, about USER: ”You probably shouldn't change its value
manually”
Can I change it or not
? Not that I'd ever want to, but ”probably”
?


Johnny Rosenberg
Post by Colin Law
Post by Johnny Rosenberg
Kind regards
Johnny Rosenberg
ゞョニヌ・ロヌれンバヌグ
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Colin Law
2015-07-12 14:26:56 UTC
Permalink
Post by Colin Law
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?
In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?
I think https://help.ubuntu.com/community/EnvironmentVariables
suggests they are both the same. Though why it uses the word
'similar' rather than something less ambiguous I don't know. I always
use USER.
Colin
And it also says, about USER: ”You probably shouldn't change its value
manually”
Can I change it or not…? Not that I'd ever want to, but ”probably”…?
Of course you can, it is only an environment variable. It might mess
up stuff though, so do so at your own peril. I suppose there is a
small probability of someone having a good reason to change it, hence
the probably.

Colin
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ub
Robert Heller
2015-07-12 15:11:11 UTC
Permalink
Post by Johnny Rosenberg
Post by Colin Law
Post by Johnny Rosenberg
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?
In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?
I think https://help.ubuntu.com/community/EnvironmentVariables
suggests they are both the same. Though why it uses the word
'similar' rather than something less ambiguous I don't know. I always
use USER.
Colin
And it also says, about USER: ”You probably shouldn't change its value
manually”
Can I change it or not
? Not that I'd ever want to, but ”probably”
?
You can always change it -- environment variables cannot be 'write protected'.
OTOH, changing it will likely break things that depend on it being set
correctly. There might be very special reasons to change it, but generally you
should not, unless you *really* know what you are doing and have one of those
'special' reasons to change it. Generally speaking most environment variables
are set by by some system thing to reflect some aspect of the running
environment (like currently logged in user in this case). You should generally
leave these things alone.
Post by Johnny Rosenberg
Johnny Rosenberg
Post by Colin Law
Post by Johnny Rosenberg
Kind regards
Johnny Rosenberg
‚¾
Ĥ
ƒ‹
ƒŒ
ƒ»
ƒ­
ƒŒ
‚Œ
ƒ³
ƒ
ƒŒ
‚°
Post by Colin Law
Post by Johnny Rosenberg
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
MIME-Version: 1.0
--
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
***@deepsoft.com -- Webhosting Services
Nils Kassube
2015-07-12 16:27:21 UTC
Permalink
Post by Robert Heller
You can always change it -- environment variables cannot be 'write protected'.
I'm not so sure about that:

~/ > UID=0
bash: UID: readonly variable


Nils
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Johnny Rosenberg
2015-07-12 17:45:36 UTC
Permalink
Thanks for your input, everyone.
As I understand it, LOGNAME seems to be there for compatibility reasons.

One thing that changed when I switched from Ubuntu 12.04 to Ubuntu 14.04 is
what I already mentioned, that things like SD-cards end up at
”/media/<username>/” now, the earlier location was just ”/media/”. One wild
guess I do is that Ubuntu uses either USER or LOGNAME somewhere ”under the
hood”, to determine the location of my SD card. If so, which one?

I'm just curios, that's all. I don't really need the information, but it's
fun to know things



Kind regards

Johnny Rosenberg
ゞョニヌ・ロヌれンバヌグ
Nils Kassube
2015-07-12 18:28:18 UTC
Permalink
Post by Johnny Rosenberg
One thing that changed when I switched from Ubuntu 12.04 to Ubuntu
14.04 is what I already mentioned, that things like SD-cards end up
at ”/media/<username>/” now, the earlier location was just ”/media/”.
One wild guess I do is that Ubuntu uses either USER or LOGNAME
somewhere ”under the hood”, to determine the location of my SD card.
If so, which one?
Skimming through the source code of the udisks2 package it looks like
none of them is used. Instead the username is read from /etc/passwd.


Nils
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/lis
Johnny Rosenberg
2015-07-12 18:36:22 UTC
Permalink
Post by Nils Kassube
Post by Johnny Rosenberg
One thing that changed when I switched from Ubuntu 12.04 to Ubuntu
14.04 is what I already mentioned, that things like SD-cards end up
at ”/media/<username>/” now, the earlier location was just ”/media/”.
One wild guess I do is that Ubuntu uses either USER or LOGNAME
somewhere ”under the hood”, to determine the location of my SD card.
If so, which one?
Skimming through the source code of the udisks2 package it looks like
none of them is used. Instead the username is read from /etc/passwd.
Ouch, my ”wild guess” was wrong
! What a shame
 :P :D

Thanks for the information!


Kind regards

Johnny Rosenberg
ゞョニヌ・ロヌれンバヌグ
Post by Nils Kassube
Nils
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
BERBAR Florian
2015-07-13 08:50:27 UTC
Permalink
Post by Johnny Rosenberg
to determine the location of my SD card.
A udev script maybe be used full in this case to determine the full
mount path of your device. Udev allow you to set a script when a device
is plugged in. With this kind of script you automatically mount your
device in a custom path when it is plugged and know its mount path
perfectly.

Some documentation :

Writing udev rules for SD device (possibly deprecated) :
http://wandrian.net/2013-11-28-1705-udev-rule-for-sd-card-reader.html
Writing udev rules (running script) :
http://www.reactivated.net/writing_udev_rules.html#external-run
udev manpage : http://linuxcommand.org/man_pages/udev8.html

good luke

Florian
Johnny Rosenberg
2015-07-13 15:42:51 UTC
Permalink
Post by BERBAR Florian
Post by Johnny Rosenberg
to determine the location of my SD card.
A udev script maybe be used full in this case to determine the full
mount path of your device. Udev allow you to set a script when a device
is plugged in. With this kind of script you automatically mount your
device in a custom path when it is plugged and know its mount path
perfectly.
I wish that was true also for my Android phone
 like it was previous to
Ubuntu 14.04

Post by BERBAR Florian
http://wandrian.net/2013-11-28-1705-udev-rule-for-sd-card-reader.html
http://www.reactivated.net/writing_udev_rules.html#external-run
udev manpage : http://linuxcommand.org/man_pages/udev8.html
good luke
Florian
--
ubuntu-users mailing list
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
BERBAR Florian
2015-07-13 16:52:06 UTC
Permalink
I wish that was true also for my Android phone… like it was
previous to Ubuntu 14.04…
This page deals with management device on Android and it talk about
udev. So, you can use it on your Android Phone.

http://developer.android.com/tools/device.html#setting-up (the third
point).

Florian
Brandon Vincent (Student)
2015-07-12 15:42:53 UTC
Permalink
The environment variable LOGNAME is a convention from the early days of AT&T UNIX. USER has been around for the same time in the BSD community.

From the man page of login(1) from UNIX System III circa 1982, the only environment variables set at login were:

HOME=your-login-directory
PATH=:/bin:/usr/bin
LOGNAME=your-login-name

From the man page of login(1) for 2BSD (in particular, 2.9 a 1983 release which contained some backported features of 3BSD and 4BSD):

login initializes the user and group IDs and the working directory, and sets the HOME, PATH, TERM, SHELL and USER environment variables.

Interestingly, FWIW only LOGNAME is required to be set by POSIX-compliant systems as stated in the IEEE Std 1003.1-2008 / POSIX.1-2008 specification.

As for the practical difference between the two, I wouldn't worry about it. Both GNU/Linux and other *nix systems such as the BSD flavors support both for compatibility reasons.

Brandon Vincent
Tom H
2015-07-30 09:54:02 UTC
Permalink
On Sun, Jul 12, 2015 at 5:32 AM, Johnny Rosenberg
Which is the correct path for my SD card ”H6_SD”?
"/media/${LOGNAME}/H6_SD"
or
"/media/${USER}/H6_SD"?
In my case, both ${LOGNAME} and ${USER} happens to be the same, so both
work, but I guess that's not always true, is it?
They're set to tbe the same by login. LOGNAME is a SYSV variable and
USER is BSD variable but they're both set on Ubuntu and FreeBSD.
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists
s***@zoho.com
2015-07-30 10:23:29 UTC
Permalink
Post by Tom H
Post by Johnny Rosenberg
In my case, both ${LOGNAME} and ${USER} happens to be the same, so
both work, but I guess that's not always true, is it?
They're set to tbe the same by login. LOGNAME is a SYSV variable and
USER is BSD variable but they're both set on Ubuntu and FreeBSD.
I'm booted to Arch Linux at the moment, but it shouldn't differ
from Ubuntu. The output of the id command differs, it's the only way for
scripts to test for root privilges, if the install is set up with a
root account. Oops, resp. $EUID seems to work for this purpose too.

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

Regards,
Ralf
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Tom H
2015-07-30 11:19:44 UTC
Permalink
Post by s***@zoho.com
Post by Tom H
Post by Johnny Rosenberg
In my case, both ${LOGNAME} and ${USER} happens to be the same, so
both work, but I guess that's not always true, is it?
They're set to tbe the same by login. LOGNAME is a SYSV variable and
USER is BSD variable but they're both set on Ubuntu and FreeBSD.
I'm booted to Arch Linux at the moment, but it shouldn't differ
from Ubuntu. The output of the id command differs, it's the only way for
scripts to test for root privilges, if the install is set up with a
root account. Oops, resp. $EUID seems to work for this purpose too.
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.
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
s***@zoho.com
2015-07-30 13:41:46 UTC
Permalink
Post by Tom H
Post by s***@zoho.com
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.

[***@moonstudio ~]$ echo $LOGNAME $USER $(id -un) $EUID $(id -u)
weremouse weremouse weremouse 1000 1000

[***@moonstudio ~]$ sudo -i
[***@moonstudio ~]# echo $LOGNAME $USER $(id -un) $EUID $(id -u)
root root root 0 0

[***@moonstudio ~]$ su
[***@moonstudio weremouse]# echo $LOGNAME $USER $(id -un) $EUID $(id -u)
root root root 0 0

Regards,
Ralf
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Tom H
2015-07-31 06:56:16 UTC
Permalink
Post by s***@zoho.com
Post by Tom H
Post by s***@zoho.com
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 weremouse weremouse 1000 1000
root root root 0 0
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).
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
s***@zoho.com
2015-07-31 11:31:27 UTC
Permalink
Post by Tom H
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).
Thank you Tom,

it's useful to know such things, to keep scripts compatible for usage
with different Linux distros and operating systems.

Your guess is correct.

[***@archlinux ~]$ pacman -Qo /usr/bin/su
/usr/bin/su is owned by util-linux 2.26.2-1

Regards,
Ralf

PS:

FHS Ubuntu

[***@archlinux ~]$ p="/mnt/moonstudio"
[***@archlinux ~]$ ls -hAld $p/bin $p/sbin $p/usr/bin/
$p/usr/sbin
drwxr-xr-x 2 root root 4.0K Jul 26 15:48 /mnt/moonstudio/bin
drwxr-xr-x 2 root root 4.0K Jul 30 14:38 /mnt/moonstudio/sbin
drwxr-xr-x 2 root root 36K Jul 31 10:26 /mnt/moonstudio/usr/bin/
drwxr-xr-x 2 root root 4.0K Jul 31 10:25 /mnt/moonstudio/usr/sbin

FHS Arch

[***@archlinux ~]$ p=""
[***@archlinux ~]$ ls -hAld $p/bin $p/sbin $p/usr/bin/
$p/usr/sbin
lrwxrwxrwx 1 root root 7 Apr 22 17:51 /bin -> usr/bin
lrwxrwxrwx 1 root root 7 Apr 22 17:54 /sbin -> usr/bin
drwxr-xr-x 5 root root 212K Jul 30 16:28 /usr/bin/
lrwxrwxrwx 1 root root 3 Apr 22 17:57 /usr/sbin -> bin



I noticed that by default Ubuntu's /tmp isn't tmpfs

[***@archlinux ~]$ ls -a /mnt/moonstudio/tmp/
. .spamassassin102421p50xJtmp .spamassassin10242DBmUqjtmp .spamassassin10242XZLXCitmp
.. .spamassassin102424Cvbvktmp .spamassassin10242edxaWAtmp .spamassassin10242zKWRtntmp
config-err-SL5T3l .spamassassin102424d72xatmp .spamassassin10242FWYa7xtmp .Test-unix
.font-unix .spamassassin102424IF1kitmp .spamassassin10242mRPxB3tmp .X11-unix
.ICE-unix .spamassassin10242cLW8dJtmp .spamassassin10242oi0hf7tmp .XIM-unix
qupzilla-weremouse .spamassassin10242CwrMp8tmp .spamassassin10242w4NwR9tmp

Default for Arch is tmpfs

[***@archlinux ~]$ df | grep /tmp
tmpfs 1895600 112 1895488 1% /tmp
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Johnny Rosenberg
2015-07-31 11:45:43 UTC
Permalink
Post by s***@zoho.com
Post by Tom H
Post by s***@zoho.com
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 weremouse weremouse 1000 1000
root root root 0 0
root root root 0 0
I couldn't even test the last one, since I don't have a root password
configured.
Anyway, thank you all for replying!


Regards

Johnny Rosenberg
ジョニー・ローゼンバーグ
Post by s***@zoho.com
Regards,
Ralf
--
ubuntu-users mailing list
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
--
ubuntu-users mailing list
ubuntu-***@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/
Loading...