Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to automatically be put in a screen if I log in on a tty (if I'm using e.g. Terminal, I can simply open a new window instead.) I've already figured out the screen parameters and startup file configurations; I just need a reliable way to check whether the terminal is a tty, a terminal emulator, or something else. As far as I know, there are two main types of terminals: tty's (like the ones you can get to in Linux with ctrlaltF#) and terminal emulators (e.g. Apple Terminal, xterm, etc.)

What are the different types of terminals one is likely to encounter today, and how can I tell which kind the current session is in from a script?

(I have Linux and Mac systems, and I would like the test to work on both. If it requires a non-standard program, that should be available in the Debian, Ubuntu, and Homebrew repositories.)

share|improve this question

1 Answer 1

I know of two different types of (pesudo) terminals: tty and pts. ttys are the terminals reachable using ctrlaltF#. pts` are the terminals started inside gnome-terminal (or konsole if using kde, or xterm).

There is a command called tty which will tell you what terminal you are currently running on.

Output from running inside a gnome-terminal:

$ tty
/dev/pts/2

Output from running in ctrlaltF1

$ tty
/dev/tty1

I do not know whether there are more types of terminals. Those two are the only ones I have encountered in my many years of using linux.

Here are more information about terminals:

share|improve this answer
    
Ah…Macs seem to use a different system; I ran tty from a Terminal window and got /dev/ttys002. –  Blacklight Shining Nov 19 '12 at 16:00
    
So…should I just assume there are only tty's and emulator programs, and check that the output of tty matches /dev/tty<number>? –  Blacklight Shining Nov 19 '12 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.