Whenever I connect to SSH session to a remote server, with either mobaXterm or just windows command line, there shows a message that says /usr/bin/logname: no login name

I can edit files and see directories normally however.

I tested with command logname and it returns logname: no login name, same with /usr/bin/logname

However when I type whoami or /usr/bin/whoami, it returns my id properly. and when I type id it also returns a line of information containing my id. The command who am i however return nothing.

logname 2>/dev/null || echo ${SUDO_USER:-${USER}} this also works from this link

What exactly is the problem here? I am unable to install Pycharm because of this error.

System is redhat linux. I do not have sudo rights.

My .profile looks like PATH=/usr/bin:/bin:/usr/sbin:/sbin/usr/local/bin:/usr/X11/bin:$PATH

and my .bashrc looks like

export PYTHONPATH=$PYTHONPATH:....(not relevant) 
source ~/.bash_profile

and my .bash_profile looks like export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11/bin:$PATH

1 Answer 1


Your login methods are not starting a login shell, or more precisely, are not indicating to the login process that you need an entry in /run/utmp. (Maybe /var/log/utmp, /var/run/utmp, or even /etc/utmp.) So:

ssh remoteHost logname
logname: no login name


ssh -t remoteHost logname
Connection to remoteHost closed.

However, unlike you, if I connect normally I do get a login shell that creates an entry in /run/utmp:

ssh remoteHost


who am i
roaima   pts/0        2022-06-20 23:12 (

There should be an option in mobaXterm to start a login shell, which usually forces the missing entry in /run/utmp. If you're using gnome-terminal there is a report of something similar. Without knowing how you are connecting from the "windows command line" I can't offer futher advice there.

  • I just tried ssh -t myid@serveraddress logname, it gives the same error .. could not find login shell option in mobaXterm.. I checked there is indeed no /etc/utemp/ ... this is a company server, is it something about restriction set by IT?
    – user530619
    Jun 21 at 2:48
  • @user530619 I've updated the location of utmp to match modern Linux systems running systemd. Please notice it's utmp not utemp/.
    – roaima
    Jun 21 at 9:54
  • Thank you for the update, I found this file /var/un/utmp exists. but /usr/bin/logname: no login name still happens every time i connect ? Another piece of info: whoami return id properly, but who am i does not return anything...
    – user530619
    Jun 21 at 15:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.