FreeBSD / Linux: Sending a Message to Windows Workstation With smbclient Command

You can use a utility called smbclient (part of samba server) to send a message to windows system from FreeBSD or from Linux/Solaris/UNIX OS. This command lets you send messages to windows workstations, display browse lists, and connect to SMB shares. The syntax is as follows to send message:

smbclient -M <WINDOW-SYSTEM-NAME> <<EOF
Message
Message

..

When the message is complete, press Control-D.

smbclient is a client that can ‘talk’ to an SMB/CIFS server. It offers an interface similar to that of the ftp program, Operations include things like getting files from the server to the local machine, putting files from the local machine to the server, retrieving directory information from the server and so on.

Sending message to Windows system from Linux/ FreeBSD

To send a message “Meeting canceled” to windows system called joyxp, type:
$ smbclient -M joyxp <<EOF
Output:

Meeting canceled
See you at coffee house in 2 hrs.
--nixCraft Sys Admin
EOF

Pass the –U option to specify the username:
$ smbclient -M myxp -U Your-User-Name-Here <<EOF
Meeting cancelled
See you at coffee house in 2 hrs.
EOF

This tip also works with Linux and other UNIX variant with Samba client utilities package. Read man page of smbclient for more information:
man smbclient

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
11 comments… add one
  • Rahul Feb 7, 2012 @ 12:22

    I tried the given command & syntax but received an error message
    > bash: warning: here-document at line 21 delimited by end-of-file (wanted `EOF’)
    Enter root’s password:
    Connection to 192.168.100.10 failed. Error NT_STATUS_UNSUCCESSFUL

    Please HELP

  • manitou Oct 2, 2010 @ 7:30

    use netbios name of computer instead of IP
    i have such error when using IP, but with netname – all working

  • AmarJ Aug 29, 2010 @ 17:32

    I have turned off the firewall also. I am getting session request failed.
    r there any changes to be made in smb.conf file???

  • Kumar P Aug 13, 2010 @ 4:20

    Hi,,,, me too getting same message….

    Help to solve… Make it as complete post…

  • kasyapa Apr 20, 2010 @ 13:21

    I have turned off the firewall also. I am getting session request failed.
    r there any changes to be made in smb.conf file???

  • Joe Apr 20, 2010 @ 12:03

    The messenger service is a big security hole in windows and its normally turned off now days.
    If your gonna turn this back on, make sure your hosts are well protected.

  • rilwis Dec 5, 2008 @ 15:07

    Thanks. It’s an useful tip 🙂

  • Manish Nov 5, 2008 @ 9:13

    Hi,

    Actually the problem was at widow client machine’s end. The Firewall was on.

    I switched off firewall (diabled) and it started working normally.

    Thank you for your suggestions.

    Regards,
    Manish

  • MaZ Nov 5, 2008 @ 7:06

    use the ip instead

    $ smbclient -M 192.168.1.45 <<EOF

    • RAMRATAN Apr 25, 2015 @ 8:45

      after this command an error appear on linux pc ” session request failed”

  • Manish Oct 10, 2008 @ 10:25

    smbclient -M machine1 <<EOF

    I tried the given command & syntax but received an error message “Connection to machine1 failed”

    Please suggest ..

    Regards,
    Manish

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.