Linux broadcast message to all

How to Send a Message to Logged Users in Linux Terminal

How can I send a messages to logged on users in a Linux server? If you are asking this question, then this guide will help you learn how to do that. We will demonstrate how to send a message to all or a specific logged on user, on the terminal in Linux.

Linux offers a variety of means for sending messages to users logged on to a server as explained in the two methods below.

In the first method, we will use wall command – write a message to all currently logged in users on the terminal as shown.

Send Message to Logged Users

To disable the normal banner printed by wall, for example:

Add the -n (Suppress the banner) flag, this however, can only be used by the root user.

In the second method, we will use write command, which comes pre-installed on all if not most Linux distributions. It allows you to send a message to another user in the terminal using tty.

First check the all logged on users with the who command as shown.

Find Logged in Users

There are currently two users are active on the system (tecmint and root), now the user aaronkilik is sending a message to the root user.

Send Message to User

Read Also:

That’s all! Do share with us other methods or commands for sending messages to all logged on users through the terminal in Linux. If you have any queries, please use the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Thread: Howto send a broadcast message to all users?

Thread Tools
Display

Howto send a broadcast message to all users?

I’m looking for a solution to broadcast messages on the network.
All systems are Linux / Ubuntu.

It would be used in case the server has to be rebooted.
It saves me a walk to every office in the building.

Re: Howto send a broadcast message to all users?

So far I have found a sort of solution.
This solution uses a combination of samba and linpopup.

Since we are only using Ubuntu in our network, we don’t want to install samba.
(Just for messaging purposes).

So anybody knows any other solution?
Maybe we could use a messenger like tool, but it has to popup on top of everything.
And we need the option to sent to all users at once.

Re: Howto send a broadcast message to all users?

You can set the time and broadcast a message to all users logged on.

Re: Howto send a broadcast message to all users?

Thanks for your reply, but it’s not what I meant.
Problem is, that people are working on our server with applications like Frontaccounting, Sugarcrm and Xoops.

So I would like to be able to broadcast a message from this server to all clients on the network. Using this, I can inform people of the fact that the server will for example be rebooted in 15 minutes.

Читайте также:  Control air для windows

The people who need to receive the message are not logged in on the system using SSH or whatever. All of the applications used by the users are web-based. So their in fact apache users and they don’t have an user account on the system.

Re: Howto send a broadcast message to all users?

Dunno if it’s what you’re looking for — but try man wall.

Re: Howto send a broadcast message to all users?

Doesn’t Man Wall only sent a message to the users logged in on the system?
(either local or remote)

From what i tested this doesn’t sent a message to the users using the web-server.
(our users are constantly using SugarCRM, so I want to sent a broadcast to them in case of server reboot)

Re: Howto send a broadcast message to all users?

Nobody?

I would swear that what i want to accomplish, is not that odd.
I can’t imagine that in the bigger companies the system administrator walks or calls to everyone to inform them about the upcoming server maintenance?

It doesn’t matter what program i use, or how i have to use it, the only requirment is that i can type the message once, and so it is displayed to all desktops in the company.

Re: Howto send a broadcast message to all users?

Nobody?

I would swear that what i want to accomplish, is not that odd.
I can’t imagine that in the bigger companies the system administrator walks or calls to everyone to inform them about the upcoming server maintenance?

It doesn’t matter what program i use, or how i have to use it, the only requirment is that i can type the message once, and so it is displayed to all desktops in the company.

install pidgin, add an account, select bonjour.

it basically uses zeroconf, it’s a simple lan/ ip messenger.

if that’s not what you need i can have a look around ?

Re: Howto send a broadcast message to all users?

install pidgin, add an account, select bonjour.

it basically uses zeroconf, it’s a simple lan/ ip messenger.

if that’s not what you need i can have a look around ?

Well, no hijacking intended, but without installing anything, is there another way? I admit, this may seem dumb, but for example, I have a logged-in «safety» user via ctrl+alt+F2, and when I alt+F7 to my admin user and broadcast a message with wall, the «safety» user receives no message despite receiving the message on the admin user’s terminal. If this is off subject, please say so, and I will edit my post to blank.
Edit: I had to:
mesg y
as the «safety» user. Is there a way to force messages to all users even if messages are set to n?

Last edited by AggravatedGestalt; January 13th, 2011 at 03:19 AM .

Источник

Linux for freshers

Linux Administration, Interview Question, Tips And Tricks

Friday, April 23, 2021

how to send broadcast messages to all currently logged on users in linux ?

Wall displays the contents of a file or, by default, its standard input, on the terminals of all currently logged-in users. The command will cut over 79 character long lines to new lines. Short lines are white space padded to have 79 characters. The command will always put the carriage return and new line at the end of each line.

Only the super-user can write on the terminals of users who have chosen to deny messages or are using a program that automatically denies messages.

Reading from a file is refused when the invoker is not a superuser and the program is suid or sgid.

Usually, system administrators send messages to announce maintenance and ask users to log out and close all open programs. The messages are shown to all logged-in users with a terminal open.

wall [-n] [-t timeout] [message | file]

The most straightforward way to broadcast a message is to invoke the wall command with the message as the argument:

wall «The system will be restarted in 10 minutes.»

Broadcast message fromroot@linuxforfreshers (pts/0) (Mon Jan 4 13:22:07 2021):

Читайте также:  Где находится репозиторий linux

The system will be restarted in 10 minutes.

The message will be broadcasted to all users that are currently logged in.

To suppress the banner and show only the text you types to the logged-in users, invoke the command with the -n (—nobanner) option:

wall -n «The system will be restarted in 10 minutes.»

The system will be restarted in 10 minutes.

If you want to write multi-line messages, invoke the command without an argument:

The wall command will wait for you to enter text. When you’re done typing the message, press Ctrl+D to end the program and broadcast the message.

You can also use the here-string redirection or pipe the output of another command to wall. Here is an example showing how to use the echo command to broadcast multi-line messages:

echo «The system will be restarted in 10 minutes. \nPlease save your work.» | wall

Broadcast Message from root@linuxforfreshers

(/dev/pts/1) at 13:36 .

The system will be restarted in 10 minutes. \nPlease save your work.

Broadcasting a Message From a File

If you are regularly sending the same messages, you can write each one of them to a file, so that you don’t need to re-type the same text. wall reads from the file only when invoked as root.

To broadcast the contents of a file, invoke the wall command followed by the file name:

The system will be restarted in 10 minutes.

Broadcast message from root@linuxforfreshers (pts/0) (Mon Jan 4 13:30:07 2021):

The system will be restarted in 10 minutes.

Источник

Linux Howtos, Linux Tutorials

Linux Howtos, Linux Tutorials, Linux Videos and Discussion Board for Newbies to Professional and experts

Linux Howtos, Linux Tutorials

Monday, February 22, 2010

How to broadcast a Message through Terminal to Login users In Fedora, Centos, RedHat, Ubuntu

Do you want to sent message to all logged in users in your system (This works great when you are a System Administrator and many users are logged into same System)?

If you are Running Any Linux Distribution like Fedora, Centos, RedHat, Ubuntu you can send or broadcast message to all user logged in using «WALL» command. To use it on the command line / Terminal.

METHOD 1
========

[root@localhost

]# wall «Your message Goes here»

Now all users can see the Message Broadcasted by You

[ashwin@localhost tmp]$
Broadcast message from root (pts/2) (Mon Feb 22 12:10:35 2010):

Your message Goes here

METHOD 2
========
[shankar@localhost

]$ wall [Press Enter]
Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished

Press Ctrl + D for EOF (End of File)

]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished

All Users can view the Message on their Terminal as below

]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished

Limitations of Wall :
1. The total length of the message is limited to 22 lines.
2. Broadcasted Messages are limited to The System Itself.

Advantages of Wall
1. During an Activity / Crisis on the system all users can be notified immediately
2. No need to Send Email to the users who are Logged into the System.

Источник

Отправка и получение датаграм SO_BROADCAST из другой сети

Всем доброго времечка, не болеть и не дурнеть от СМИ!

Взялся я писать клиента на Пингвине, который получает бродкаст udp-датаграмму и посылает ответ таким же способом. Нужно это для того, чтобы удаленный девайс, который может находится в другой подсети, доступ к которому ограничен, смог словить пакет, и прислать свой в ответ со своим ip-адресом для дальнейшей с ним работы. Ну вот незадача — если говорить об SOCK_DGRAM, Linux стоит на страже любых поползновений, акромя тех, что в его сетке.

Общение проходит между Windows и Linux (я пишу для этой стороны).

Удалось протиснуться, установив опцию SO_BINDTODEVICE, хоть этот сокет начал отправлять, но этот сокет не принимает, а может лишь отправлять (насколько я понял из мануалов). То, что сработало, ниже:

Далее мои размышления пошли в сторону RAW-сокетов, что-то вроде этого

socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))

Как прочитал из мануалов, сырые сокеты могут получать датаграму еще до ее попадания в ядро, таким образом есть возможность отловить этот броадкаст, и вот моя следующая попытка это сделать:

Читайте также:  Долго грузит windows 10 при установке

Только ОНО всё равно не работает, как надо: летит куча пакетов с первый байтом ‘E’. На просторах репозиториев находил, как люди устанавливают фильтры, но там жуткая морзянка из макросов, которую не каждый смелый человек отважится искать по крупицам. С posix сокетами раньше я не работал, использовал curl или qt, но нужда приперла. Прошу помочь навести порядок (что с чем мешать) с этими сокетами.

Посылка броадкастов в удаленную сеть — это тупиковый вариант в ipv4. В ipx если не ошибаюсь такая хрень работала 🙂

Любой нормальный роутер такую хрень дропает (форвардинг пакетов на широковещательный адрес).

Ты сам то подумай! Есть сетка с несколькими тысячами хостов. Ты туда один пакетик РАЗ! а тебе в ответ несколько тысяч ответов прилетает через узенький канал или еще более веселый вариант: юный хакер посылает пакет у которого оба адреса широковещательные.

PS для приема пакетов приходящих на широковещательный адрес ничего специального программировать не нужно.

Надеюсь, это тоже первоапрельская автокоорекция.

Да это понятно, что всё ради безопасности, кто бы спорил, и Линух молодец. Однако, Wireshark чудесным образом ловит эти пакеты на той же машине с линухом. Да и в варианте, где один пакет и ух — будет девайсов не много и отвечать будут только они, а не всё, что движется и слушается, внутри свой протокол. DHCP же не умирает. Нагрузка на сеть — да, но девайсов не так много.

В первом примере (который с AF_INET сокетом) не вызывается bind. Сокет не имеет локального адреса, вот и не получает бродкаст. Надо его сбиндить на sin_family=AF_INET, sin_port=htons(SERVERPORT), sin_addr.s_addr=htonl(INADDR_ANY) .

Но посылать бродкасты через роутер это действительно хреново. Обычный бродкаст на ip=255.255.255.255, mac=ffff.ffff.ffff роутер должен дропать по rfc. Directed бродкаст на ip=x.y.z.255, mac=gateway-mac роутер может отфорвардить, а может дропнуть, в зависимости от настроек роутера.

DHCP требует форвардера при отсутствии dhcp-сервера в сети клиента.

Форвардинг пакетов на широковещательный адрес — это нестандартное поведение маршрутизатора.

Пробовал сделать bind на INADDR_ANY, в таком случае принимаются только те пакеты, которые я собственно сам отправил. Те, что из другой — не приходят, но их все так же видит WireShark. Судя по man, INADDR_ANY это бродкаст подсети, то бишь той, в которой я. Так же, пробовал делать это с INADDR_BROADCAST, результат тот же. Вариант с INADDR_ANY ниже:

«дропать по RFC» Имеется в виду DHCP(RFC 2131)?

«дропать по RFC» Имеется в виду DHCP(RFC 2131)?

rfc по которому роутер не форвардит пакет на широковещательный адрес сети попробуй найти сам 🙂 Это должно быть ооочень древним rfc.

У dhcp другая проблема. Пакет с 0.0.0.0->255.255.255.255 бесполезно передавать дальше, т.к. отвечать на адрес 0.0.0.0 бессмысленно.

SO_BINDTODEVICE — это отдельная магия, которая позволяет посылать пакеты мимо таблицы машрутизации. Тебе она нафиг не нужна.

SO_BROADCAST нужен только для посылки пакетов на широковещательный адрес своих (непосредственоо подключенных) сетей.

Если ты используешь свою поделку только в рамках локальной сети, то есть смысл посмотреть на мультикастинг. Но там тоже есть проблемы. В большенстве случаев роутинг мультикастинга выключен по-умолчанию или отсутствует вообще, однако оно хотя бы легально в сравнении с броадкастами.

у меня такая фигня на мультикастах с чужих сетей была. помогло

Мультикастинг мне вряд ли подойдёт. Несмотря на то, что девайсы физически будут в одной сети, они могут иметь через пень колоду абсолютно неизвестные настроенные статические ip-шники. Именно поэтому я и влез в это «нелегальное» бродкастовое дело. Спасибо за советы. У меня, вроде как, получилось скрестить ужа с ежом на сокетах — итого созданы два сокета: один с SO_BINDTODEVICE для отправки и другой SOCK_RAW с ETH_P_IP, который, по сути, работает как снифер всей кучималы ещё до обрезки заголовков, начиная с канального уровня. И вот ОНО мне даже 10 Мб за 28 сек в 100Мбит-ной сетке прислало. Единственное, что меня ещё волнует, то, что размер даты упёрся в стандартные 1500 байт. Я полез мастерить что-то с mtu, увеличил — не помогло, увеличил буфер — не помогло, попытался включить/выключить фрагментацию — опять же «лесной друг-индеец» Линух отреагировал крайне отрицательно на все потуги. Понятно, что 1500 это стандартный размер пакета, но было бы здорово, если бы нашлось что-то вроде фрагментацию.

Источник

Оцените статью