Linux or UNIX – Find tty name

by Vivek Gite · 6 comments

To print the file name of the terminal connected to standard input (keyboard) you need to use command called tty.

This command is available on Solaris, Linux, FreeBSD, and other Unixish operating systems.

The tty utility writes the name of the terminal attached to standard input to standard output.

You can also use who or w command to find out terminal/tty. Type tty command as follows:
$ tty

Output:
/dev/pts/2

Use following command:
$ tty

Output:

/dev/tty3

You can also use w or who commands to find out tty:
$ w

Output:

NAME     LINE         TIME         COMMENT
vivek    tty1         Feb  6 00:26
root     tty2         Feb  5 14:57

OR use who command:$ who

vivek    tty1         Feb  6 00:26
root     tty2         Feb  5 14:57

In above output second column indicates the tty name.

See also:

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 6 comments… read them below or add one }

1 Rajiv 02.02.09 at 9:40 pm

As a Newbie, I am always searching online for articles that can help me. Thank you

2 Mohammed 02.10.09 at 12:36 am

Finally, the answers that I was looking for! Cheers mate.

3 MySpace Friend Adder 06.21.09 at 2:54 am

Very well thought out and informative. I’m sure many others enjoy reading this too, but are just a little scared to post – anyway – thanks again!

4 Limousine Software 11.13.09 at 6:08 am

I was looking for this info. thanks.

5 Charanjit Singh 12.16.09 at 11:36 am

Hi Vivek
Thanks for this post, but what is the file in tty configuration is saved. Say If I want to disable the login in purticular tty. Where I will find out this file.

6 /dev/null 01.02.10 at 4:46 am

maybe too late for an answer, but could help others.
if your distro uses inittab, edit it
/etc/inittab

THANKS!!!! tty too obvious but i did not knew it…

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All