Xubuntu 16.04 ttyname failed Inappropriate ioctl for device

21,164

The ultimate cause is that Xubuntu clearly didn't expect anyone to perform a graphical login to the root account, so its default .profile file generates a spurious error in this situation. If you look at the last line of /root/.profile, you find:

mesg n || true

This is to prevent programs like talk from writing to your console. This is especially important if you logged in to root via a text session (su from xterm, ssh, etc.) since those messages can clutter up the screen.

The || true bit is to prevent the shell script from terminating if mesg should fail (as it is failing here), but that doesn't prevent it from generating error messages when it fails, which you are seeing.

The cause of the problem is that by putting the line in .profile, it runs every time bash is executed, even when it is run from a session without a tty device (like during the earliest parts of a graphical login), so you see the error. It's harmless, because mesg would be meaningless when run from a session without a TTY anyway, but the desktop doesn't know this and displays the message.

One solution (as a comment in a question you referenced said) is to change the line so it doesn't try to call mesg when there is no TTY:

tty -s && mesg n || true

This tells it to not try calling mesg when there is no TTY, but will still call it when there is a TTY (e.g. from an SSH login).

Share:
21,164

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I have a need to launch Xubuntu as a root user for a stand-alone demo system.

    Whether I use the auto-login feature from lightdm, or when logging in via "Other" > "root" when prompted, I always get the following response:

    Error found when loading /root/.profile
    mesg: ttyname failed: Inappropriate ioctl for device
    As result the session will not be configured correctly.
    You should fix the problem as soon as feasible.
    

    enter image description here

    After clearing the popup box above, the system performs as expected with the ROOT user.

    Here are the contents of /etc/lightdm/lightdm.conf:

    [Seat:*]
    autologin-guest=false 
    autologin-user=root
    autologin-user-timeout=0
    

    I have seen other similar issues online relating to Vagrind, and that the issues was solved with some of the latest updates, but this still seems to be happening on Xubuntu 16.04

    https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1584488

    How to solve `ttyname failed: Inappropriate ioctl for device` in Vagrant?

    Most forums state that this message is erroneous and should not be displayed. Is there anyway to launch Xubuntu automatically as root while avoiding this erroneous popup?