How to do Communication in Linux Operating System
If you are working on a terminal, which is connected to other terminals through the server (UNIX), you may need to send files or messages to a person sitting on other terminals. This article is going to solve the problem of communicating with other users using some specific commands.
Communication in Linux is subdivided into two categories; the Online Communication and the Offline Communication. In the Online Communication, both the sender and receiver are online, while in Offline Communication, the sender should be online while the receiver should stay offline.
Before starting the communication process, we first need to know who are available online. The command $who is used for this purpose. It provides user’s information including those who are currently logged in to the server.
Let’s begin with online communication:
1. Online communication: The Online Communication can be performed by executing the write command.
Syntax: $write <username> <terminal number> [enter]
On pressing the enter key, the request will go to the UNIX server. UNIX will then check the state of the receiver. During that point, one of the two things may happen:
- If the receiver is currently available to receive the message, it will be shown to his terminal.
- If the receiver is currently not available, the server will display a message that the user is currently not in logged in position
- If the receiver is available but not in a state of receiving any messages, then the server will display a message that the user is busy and doesn’t want to receive any message right now. This state can be activated by the receiver using the command $mesg n [enter] and can be deactivated by using command $mesg y [enter].
Note:
To terminate the connection, the [ctrl+d] command will be used by both sender and receiver.
2. Offline communication: The Offline Communication can be performed by executing the mail command. In Offline Communication, whether the receiver is not available or busy, a message will be stored to the UNIX server and when the receiver will be ready to receive, the server will send the message to the receiver. Unread mails are saved into mbox folder.
Syntax: $mail <username> [enter]
Other important commands:
1. Command used for checking mails:
To check mails received by the user, the mail command should be executed, but here, the syntax is quite different.
Syntax: $mail [enter]
2. To read the full mail:
Syntax: &<mail number>
3. To delete mail:
- To delete currently opened mail:
Syntax: &d [enter]
- To delete particular mail that is currently not open:
Syntax: &<mail number>d [enter]
4. To quit from communication mode and go to the shell:
Syntax: &q [enter]