Ubuntu – How to check which tty I’m currently using

command linetty

There are 7 terminals that can be used in our system. tty7 is GUI based.

How can I check which tty I'm currently using?

Best Answer

There are several ways to find this out. I would go with the who am i (not who) command:

$ who am i
ravexina    tty2        2017-04-10 11:19 (:0)

When I'm in a graphical terminal, it would return something like:

ravexina    pts/0        2017-04-10 1:19 (:0)

Under ssh session using a graphical terminal result is the same, but instead of (:0), I will get my machine IP (192.168.x.x). other commands like w, who, pgrep, ps, etc are helpful too.

For example to find out at which tty my graphical interface is running:

ps $(pgrep Xorg)

Which in my case, because I don't use any display manager like gdm or slim it will produce:

 PID  TTY      STAT   TIME COMMAND
 1693 tty1     Sl     0:05 /usr/lib/xorg/Xorg
Related Question