sudo tries to open /dev/tty for read-write and prints this error if it fails. You indicated in the comments that / dev / tty is missing from your system.
Sudo has the -S option to read the password from standard input instead of / dev / tty. You can run sudo -S to become root.
Regarding the recovery of / dev / tty, it is possible that a server reboot will be enough; the system can recreate all devices in / dev at boot time. In addition, you use the mknod command to create the device, but you need to know the correct primary and minor numbers for the tty device. On an Ubuntu system, I have access, I see these entries in / dev:
crw------- 1 root root 5, 1 Apr 16 18:36 console crw-rw-rw- 1 root tty 5, 2 Sep 24 15:35 ptmx crw-rw-rw- 1 root tty 5, 0 Sep 24 14:25 tty
In this case, the main number is 5, and the youngest is 0./dev/console and / dev / ptmx have the same main number. So I checked / dev / console or / dev / ptmx to find the correct main number, then run:
mknod /dev/tty c major 0
where "major" is the correct base number.
After reconstructing / dev / tty, make sure the permissions are correct:
chmod 666 /dev/tty
Kenster
source share