Linux error ttyname failed: inappropriate IOCTL for device solution

when I use git push, hexo deploy and similar operations, I often see an error message ttyname failed: Inappropriate ioctl for device. How does this work, not 0 errors,0 warnings work?The solution to this problem is documented here.

problem cause

Ubuntu knows that not everyone will perform graphical logins on the root account, so in the default .profile file it is set to generate a false error in this case. As you can see, there is a line at the end of the /root/.profile.

mesg n || true

what is this?This is to prevent programs like talk from writing to your console, which is especially important if you are logging into your root account via a text session. || true is to prevent an error when the request for tty fails from causing the shell script to abort.

put this sentence in the .profile file, which allows you to execute this sentence every time you run bash. When you run from a painting without a TTY device, you will see an error, and this will not affect other programs, just a message will be displayed.


is harmless, but it’s not comfortable to see the error message all the time, so get rid of it.

change /root/. Profile filemesg n || true to the following.

tty -s && mesg n || true

this allows mesg not to send a message when there is no tty, but to continue calling when there is one. Now you can see that ttyname failed: impatient ioctl for device.

Read More: