Score:2

Wrong logname at login in Ubuntu 21.10

td flag

I upgraded my Ubuntu 21.04 to 21.10 yesterday and am running into serious problems after rebooting.

Troubles with graphical drivers (solved)

This is solved, but maybe I broke something by solving this problem ? Ubuntu stuck during boot and the desktop was never showing. I restarted in rescue mode, updated grub to add "nomodeset" and did some reinstallations + reconfigurations :

apt install --reinstall xserver-xorg-video-amdgpu
dpkg-reconfigure gdm3 ubuntu-session xserver-xorg-video-amdgpu
dpkg-reconfigure ubuntu-session xserver-xorg-video-amdgpu
apt reinstall gdm3 gnome-shell yaru-theme-gnome-shell

I then updated grub2 after reboot to make the "nomodeset" permanent.

Identity problem

After finally reaching my desktop, everything first seemed reset to default and my files disappeared from Desktop... until I opened a terminal and saw errors related to filesystem rights on /root/ (?!). After digging a little I came to understand that in bash my HOME environment variable is set to /root, that my LOGNAME is "root"... basically bash thinks that I'm root while system/C programs still recognize me correctly as my actual user. The desktop shown is /root/Desktop and not my user desktop, and so on. My files are still present on disk.

Testing some bash variables :

amael@laptop:~$ echo $LOGNAME
root
amael@laptop:~$ echo $USER
root
amael@laptop:~$ echo $HOME
/root
amael@laptop:~$ echo ~
/root
amael@laptop:~ echo $MAIL
/var/mail/root

Note that the prompt shows the correct username whereas the default folder when opening the terminal is the wrong : $HOME = /root.

Non-shell commands show the correct username :

amael@laptop:~$ whoami
amael
amael@laptop:~$ logname
amael
amael@laptop:~$ id
uid=1000(amael) gid=136(vboxusers) groupes=136(vboxusers),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),998(docker)

My /etc/passwd file seems unchanged and correct :

amael@laptop:~$ egrep "^root|amael" /etc/passwd
root:x:0:0:root:/root:/bin/bash
amael:x:1000:136:Amael,,,:/home/amael:/bin/bash
amael@laptop:~$ 

My disks appear mounted in rw mode :

amael@laptop:~$ ls -al /home
total 32
drwxr-xr-x  5 systemd-coredump systemd-coredump  4096 juil. 30  2020 .
drwxr-xr-x 20 root             root              4096 juil. 30  2020 ..
drwxr-xr-x 59 amael            vboxusers         4096 nov.  21 10:15 amael
drwx------  2 root             root             16384 juil. 30  2020 lost+found
amael@laptop:~$ mount | grep mapper
/dev/mapper/vgubuntu-root on / type ext4 (rw,relatime,errors=remount-ro)
/dev/mapper/vgubuntu-home on /home type ext4 (rw,relatime,errors=remount-ro)

What can explain this ? I guess a full reinstallation can solve this but it would be nice not to have to do this.

Thanks for your feedback !

FedKad avatar
cn flag
Just thinking... Some user startup ("profile") scripts may have been corrupted.
Amael H. avatar
td flag
Well, the easiest answer is often the best. I had already checked most of profile scripts and went one again after reading your answer. This time I was successfull : the file /et/environment was containing a dozen of variables including HOME, LOGNAME, USER, MAIL... and all of them referring to root. Deleting all lines except PATH and LANG solved my issue, I can boot again to my profile and got everything back :) Thanks !
Score:0
td flag

@FedonKadifeli was right : my /etc/environment file was somehow filled with many variables that should not be there. Deleting uncommon lines solved my problem !

I compared my file to a live-USB version and also checked here for reference about what should be in this file : Setting PATH variable in /etc/environment vs .profile

Problem solved.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.