1

I am trying to understand the differences between logname and LOGNAME from Difference between logname and $LOGNAME and https://askubuntu.com/questions/490620/difference-between-logname-and-logname

On Lubuntu 18.04, why did I get logname: no login name?

t@ocean:/t/t/bkg$ echo $LOGNAME
t
t@ocean:/t/t/bkg$ logname
logname: no login name
t@ocean:/t/t/bkg$ su t
Password: 
t@ocean:/t/t/bkg$ logname
logname: no login name
$ echo $?
1
t@ocean:/t/t/bkg$ cat /var/run/utmp
~~~reboot4.15.0-22-generic��[8Jtty1tty1LOGINJ��[�!�tty7:0t:0��[��5~~~runlevel4.15.0-22-generic��[

t@ocean:/t/t/bkg$ sudo su
[sudo] password for t: 
root@ocean:/tmp/test/bkg# logname
logname: no login name
root@ocean:/tmp/test/bkg# echo $LOGNAME
root

What is logname supposed to output? Thanks.

From man logname:

logname - print user´s login name

Print the name of the current user.


To address the comments:

$ cat /proc/self/loginuid
4294967295

t@ocean:/t/t/bkg$ grep ":$(id -u):" /etc/passwd
t:x:1000:1000:t,,,:/home/t:/bin/bash

t@ocean:/t/t/bkg$ tty
/dev/pts/8
t@ocean:/t/t/bkg$ w
 17:52:08 up 5 days,  6:28,  1 user,  load average: 0.39, 0.29, 0.28
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
t        tty7     :0               Wed11    5days  1:47m  6.33s /usr/bin/lxsession -s Lubuntu -e LXDE

Mark suspected the cause is that my lxterminal doesn't add an entry to utmp.

Pandya: Oh. Seems a bug with entry as you've concluded.

  • Comments are not for extended discussion; this conversation has been moved to chat. – terdon May 31 '18 at 8:46
  • Moving the helpful comments into a chatroom, which will disappear eventually, is very unfortunate. I have to manually save some comments from the chatroom. – Tim May 31 '18 at 17:47
  • If the comments are useful, they should be moved to the question or answer they are commenting upon. Comments are designed to be ephemeral and are not the place to have discussions. – terdon May 31 '18 at 17:53
  • Yet I had to copy others' comments into my question. I am on the side with what this user said in his profile unix.stackexchange.com/users/21167/zwol on this matter – Tim May 31 '18 at 18:00
  • 1
    The policy saying comments are not for extended discussion is an incorrect and harmful policy. The discussion of a question or answer belongs with the question or answer, i.e. in the comments. I have refused to cooperate with this policy for years and I advise you to do the same, Tim. @terdon – zwol Jun 1 '18 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.