Linux or UNIX – Find tty name

by on February 6, 2006 · 7 comments· LAST UPDATED December 24, 2006

in , ,

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


Use following command:
$ tty



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


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:

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 7 comments… read them below or add one }

1 Rajiv February 2, 2009 at 9:40 pm

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


2 Mohammed February 10, 2009 at 12:36 am

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


3 MySpace Friend Adder June 21, 2009 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 November 13, 2009 at 6:08 am

I was looking for this info. thanks.


5 Charanjit Singh December 16, 2009 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 January 2, 2010 at 4:46 am

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

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


7 Abdul Rohman September 24, 2012 at 6:36 am

How to go to specified tty? if I login last time with pts/2, but now I login again with pts/3, can I go to pts/2 now, how to do it? Thanks before


Leave a Comment

Tagged as:

Previous Faq:

Next Faq: