2.7. What tty Am I On?
Each login session has its own tty (Section 24.6) -- a Unix device file that handles input and output for your terminal, window, etc. Each tty has its own filename. If you're logged on more than once and other users want to write or talk (Section 1.21) to you, they need to know which tty to use. If you have processes running on several ttys, you can tell which process is where.
% tty /dev/tty07
You can tell other users to type write your-username tty07.
Most systems have different kinds of ttys: a few dialup terminals, some network ports for rlogin and telnet, etc. (Section 1.21). A system file like /etc/ttys lists which ttys are used for what. You can use this to make your login setup more automatic. For example, most network terminals on our computers have names like /dev/ttypx or /dev/pts/x, where x is a single digit or letter. I have a test in my .logout file (Section 4.17) that clears the screen on all ttys except network:
# Clear screen non-network ttys:
` ` Section 28.14
if ("`tty`" !~ /dev/ttyp?) then clear endif
(Of course, you don't need to clear the terminal screen if you're using an xterm window that you close when you log out.)
Copyright © 2003 O'Reilly & Associates. All rights reserved.