Unit 5 Communication With Other User-1
Unit 5 Communication With Other User-1
user
• The write command allows user to communicate with other users whereas the mesg
command allow or disallow write access to the terminal.
(i) write
• It is on-line communication command.
• It sends a message to another user who is currently connected to the Unix system.
• The general syntax of write command is:
Syntax:
write user [ttyname]
• The write command provides a facility to communicate with other users, by copying lines
from his terminal to other user's terminal.
• When a user runs write command, the other user on the other hand gets a message on his
terminal in the following form:
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 1
UNIX | Unit 5: Communication with other
user
how are u?
• If the user is logged in on more than one terminal with same username then you have to
specify the terminal name as, the second argument to the write command.
• For example, a user bca10 is logged in at two different terminals pts/3 and pts/6.
• Now, user bca1 wants to send message to bca10 then he types specific terminal name with
username on his terminal as follow:
$write bca10 pts/6
messages <ctrI-d>
In this case, if you do not specify terminal name then write command find solution to itself
i.e. who has to send message.
In Linux, it sends to user whose login time is latest.
• There are two requirements for smooth write operation:
1. The receiver must be logged in to the system
2. The receiver terminal is writable.
• There are mainly two alternative to fulfill these requirements:
1. finger command
o Finger command tells you that who are currently connected to the system and
who can receive messages on their terminals.
o The finger displays a list of all those user who are logged in to the system and the
list also places a * before the terminal-name where mesg is set to -n.
$finger<enter>
The result shows that which terminal is write protected and which terminal is
writable.
2. who-T
o The who —T command lists all the users who are currently logged in and places a'+'
next to the username who have allowed messages and a '-' sign does not allowed.
$who-T
(ii) mesg
• It controls write access to your terminal by others.
• It is used to allow or disallow other users to write to your terminal.
syntax:
mesg [y/n]
• Without argument, it displays the write access state of your terminal.
$mesg
is y
• The output y indicates that your terminal get access to write by other users.
• It has two options which determine the write access to your terminal.
Option Meaning
Y or y It allows write access to your terminal.
N or n It disallows write access to your terminal.
• If a user wish to disallow write access to his terminal then he issued a command as follow:
(iii) wall
• It sends a message on the terminal of all the users who are currently logged in to the Unix
system.
• This command is specially designed for the super user.
• The wall command enables the super user to 'write to all' irrespective of whether the users
have given write permission to their terminals or not.
Syntax:
wall [message]
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 3
UNIX | Unit 5: Communication with other
user
It sends message to all users who are currently connected to the system.
• The message can also be sent to wall using pipe like this:
$echo "Good morning students” |wall
Broadcast message from bca1(Thu Sep 516:30:47 2013):
• The message can be also sent as the standard input from a terminal. In this case, the message
should be terminated with the EOF key (usually Control-D).
$waII
Hello
There is an urgent.
Please contact to TYbca1
<ctrI-d>
The wall program resides in /etc directory (/usr/bin in linux).
(i) Motd
• It is a special file resides in /etc directory.
• If a super user wishes to put an off-line message to the user then he typed message in the
motd file.
• The content of this file is displayed on user's terminal as soon as any of the user logged in to
the system.
• The motd stands for the 'message of the day’. i.e. a system user puts message of the day to
this file.
• It is only the super user who can change the contents of the file/etc/motd.
• As soon as a user login to the Unix system a file /etc/profile file gets executed.
• It gets executed every time the user logs in.
• Moreover, every user has his own user profile file, profile, resides in user's home directory.
• The sequence of execution of these files is /etc/motd, /etc/profile followed by profile.
(ii) mail
• It is off-line communication command.
• It sends and receives mail.
• Unlike, write it allow user to send a mail to users even if they are not logged in to the Unix
system.
Syntax:
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 4
UNIX | Unit 5: Communication with other
user
mail-f[name]
mail [-u user]
• When users receive a mail message, they can do several things with it:
o View a mail on the terminal
o Save it in a mailbox
o Save it in a file
o Delete a mail
o Reply to it
o Forward it to other users
• Following options are used with mail command:
(i) -s (subject): It specifies subject of the mail on command line. The subject is enclosed in
quote if it contains spaces.
(ii) -c(carbon copy): It sends carbon copies to list of users.
(iii) -b (blind carbon copy): It sends blind carbon copies to list. List should be a comma-
separated list of names.
(iv) -f: It reads the contents of your mbox ($HOME/mbox) or the specified file for processing;
when you quit mail writes undeleted messages back to this file.
• A user want to send e-mail to user bca1 then he typed on his terminal as follow:
• When any new mail comes to the user, he is notified by the following message on his
terminal.
You have new mail in /var/spool/mail/bca1
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 5
UNIX | Unit 5: Communication with other
user
• Without any argument, mail command display list of header of each messages and then give
"?' prompt. This is an interactive mode of mail command.
$mail
mailx version nail 11.25 7/29/05. Type? for help.
"/var/spool/mail/mas": 5 messages 1 new 1 unread
01 examination Mon Sep 10 13:58 20/659 tmt
02 examination Mon Sep 10 14:32 19/628 forward
03 mas Mon Sep 10 14:37 24/874 Re:forward
U4 tybcasem5 Tue Aug 6 16:44 20/637 just hello
N5 tybcasem5 Thu Sep 517:06 19/644
? #interactive prompt of mail command
• The result shows that there are five mails among them 3-mails are old, 1-mail is unread and
1 is new. Letter 0, U and N indicates Old, Unread and New mail message respectively. Second
column indicates mail number, 3 column indicates group name of a sender, 4 column shows
mail date and time and last column shows subject of a mail.
o A user can view mail, delete it, reply it, forward it and so forth using the internal
command shown in table. Internal commands are used in interactive mode of mail
command at "?" prompt.
Command Action
+ It displays next message.
It displays previous message.
N It displays N'h message.
h It displays only headers of all messages (default).
dN It deletes message N, the current message deleted if N is not specified
uN It undelete message N, the current message undeleted if N is not specified.
m user It forwards mail to user
rN It replies to sender of message N (the current message if N is not specified);
q It quits mail program
! cmd It runs UNIX command cmd.
? It displays on-line help.
?m bca10
subject: Just FD #ask for subject
hello
<ctrI+d>
• mail saves messages in a mailbox, which normally is placed in the directory /var/spool/mail
and has same name as the login name i.e. bca1's mail saved in /var/spool/mail/bca1
• When a mail message has been viewed by the user, it is saved in SHOME/mbox automatically
on quitting from mail program.
(iii) News
• This command is invoked by user to read any message that is sent by the system
administrator.
• A system administrator types the information which he wants everyone on the network to
know in different files in usr/news directory.
• Whenever a user logged in and if any fresh news has come in after the time of last logged
out then a following message is displayed on user's terminal:
$news
(a) -n (name)
• It displays only the name of files whose contents are not been read before.
$ news -n
news: mess mess2 mess3 #these files are not seen
(b) -s
• It lists the number of news items that have still not been read.
$news-s
3 news items #3-messages are not read
(c) -a (all)
• It displays the contents of all news items regardless of whether they have been read or not.
• A user can also use news with a filename to display the specific message. You can do that
even if the item has been read before:
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 7
UNIX | Unit 5: Communication with other
user
$news mess1
---display news-----
SASCMA English Medium & STERS BCA & BBA College By: Dr. Pooja Negi 8