Detect the device file used by a terminal

When a terminal or console is started a /dev/ttyX file is created for that instance. From that given terminal, is it possible to detect through a command what is the ttyX file being used?

Upvotes: 0

Views: 137

Answers (2)

user149341
user149341

Reputation:

If what you're looking for is a command, it's tty.

Upvotes: 2

You want ttyname(3), which is POSIX-standard.

Upvotes: 2

Related Questions