Use Linux commands to send messages

Source: Internet
Author: User
Using Linux commands to send messages (post) Linux has developed to today, and many functions can be completed on a visual interface. However, commands are very useful in many cases. In particular, Linux administrators can communicate with other users by sending system rest, bulletin board information, and public information.

Set logon prompt

/Etc/motd File Usage

/Etc/motd? That is, message? Of? Today (Bulletin Board information), the content of the/etc/motd file is displayed on the user's terminal each time a user logs on. The system administrator can edit system activity messages in files. For example, the Administrator notifies the user of the system when to upgrade the software or hardware and when to perform system maintenance. If shell supports Chinese, you can also use Chinese, which makes it easier to understand. /Etc/motd? The disadvantage is that many users choose to automatically enter the graphic interface when logging on to the system, so this information is often invisible.

Use of the/etc/issue file

The usage of the/etc/issue file is not much different from that of the/etc/motd file. The main difference is that when a network user logs on to the system through a serial port, the/etc/issue file content is displayed before the login prompt, while the/etc/motd content is displayed after the user successfully logs on to the system.

Use the write command

You can use the write command to send messages to other online users. Format:

# Write username [tty]

Enter write in the shell prompt symbol. Username indicates the user name that accepts the sent message. If a user logs on to the system multiple times, the TTY parameter specifies the terminal to be sent. The prerequisite for sending information using write is that the user has logged on to the system. Otherwise, the following message is displayed:

# Write cquota
Write: Cashed is not logged in

You can use the who command to query the logon user name. Then you can enter the information to be sent. After the input is complete, type EOF to end the information and use the crtl + D combination key to send the information. The entered content appears on the user's screen and the communication is terminated.

If you are on the network, you can use the write command to add the host name or domain name after username to establish network communication. To communicate with BJ users on the CAO host, run the following command:

# Write bj @ Cao

You can use the rusers command to list all login users on the LAN.

Wall command

If you want to send a message to all users in the system, you can use the wall command, which indicates write all. Enter wall and edit the information. If the shell supports it, you can use Chinese. Then use the crtl + d key combination to send information. In this way, the desktop of all login users in the system will receive information. If you are on the network, you can use the rwall command to send information to all users on the LAN.

Talk command

The talk command can implement two-way conversations with another login system user. The system administrator can enter information. Both parties can view the screen information during the communication. Format:

# Talk Username

Example:

# Talk B

Recipient's screen display:

Message from Talk_Daemon@www.cao.com...
Talk: connection requested by B @www.cao.com.
Talk: respond with: Talk B @www.cao.com

Then go to the talk split screen interface and enter the information entered by both parties. The screen of the recipient.

After the user completes the session, use crth + C to disconnect. Like write, you can add a host name or domain name after username to establish a network session connection.

Mesg command

Users can prevent other users from sending messages to interrupt their work, and use the mesg n command to prohibit other users from sending messages. When someone tries to use write to send messages to him, the sender will see the prompt:

# Write: user has messages disabled on pts/n?

However, a super user can send messages to any user, even if the user uses the mesg n command. To restore acceptance information input:

Mesg-y

The software running on Linux servers is mainly open-source software, which is constantly being upgraded. The stable version and the test version alternate. If you are a Linux Network Manager, you often need to go to the corresponding website to check whether there are patches, bug fixes, and upgrades. The Network Administrator also provides users with security services. Users should regularly send security information to ensure security awareness. You can use the preceding commands to better manage users.

In UNIX operating systems, to notify users of a certain piece of information, we often use the method of writing information to the screen that users can see.
Send messages to a single screen
Each user who logs on to the host system is assigned a terminal number. For example, the 12 screens on the console are tty01 ~ Tty12, generally including tty2a, tty2b, and tty21a ...... And other terminal device numbers. For remote logon, the virtual terminal numbers such as ttyp0 and ttyp1 are used. The corresponding terminal device files are all in the/dev directory.
Echo 'Let me tell you :...... '>/Dev/tty03

In this method, the terminal file/dev/tty03 is directly written by the output ing character ">" to send information to the screen. Different from the following three methods, this method is for terminals rather than login users. Therefore, even if the terminal does not have user logon, you can use this method to send information to the screen. However, the other three methods can only send information to screens with user logon.

Send information to a specified user

Users of the same system can log on to multiple terminals. For example, Super Users can log on to the tty21c terminal connected to multiple user cards on Screen 3 of the console. In this case, you can use the write command to send information to the specified screen.

Write root tty03

If you only log on to the screen, you can omit the second parameter. This command can be used to implement the chat function, because the information is sent to the specified screen after each carriage return, which is not implemented by other sending methods. "Terminate" using Ctrl + D.

Send information to all users logged on to the host

The broadcast concept exclusive to a multi-user system: Like Wireless broadcast, it enables everyone to hear your voice.

Wall

Wall-G group

Wall-g root see.txt

In this example, the "-G" parameter specifies the user group to send information to a specific group. In other words, the system has multiple user groups to log on. You only want to broadcast the information to the user screen of the root Super User Group. You can use the "-g root" parameter. The wall command without parameters sends screen information to all users logging on to the system. It is generally used for emergency shutdown, prompting users to save information and exit the system at the specified time. The information to be broadcasted can be the content in a text file or directly entered. However, unlike write, when directly entered, each line of information is not sent after carriage return, only after the CTRL + d key combination confirms that the input is complete will all be sent. NOTE: If no other user logs on to the system, all screens (terminals) are in the login: Waiting For Logon status, the information sent by the wall command will not be displayed on the screen.

Send messages to user screens on the network

The above three methods can only send information to the screen of the local host. In actual work, we need to do the same operation to the User Screen of multiple UNIX hosts on the network for unified action, in this case, the network broadcast command rwall is used.

Rwall 123.45.67.89 <see.txt

The parameter is the Unix Host IP address that receives the information. The <character is used to send the text file information to all screens on the specified host with user logon. The rwall command does not need to log on to the host of the other party, and does not need a password. In actual applications, a shell document is usually made. hosts that want to receive information are included in the document, and then sent in a unified manner. For example, the shell document is GB:

Rwall 123.45.67.89 <$1

Rwall 123.45.67.90 <$1

Rwall 123.45.67.91 <$1

......

When sending the message:./GB see.txt.

Similarly, the screen of the remote host can receive information only when a user logs on. In the login status, no information is sent to the screen. If the host of the other party is closed or the line is faulty, the system will prompt "couldn't contact 123.45.67.89: RPC: timed out ".

The above methods and commands are tested and passed in SCO unix5.05 system. The specific form of commands may change in other UNIX systems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.