Week 5. Topic "Interacting with others"

With the advent of time-sharing computers in the early 1960s, people already passed messages through shared files. It was easy to implement as long as everybody worked in the same computer. Over time, for it to work across incompatible computers a complex web of gateways and routing systems developed. They all had their own formats of e-mail addresses. The common format today, username@domain, was created in 1971. Applications like messaging and chat are also very old ideas, which went through similar developments.

In this week’s unit you will get to know those original tools for viewing users logged on at a specific time, write and talk to them get information on users who are off-line and finally how to mail them - all in the command line.

5.1 Who else is there

5.1.1 who, what, last, etc.

Let’s see what manual pages exist related to ’who’:

man −k  who 
[...] 
w (1)        − Show who is logged on and what they are doing. 
w.procps (1) − Show who is logged on and what they are doing. 
who (1)      − show who is logged on 
who@ (1)     − prints the list of active users on a remote host. 
whoami (1)   − print effective userid 
[...]

The commands who (who is logged in), w (what they are doing) and whoami are interesting for us:

who −H 
NAME   LINE  TIME             COMMENT 
user0  pts/0 2015−02−14 16:26 (1.2.3.4) 
user1  pts/1 2015−02−14 16:47 (5.6.7.8) 
user1  pts/2 2015−02−14 17:32 (5.6.7.8)
shows who else is connected to what terminal and through what IP address.
who am i 
user1 pts/1 2015−02−14 16:47 (5.6.7.8) 
is a special form of who -H referring to one's own login.
w 
 17:34:06 up  8:15,  3 users,  load average: 0.08, 0.09, 0.12 
USER  TTY   FROM    LOGIN@  IDLE  JCPU   PCPU  WHAT 
user0 pts/0 1.2.3.4  16:26 49:26  1:13   0.39s sshd: pi [priv] 
user1 pts/1 5.6.7.8  16:47  6.00s 2.17s  0.39s sshd: pi [priv] 
user1 pts/2 5.6.7.8  17:32  1:26  1.21s  1.21s −bash 
showswho is logged in and what they are doing.
whoami 
user1

if you use multiple accounts and don't know which one you are using. Doesn't make much sense in our practice computer since the shell prompt shows the userid.

The command last (last logged in) lists the users logged in last.

last −5 
user1  pts/1  1.2.3.4 Sat Feb 14 17:50   still logged in 
user1  pts/0  1.2.3.4 Sat Feb 14 17:47   still logged in 
reboot system 3.18.7+ Sat Feb 14 09:13 − 17:56  (00:10) 
user0  pts/2  5.6.7.8 Sat Feb 14 17:32 − down   (00:13) 
user5  pts/2  8.7.6.5 Sat Feb 14 17:03 − 17:24  (00:20)

The user ’reboot’ is a special kind of a user. It shows that the local time is 17:56 and the machine has been running since 09:13 the same day.

5.1.2 finger

The command finger gives you some information of other users in the system: .

finger 19cs000 
Login: 19cs000            Name: Bindu Raj 
Directory: /home/e00000  Shell: /bin/bash 
Office: PR21, 34 56       Home Phone: 012 345 67 89 
Last login Mon Dec 29 19:33 (IST) on pts/0 from 10.20.30.40 
Mail last read Sun Feb 15 00:14 2015 (IST)

The information must be recognizable. It also has the GECOS data we entered with the chfn  command in Week 1.

You can leave additional information like vacation notices or about your current work. See for example:

finger e00000 
[...] 
Project: 
Working on the Apollo mission ;) 
Plan: 
I am out of office till 25 February.
The trick is to put this information in to special files called .project and .plan in your home directory. Create your own .project and .plan files!

5.2 Messaging

5.2.1 write

With write you can write messages directly to other users' terminals.

$ write 19cs042
write: 19cs042 is logged in more than once; writing to pts/2

Let's take a break!

The write program imposes no rules, doesn’t have a protocol except that pressing Return sends complete lines to the other side. The convention is to take turns, ending turn with o (for “over”), and to signal your intent to quit with oo (for “over and out”). Finally, Ctrl-D ends the connection.

The following screen artificially seperates the messages of the two partners:

     userX’s terminal     userY’s terminal 
     −−−−−−−−−−−−−−−−     −−−−−−−−−−−−−−−− 
write userY 
                          Message from userX ...                    $ write userX 
Message from userY ... 
How about lunch? (o) 
                In ten minutes. (o) 
Fine! (oo) 
                          Agreed. (oo) 
                          Ctrl−D 
EOF 
Ctrl−D 
                          EOF
If you don’t want to be bothered with such messages, read the man page for mesg.

5.2.2 talk

talk is what is today known as “chat”. In the example below userX starts a conversation by typing talk userY@localhost. Then userY responds as requested, that will join them in a full screen chat setup.

     userX’s terminal     userY’s terminal 
     −−−−−−−−−−−−−−−−     −−−−−−−−−−−−−−−− 
talk userY@localhost 
                          Message from Talk_Deamon... 
                          talk: connection requested 
                          talk: respond with: ... 
                          $ talk userX@localhost 
                          [connection established] 
X types here         Y types here 

Ctrl−C         Ctrl−C 

5.3 Mail

The system provides a postal system for communicating with other users. You must have noticed the message about mail as you logged in. You might even get notices of newly arrived mail.

To read your mail, open your mail client, often simply called mail. An overview of your mails, called mail headers, will be printed. To read a the current message, just type p (print), or to read a specific message type p N, N being the message number. h (headers) gives you the listing of headers. s FILENAME (save) will save a message in a file. d deletes messages, and q quits the program. Here is a session reading mail:

mail 
Heirloom mailx version 12.5 6/20/10.  Type ? for help. 
”/var/mail/e00000”: 2 messages 
>O  1 Imran Khan Fri Feb 11 19:27   31/794   Hi there! 
>O  2 Sharuk Khan Fri Feb 12 21:12   31/794   Greetings 
>O  3 Kublai Khan Fri Feb 12 09:13   31/794   Bye bye 
p 1
 
Message  1: 
From Imran Khan  Fri Feb 11 19:27:50 2015
[...] 
Date: Fri, 13 Feb 2015 19:27:50 +0530 
Subject: Hi there! 
User−Agent: Heirloom mailx 12.5 6/20/10 
Content−Type: text/plain; charset=us−ascii 
From: e00000@arm (Dummy User) 
Status: RO 

Hi
[...]

Sending mail to someone is straightforward:

mail userY 
[or within mail, m userY
Subject: Just to say hi! 
Type in the text of the letter 
on as many lines as you like.
...
 
Ctrl−D 
EOT 
?

Here too Ctrl-D signals the EOT (end of text).

For practice, send a mail to yourself. (It is not as odd as it may sound - it’s a handy way of taking notes.)

There are other ways of sending mail – you can send a previously prepared letter, you can mail to a number of people all at once, and you may be even able to send mail to people on other machines. In this week’s assignment you will learn more about these things.

Note that the simple mail program we have in the practice computer is not a full featured with a rich set of encryption like SMIME, SSL, SMTP-Auth, etc. Which are beyond this course. But simple things like “signature” works. Create a file called .signature (note the dot as the first character) in your home directory and then send a mail.

Summary

In this week you’ve learnt:

  • That the who and w commands tell you who is logged in
  • that last and finger commands tells you about off-line users, and to make use of .project and .plan files
  • to write and talk to others
  • to use the built-in postal system mail

Last modified: බ්‍රහස්පතින්දා, 16 දෙසැම්බර් 2021, 10:01 ප.ව.