Score:3

sudo: unable to allocate pty: No such device

tk flag

Ubuntu 22.04.01 LTS Gnome

Changed python version which resulted in inability to access Terminal and a few other things.

Used a liveUSB and then selected to try ubuntu.

In that terminal entered:

sudo fdisk -l
sudo mount /dev/sda1 /mnt/
sudo mount --bind /proc/ /mnt/proc/
sudo mount --bind /sys/ /mnt/sys/
sudo mount --bind /dev/ /mnt/dev/
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt/

That code executed fine. I then wanted to change python3.11 to python 3.10 with

sudo update-alternatives  --set python /usr/bin/python3.6

However I get the error listed in the title. Other attemps with various code to change python also raise the same error. Can't find any similar questions on here.

muru avatar
us flag
You also need to mount `/dev/pts`.
Score:2
jp flag

PTY(AKA Pseudoterminal) is used for implementing terminal emulators such as xterm … It is involved in enabling the interpretation of passed data in the same way a real terminal would interpret the data … This becomes important when sending input to programs(such as su and sudo) that normally refuse to read input from pipes.

In Ubuntu(and many other Linux distributions), PTYs are pseudo-devices identified under /dev/pts and thus a simple mount —bind won’t make it available in the target mount-point but, a recursive mount —rbind will.

So you can solve this by either mount binding /dev/ recursively using the option —rbind like so:

sudo mount --rbind /dev/ /mnt/dev/

Or by additionally mount binding /dev/pts/ directly like so:

sudo mount --bind /dev/pts/ /mnt/dev/pts/

Or if you are not going to need such programs as su and sudo in the target chroot, then you can just become the user root before you run your commands like so:

sudo -i

Then you’ll be able to run your commands in the same shell with elevated permissions without the need to use sudo.

Score:-2
tk flag

Remove sudo from the commands.

I sit in a Tesla and translated this thread with Ai:

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.