Linux or UNIX – Find tty name

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:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • Rajiv Feb 2, 2009 @ 21:40

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

  • Mohammed Feb 10, 2009 @ 0:36

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

  • MySpace Friend Adder Jun 21, 2009 @ 2:54

    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!

  • Limousine Software Nov 13, 2009 @ 6:08

    I was looking for this info. thanks.

  • Charanjit Singh Dec 16, 2009 @ 11:36

    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.

  • /dev/null Jan 2, 2010 @ 4:46

    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…

  • Abdul Rohman Sep 24, 2012 @ 6:36

    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

  • aref ghobadi Aug 22, 2015 @ 7:10

    Hi Vivek
    thank you

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum