Questions tagged [pty]

Pseudoterminals (also spelled “pseudotty” or “PTY”) are pseudo-devices used with ttys whose emulators run in userspace. Use the [tty] tag for broad (text terminal)-related questions, and the [console] tag for terminal devices pertaining to the system console.

Filter by
Sorted by
Tagged with
2 votes
1 answer
48 views

zsh zpty does not work on macOS, does work on Linux?

zsh module zsh/zpty seems to work perfectly well on my Linux virtual machine running on Apple M1 macOS machine. But the same does not work on macOS (even on the same host machine). I have tried this ...
  • 476
1 vote
1 answer
950 views

"sudo: unable to allocate pty: No such device" in chrooted Linux

Added: After reading suggested as duplicate Which of proc, sys etc. should be bind-mounted (or not) when chrooting into a "replacement" distribution? : How I know: it is customary to invoke ...
0 votes
0 answers
87 views

How does the use_pty sudoers option prevent a persistence attack?

As a rule in the Debian 10 hardening guide, and various other audit guides of the Center for Internet Security (CIS), setting the use_pty sudoers option is recommended for the following rationale: ...
  • 1
3 votes
1 answer
74 views

SSH under pty still promts stdin from terminal

I am currently learning about the pseudo-terminal functionalities in C. I am able to create the master, slave end of the pty, after fork, I have set the stdin, stdout, stderr to fd slave , after exec ...
0 votes
1 answer
160 views

How to get color in terminal but no color in output file [duplicate]

To show output in both terminal and to a file, tee can be used like below ls --color=auto | tee opfile But now, there is no color in the terminal. If I force colors, opfile also has colors which ...
  • 4,217
0 votes
1 answer
569 views

Why dmesg output displayed on /dev/tty1

This is still related to my yesterday thread, so there's alert or maybe it's just log that displayed on my terminal on /dev/tty1. Ofcourse it's annoying because it's displayed in my bash prompt, so ...
1 vote
1 answer
80 views

Do programs that create pseudoterminals emulate terminals?

The way I understand it, applications that create a pty (a master/slave pair) can be separated into 2 categories: terminal emulators (xterm, urxvt, ...), which supposedly produce graphical output the ...
  • 3,073
0 votes
1 answer
100 views

Verbose logging: howto save disk?

Situation I'm running a program on Linux, which produces a lot of verbose logs to stdout. The program itself is put into background by using systemd.service facilities. Until now, I have configured ...
  • 209
1 vote
1 answer
246 views

How do I display a bash prompt when using SSH without a pseudo-terminal?

When the connection is slow, I connect to remote computers using SSH without allocating a pseudo-terminal (e.g. ssh -T user@example.com or ssh user@example.com bash). Although I am able to use the ...
  • 2,304
2 votes
1 answer
346 views

Perplexity about TTY and PTY

I'm trying to understand this topic but, apparently, for my brain it is too hard. Terminal device entries normally reside in two directories: /dev and /dev/pts. The /dev directory contains entries ...
0 votes
0 answers
106 views

How does terminal in Linux actually work? [duplicate]

I'm using Linux console for years, but currently started thinking of how it actually works. Typing a command as a string and pressing Enter returns its output in the same terminal window. Opening a ...
  • 209
0 votes
1 answer
2k views

What is Virtual Serial Port in QEMU?

Ubuntu 20.04 both on host and guest. I'm new to QEMU and trying to set up guest-host communication via serial port. The QEMU documentation says that -serial dev option: Redirect the virtual serial ...
  • 209
-1 votes
2 answers
351 views

Why does the input cursor always go from the top to the bottom in a terminal emulator?

I noticed that the terminal cursor starts at the top of the terminal and slowly moves down as more commands are executed, until ultimately settling on the bottom regardless of the number of commands. ...
1 vote
3 answers
210 views

What "bad" things may happen (and why) if a Terminal Emulator and the Shell running in it are using different TERM types?

For example, in PuTTY's configuration I set terminal type to xterm-256color but after SSH login I change it with export TERM=linux in the shell. I know it works quite well for most time. Just want to ...
  • 164
1 vote
2 answers
273 views

How can I clean up output from expect?

Background: I'm using expect to connect between AMCE.sh and a managed network switch. I can connect to the switch via SSH, log in and issue commands but because of the way the switch manages SSL ...
  • 175
-1 votes
1 answer
238 views

Why is Linux giving a pts number for real terminal console? (which is not an emulated terminal like ssh or xterm)

I read that pts is a pseudo-terminal (that we get through ssh or xterm) and tty is the native terminal. I didn't connect to my PC through ssh or xterm, but I am still getting pts/0 and pts/1 when I ...
1 vote
0 answers
144 views

Interpret bash escape sequences and other characters using ncurses

I want to design a terminal multiplexer like tmux, but not that complex, something minimal, that works remote, using ncurses. On the server side, the workflow is as follows: The server process ...
0 votes
1 answer
90 views

Are there tools that I can use to obtain a snapshot of terminal or pty state? [duplicate]

Please stop marking this question as a duplicate, it's not a duplicate. Thanks. Consider the sequence of a, followed by \x1b[D ("cursor back"), followed by b. This would produce an output of ...
  • 2,135
1 vote
1 answer
2k views

Shell Upgrade: script typescript command using bash

Can anyone explain what this means: SHELL=/bin/bash script -q /dev/null It is used to upgrade a shell in a CTF in HTB: SHELL=/bin/bash script -q /dev/null Ctrl-Z stty raw -echo fg reset xterm ...
0 votes
1 answer
118 views

script -c '...' does NOT print colors

edit: I was in EternalTerminal session, and that was the source of the difference. In a regular ssh, it works. I need to get commands in a pipe to believe they are in a PTY and emit colorized output. ...
0 votes
0 answers
1k views

Link character device to pty with socat

I have a "regular character device" - not sure of the proper naming - that doesn't support ioctl on an embedded device (/dev/appvcom). I need to connect to it with an application that uses some ioctl ...
  • 101
0 votes
2 answers
233 views

How to replace program running in graphical terminal with another program?

Lets say I have top or some ncurses program running in a graphical terminal, and from outside this terminal I'd like to execute a command, that would replace top with another program of my choosing. ...
0 votes
1 answer
561 views

Alternative to "openvt", but for pseudo terminal (pts). Exists?

Alternative to "openvt"...but for pseudo terminal(pts)... Exists? Openvrt operate only tty...but not pts. (Example: lauch comand in specific pts and with user of shell pts destination) Command <...
1 vote
1 answer
687 views

How bash sets tty attributes before and after running a command?

Open xterm, run tty and see pseudo terminal slave file (let's say it is /dev/pts/0). Then open another xterm and run $ stty -F /dev/pts/0 speed 38400 baud; line = 0; lnext = <undef>; discard = &...
3 votes
1 answer
2k views

What is the difference between IXON and IXOFF tty attributes?

To be specific, let's speak in pseudo-terminal terms. Suppose we have file descriptors master and slave for a pseudo-terminal pair (suppose it is a controlling tty). Disabling IXON on master (or slave,...
0 votes
1 answer
473 views

Detect pty buffer capacity

I am using the tty subsystem of Linux to emulate serial ports. The emulated serial ports are used by an application that expects a physical serial port. In my case, the application is running under ...
  • 323
0 votes
0 answers
556 views

Why does changing my home directory in WSL break my PATH but only in the second window in tmux?

A bit ago, I found it necessary to set my home directory to my One Drive in WSL. Thanks to this post I was even able to get my permissions working correctly within WSL (Ubuntu 16.04 LTS). However, ...
  • 4,363
0 votes
0 answers
651 views

Restricted shell within docker container

Some context for my question: I am working on a pty NodeJS server running in docker where I want to provide users connecting to the shell an isolated environment where they can play around with ...
7 votes
1 answer
650 views

Why blocking read() on a pty returns when process on the other end dies?

When slave side of pty is not opened, strace on the process, which does read(master_fd, &byte, 1);, shows this: read(3, So, when nobody is connected to the slave side of pty, read() waits for ...
1 vote
1 answer
673 views

How TTY differs from an ordinary file? [duplicate]

I'm trying to understand ssh's -t option: -t Force pseudo-terminal allocation. This can be used to execute arbitrary screen- based programs on a remote machine, which can be ...
0 votes
0 answers
37 views

Why does macOS specific terminal shortcuts like Left-arrow + Option work in a remote shell on Ubuntu with a dedicated pty?

Why do macOS specific terminal shortcuts like Left-arrow + Option work in a remote shell on Ubuntu with a dedicated pty? I'm trying to understand why macOS specific terminal shortcuts like Left-arrow ...
  • 3,659
2 votes
1 answer
343 views

PTY master missing read function

How can terminal emulator read from ptm device while it missing read function? There is a PTY driver: https://github.com/torvalds/linux/blob/master/drivers/tty/pty.c. I see pty_write function, but can'...
  • 151
3 votes
1 answer
876 views

What exactly tty line discipline does with input from pty slave device?

I know that tty line discipline processes special characters (such as ^C, ^? and etc), but it is only about input from pty master device. But what about input from pty slave device? What tty line ...
  • 151
1 vote
0 answers
94 views

Can terminal parameter changes on the slave side be detected on master?

A process (creator) creates a pseudo-terminal master/slave[/dev/pts/1] pair. Another process (consumer) opens /dev/pts/1 and changes the serial terminal parameters with tcsetattr. Is there a way for ...
0 votes
2 answers
96 views

less: advertise terminfo through pipe

If I do ls | less, ls detects that it isn't connected to a terminal, which is fair enough. Except that less is connected to a terminal. In this setup, ls could produce the coloured and columnised ...
21 votes
1 answer
4k views

What does 'script /dev/null' do?

Every time I log into a VM with root, su into a user account, and try to use screen it throws an error: Cannot open your terminal '/dev/pts/0' - please check. A Stack Overflow post said I needed to ...
  • 313
4 votes
1 answer
7k views

ssh - Disable pseudo-terminal allocation

ssh client option "-T" is Disable pseudo-terminal allocation. If I turn on this option, the remote sshd will not allocate a pty to run remote command. How the output of remote command transfer back ...
  • 41
5 votes
1 answer
2k views

Where does `/dev/pts/ptmx` come from? [duplicate]

On my Archlinux, /dev/pts is mounted by the devpts, so who created the /dev/pts/ptmx device node? What's the purpose of this node? it's the same (Major=5 Minor=2) device node same as /dev/ptmx/, but ...
2 votes
3 answers
3k views

How can we find out the pseudoterminal master and slave from each other?

A pseudoterminal has a pair of master and slave. How can we find out the master device file from a slave device file (e.g. /etc/pts/3)? I only find /dev/ptmx and /dev/pts/ptmx, but they can't be ...
  • 94.9k
6 votes
1 answer
3k views

Virtual serial port between docker containers

I can create two linked virtual serial ports on a Linux system with socat, and pretend one end is a serial device, and the other one is some code that uses the device. The socat command would look ...
1 vote
0 answers
623 views

PTY allocation request failed on channel 0

My remote vm server's password has expired, i cann't change password. [user@localhost ~]$ ssh root@x.x.x.x root@x.x.x.x's password: PTY allocation request failed on channel 0 WARNING: Your password ...
  • 11
3 votes
1 answer
915 views

read(2) blocking behaviour changes when pts is closed resulting in read() returning error: -1 (EIO)

I'm trying to figure out how I can reliably loop a read on a pt master I have. I open the ptmx, grant and unlock it as per usual: * ptmx stuff */ /* get the master (ptmx) */ int32_t masterfd = open("/...
3 votes
1 answer
415 views

Do pty devices have two input buffers?

When terminal devices are in cooked mode, bytes input into terminal is cached and processed by kernel, some bytes are used for line editting and "cosumed", making read return one line a time. But for ...
1 vote
2 answers
162 views

Why application does not run from SCREEN without delay?

Suppose we need to run application in screen and keep it running when screen exits. The following command does the job, but only if "sleep 1" is appended to it. Why it does not work without "sleep 1"? ...
-2 votes
1 answer
478 views

Can't open a screen on pty freshly created [closed]

I have a program that communicates through a serial protocol uart. I would like to test this protocol using simple terminal emulator running on the same computer. This program opens /dev/tty. I would ...
  • 115
0 votes
1 answer
118 views

Software flow control: why TX is blocked on terminal?

Why terminal cannot send data after ^S was pressed? I have always thought that ^S is used by terminal to tell tty driver that tty driver must not transmit data from application TO terminal (when it is ...
0 votes
0 answers
426 views

Why does ssh allocate a tty on server side?

Basically when you run an interactive program on the server you need to use ssh -t instead of ssh. For example: This works: ssh -t user@server top. This doesn't work: ssh user@server top. Question ...
  • 4,024
2 votes
1 answer
206 views

Are all the slaves paired with the same master?

In bash in lxterminal $ tty /dev/pts/2 $ ls /dev/ptmx -l crw-rw-rw- 1 root tty 5, 2 May 26 09:38 /dev/ptmx On Ubuntu, is there only one master for all the processes, and all the slaves are paired ...
  • 94.9k
2 votes
2 answers
2k views

Do the output of command `tty` and the file `/dev/tty` both refer to the controlling terminal of the current bash process?

From man tty tty - print the file name of the terminal connected to standard input $ tty /dev/pts/2 From APUE: Historically, the name of the controlling terminal in most versions of the UNIX ...
  • 94.9k
2 votes
2 answers
324 views

Does the master device appear just like a standard terminal to the driver program?

From the Linux Programming Interface The key point about a pseudoterminal is that the slave device appears just like a standard terminal. All of the operations that can be applied to a terminal ...
  • 94.9k