07. Communication Utilities

Communication with Other Users

  • Linux is designed to be a multi-user system, so it is appropriate to have utilities that help users communicate within the system as well as outside the system
  • For quick communication with users within the system
    • write
    • talk
    • Useful for a quick message between users. The “original” instant messaging tool
    • Require that both users are currently logged in
    • Will take over the screen of both users
    • Since this is not a GUI environment where you can have a window for your work and a different window for messages, when write or talk runs, your work screen will be suspended for messages from write or talk
  • To communicate with users within the system and outside the system:
    • mail
    • This is an email tool
    • Only the email sender needs to be currently logged in

write

  • To start write, type: write userID
    • your work screen is suspended and reserved for write
    • then you type your line of text message
  • The other user will:
    • see on screen a write request message with your userID and your text message
  • The other user can:
    • respond by typing write yourID and reply with his/her text message
    • you both now are running write and can send messages to each other
  • Or the other user can:
    • ignore you, in which case you don’t get a message back but you are still in write
    • you can choose to write another message, or ‘get the hint’ and quit write
  • To end
    • control-d

talk

  • To start talk, type: talk userID
    • Your work screen is suspended and reserved for talk. It is split into 2 halves, for you and for the other person
    • Then you type your line of text message
  • The other user will:
    • see a talk request message with your userID and your text message
  • The other user can:
    • respond by typing talk yourID and reply with his/her text message. His/her screen is also split into 2 halves to show the correspondence
    • you both are now using talk to send messages
  • Or the other user can:
    • ignore you, in which case talk will keep requesting a response from this user until you choose to quit out of talk
  • To end:
    • control-c

mesg

  • To prevent other users from interrupting your work with write or talk, use mesg (for messaging)
  • 2 ways to use mesg
    • With no argument: mesg
      • check messaging status, mesg will return:
      • y which means you can receive messages
      • n which means you refuse messages
    • With one argument:
    • mesg y set messaging to on so you can receive messages (only applies to current session)
    • mesg n set messaging to off so no messages will get through (only applies to current session)

mail

  • mail: the “original” email tool. It is only for emailing text and cannot accept attachments
  • But it is the basic email that comes with every Linux system, so you can use it when “fancier” emails are not / cannot be installed
  • As with other email tool, and unlike write and talk, the user you send email to doesn’t have to be currently logged in and his/her messaging status doesn’t affect email
  • 2 modes: send and receive
  • The mail commands in the next slides are either send mode commands or receive mode commands

mail Send Mode: How to Send Mail

  • Send mode is used to send mail
  • To start:
    • mail userID for sending email to a user in the same system
    • mail full_email_address for sending email to someone outside the system
  • mail will respond with:
    • subject: you can fill in the subject or hit enter for no subject
  • Then start typing the text for your mail message
  • When done:
    • control-d to send
    • mail will respond with cc: you can add addresses for cc, or hit enter to leave it blank
    • or
    • control-c to cancel and not send (to “kill” a message in Linux)
    • you will be asked to do control-c twice to confirm
    • a message that is killed will be appended to the file dead.letter in your home directory

mail Send Mode: Commands

  • Send Mode commands:
    • Each send mode command
      • can be used in the body of the text message
      • has to appear on a line by itself
      • starts with ~
    • ~v use vi to edit or to view the mail message
      • When done use :wq to exit out of vi and return to mail send mode
    • ~h edit the header of the mail message.
      • You will be prompted to edit the fields: To, Subject, cc, bcc
    • ~r filename read (bring in) an existing text file into the current email message
      • filename can have a path
    • ~m mesg_num mail (bring in) an existing email into the current email message
      • mesg_num is the number of the existing email in the receive mode

mail Receive Mode: Check for Mail

  • To start: mail
    • Without an argument, mail will be in receive mode
  • You will get a message no mail for yourID or
  • You will see a receive mail header, with fields: status message_num senderID date size subject
    • The symbol > in front of one of the messages indicates it is the current message
    • status: N for new, U for unread, blank for already read
    • message_num : a number, the numbers are in the order that the mail was received
    • senderID : email address of the person who sent the mail
    • date : the time and date received
    • size : number of lines / characters
    • subject : what the sender put in the subject field
  • Following the header, you will get the prompt &, this means mail is ready for the mail receive mode commands.

mail Receive Mode: Message Number

  • The receive mode commands can optionally accept a message number
  • If no message number is given, the command applies only to the current message
  • If there is a message number, it can follow the command immediately or with 1 or more space in between
  • How to use a message number:

8 command will apply to message 8

1,8,6 command will apply to messages 1,8,6

2-5 command will apply to messages 2 to 5, inclusive

$ command will apply to last message

* command will apply to all messages

mail Receive Mode: Commands

  • Receive mode commands (the [ ] indicates optional field):
  • To read a message: [message_num] <enter key>
    • The message will appear on screen and end with the & prompt
  • To see the mail header : h
    • The mail header shows all messages and their status
  • To delete: d [message_num]
  • To undo a delete: u [message_num]
  • - Can undo as many deleted messages as you have deleted in the session
  • To reply to sender only: R [message_num]
  • To reply to all r [message_num]
    • Both reply commands will take you to send mode, where you can type your reply
    • When you send the reply and get out of send mode, you’ll be back in the current receive mode
    • To bring the original mail into your reply email, use ~m in your reply to bring it in
  • To forward mail: m email_addr
    • This takes you to send mode
    • Then use the ~m command of send mode to bring in the message you want to forward
    • You can add any extra message of your own before send
    • When you send the forwarded message, you’ll get out of send mode and be back in receive mode

mail Receive Mode: Save Mail

  • To save and email to a mail folder:
    • s [msg_num] folder_name
  • A mail folder is a text file created by mail when you save a mail message
    • If the folder_name is new, the new text file is created
    • If folder_name already exists, mail will append the mail message to the text file
  • This text file can be opened by any utility that can open a text file, but it can also conveniently be read by mail itself
  • To use mail to read this mail folder:
    • mail –f folder_name
    • The option –f is for file
  • Each mail message in the file is displayed like in the mail receive mode
  • This provides a convenient way for you to sort your email into separate folders and view it with mail

mail Receive Mode: Exit

  • To exit out of mail: x
  • When you exit, mail will act as if you had not opened the current mail session
    • Messages with status N will still be N
    • Messages with status U will still be U
    • Messages that are deleted will be restored
    • Messages that are read will keep their status (U or N)
  • However, messages that are sent or saved in a folder will still have been sent or saved in a folder

mail Receive Mode: Quit

  • To quit out of mail: q
    • When you quit, mail keeps track of the status of the current session
    • Therefore messages will have updated status
  • Messages that are read: go into a folder called mbox, created by mail automatically in your home directory
  • To see these messages, use mail to open the folder mbox:
    • mail –f (with no argument)
  • Messages that are not read: stay in your inbox and marked with status U
  • Messages that are saved: go to the folder that you saved in
  • Messages that are deleted: gone
  • Topics:Communication with Other Users
  • Messaging with write and talk
    • write
    • talk
    • mesg
  • mail commands
    • send mode: How to send an email on linux system
    • receive mode: How to receive an email