Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 3.7 Detaching a Session with screen Chapter 3
Logging Out
Next: 4. Organizing Your Home Directory

3.8 What tty Am I On?

Each login session has its own tty (38.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 (1.33) 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.

To do that, run the tty command at a shell prompt in the window:

% tty

You can tell other users to type write your-username tty07.

Some systems have different kinds of ttys: a few dialup terminals, some network ports for rlogin and telnet, etc. (1.33). You or your system administrator can look in a system file like /etc/ttys to find out which ttys are used for what. You can use this to make your login setup more automatic. For example, most network terminals on our computer have names like /dev/ttypx or /dev/ttyqx, where x is a single digit or letter. I have a test in my .logout file (3.1) that clears the screen and prints a fortune (3.3) on all ttys except network:

` ` !~ 

# Clear screen and print fortune on non-network ttys:
if ("`tty`" !~ /dev/tty[pq]*) then

The GNU version of tty is on the CD-ROM.

- JP

Previous: 3.7 Detaching a Session with screen UNIX Power ToolsNext: 4. Organizing Your Home Directory
3.7 Detaching a Session with screen Book Index4. Organizing Your Home Directory

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System