home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


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


/dev/tty07

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/ttyp x or /dev/ttyq x , 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
    clear
    fortune
endif

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

- JP


Previous: 3.7 Detaching a Session with screen UNIX Power Tools Next: 4. Organizing Your Home Directory
3.7 Detaching a Session with screen Book Index 4. Organizing Your Home Directory

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