5 Collaboration tools

In the early days it was common for many people to work in one machine, often at the same time. Naturally ideas like messaging, chat, mail, etc. were part of Unix right from the beginning. 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 e-mail in the command line.

5.1 Who are my neighbours

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 
NAME    LINE  TIME             COMMENT 
user0  pts/0 20150214 16:26 (1.2.3.4) 
user1  pts/1 20150214 16:47 (5.6.7.8) 
user1  pts/2 20150214 17:32 (5.6.7.8) 
$ who am i 
user1 pts/1 20150214 16:47 (5.6.7.8) 
$ 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 
$ whoami 
user1

As you can see in the example above, who -H prints headers to the columns. who am i is a special version of who showing details of one’s own session. The output of w above shows that two users are logged in remotely, user1 has two sessions open.

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

# last 
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 e00000 
Login: e00000            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)

This information is called GECOS (General Electric Comprehensive Operating System) in Unix. It is a term originated in a now extinct operating system. Some information like the phone number can be can be set by the user. The command is chfn (change user name and information). In the practice computer only the super user can change the user names, but you can set other values.

Excercise: Add (hypothetical) home and office phone numbers and a room number to your GECOS.

You will 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 create special files like .project and .plan in your home directory. Since we haven’t done file editing yet, you can create those files through the following hack:

$ echo ”Working on the Apollo mission ;)” > .project 
$ echo ”I am out of office till 25 February.” > .plan

5.2 Messaging

5.2.1 write

If you are working in a multi-user Unix system, you are bound to see messages like Message from userX pts/2 ... accompanied by a beep tone. UserX wants to write to you, to respond you start write giving the login name (and the terminal, if userX is logged in more than one).

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), which stands 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) 
                          How about lunch? (o) 
                          In ten minutes. (o) 
In ten minutes. (o) 
Fine! (oo) 
                          Fine! (oo) 
                          Agreed. (oo) 
                          Ctrl
EOF 
Ctrl
                          EOF

If you don’t want to be bothered with such messages, refer 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 
Ctrlc to end             Ctrlc to end 
_____________________     ______________________ 
 
 
Typing of Y reflected     Typing of X reflected

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 arriaved 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 msg.no’. ’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.

$ 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  2 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! 
UserAgent: Heirloom mailx 12.5 6/20/10 
ContentType: text/plain; charset=usascii 
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! 
[Now type in the text of the letter 
on as many lines as you like... 
... 
To finish, type a Ctrld on a new line] 
Ctrl
EOT 
?

The Ctrl-d signals the EOT (end of text).

For practice, send mails 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 Raspberry is a full featured with a rich set of encryption like SMIME, SSL, SMTP-Auth, etc. Which are beyond this course. Here you can demonstrate that the common “signature” attachment works by creating a file called .signature (note the dot as the first character) in your home directory.

5.3.1 Command line calender, only for freaks

The original calendar program cal is ‘read only”, you can not enter your appointments in to it. Such a calendar program is included in the Raspberry, called pal.

See how you could maintain your appointments in pal. This is only for the freaks. ;)

5.4 Assignment for the week

There are two time slots reserved for the assignment: see the on-line platform for details.

This assignment is fun, only if there are many users logged in at the same time. So, be there! This assignment is open to all who have collected their account in assignment 1, irrespective whether you passed the other assignments.

Please note that, you might need some “training” before the fun begins. So do a rehearsal before the session.

During the assignment you will be collecting the data to be submitted in a text file and will mail the file to user e00000. To do that you need to know few things which we haven’t covered yet. Here they are, without explanations:

Except otherwise stated, add the outputs of the steps below to a file called ’evidence’:

Step 1: Print the system date.

Step 2: Print ’who am i’.

Step 3: Record the ’who’ and ’what’ of the others who are logged in.

Step 4: Get the last 5 logins in to the system

Step 5: Find out when the system was last rebooted

Step 6: Create your own .project file

Step 7. Finger a couple of users and record one with a .project file.

Step 8: Send a couple of ’write’ messages to others. (This one you can not record)

Step 9: ’talk’ with sombody. (This too you can not record)

Step 10: Read your mail. There will be a mail from e00000. Reply to it! (If you delete the message by mistake, you can just write a new mail.)

Step 11: Mail the your recording of steps 1 - 7 to e00000.

Addition: You need to ”submit” in the assignment tool with a short note like ”I have sent the mail to e00000”, as explained the Announcement forum.

Summary

In this week you’ve learnt: