Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone explain to me what the purpose of /dev/tty

Tags:

linux

unix

Can anyone explain what the purpose or how to use /dev/tty

like image 793
Victor Avatar asked Oct 30 '25 00:10

Victor


1 Answers

You can start with the POSIX spec. From there, read about the "controlling terminal" of a process.

But just for example... /dev/tty is how a command like "ssh" can read your password even if its standard input comes from somewhere else:

tar cf - . | ssh dest 'tar xf -'

If ssh decides to prompt you for a password, it will read it from /dev/tty instead of stdin.

Conceptually, /dev/tty is "the keyboard and text terminal". More or less.

like image 90
Nemo Avatar answered Oct 31 '25 16:10

Nemo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!