Wake-on-LAN (WOL) is an Ethernet networking standard that allows a server to be turned on by a network message. You need to send ‘magic packets’ to wake-on-lan enabled ethernet adapters and motherboards to switch on the called systems. Make sure you connect the NIC (eth0 or eth1) with the motherboard and enable the BIOS’s WOL function. This is a quick guide to enable WOL under RHEL / Fedora / CentOS / Debian / Ubuntu Linux.

Client Software

It would be best if you used software to send WoL ( Wake-on-LAN ) magic packets to the target system. You will find various tools for all modern operating systems, including MS-Windows 8/10, Apple macOS & OS X, all modern Linux distros, FreeBSD, OpenBSD, NetBSD and many smartphones.
How To Wake Up Computers Using Linux Command [ Wake-on-LAN ( WOL ) ] By Sending Magic Packets

Linux Install etherwake Under Debian / Ubuntu Linux

We use the etherwake command to send a Wake-On-LAN “Magic Packet” under Linux operating systems. Type the following apt-get command/apt command to install the same under Debian / Ubuntu Linux desktop:
## apply all patches on Debian/Ubuntu ##
$ sudo aptitude install etherwake
## OR ##
$ sudo apt install etherwake


[sudo] password for vivek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package etherwak
[vivek@nixcraft-wks01 backups]$ sudo apt install etherwake
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
The following NEW packages will be installed:
  etherwake wakeonlan
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 18.1 kB of archives.
After this operation, 56.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 etherwake amd64 1.09-4build1 [8,900 B]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 wakeonlan all 0.41-12 [9,232 B]
Fetched 18.1 kB in 1s (16.9 kB/s)    
Selecting previously unselected package etherwake.
(Reading database ... 338929 files and directories currently installed.)
Preparing to unpack .../etherwake_1.09-4build1_amd64.deb ...
Unpacking etherwake (1.09-4build1) ...
Selecting previously unselected package wakeonlan.
Preparing to unpack .../wakeonlan_0.41-12_all.deb ...
Unpacking wakeonlan (0.41-12) ...
Setting up wakeonlan (0.41-12) ...
Setting up etherwake (1.09-4build1) ...
Processing triggers for man-db (2.9.1-1) ...

Installing a tool to send a Wake-On-LAN “Magic Packet” on RHEL/CentOS Linux

There is also Perl script to wake up computers. We can install it as follows on Debian/Ubuntu Linux:
sudo apt-get install wakeonlan

Type the following dnf command/yum command on your Fedora/RHEL/CentOS/Rocky and AlmaLinux system. For instance:
$ sudo yum install net-tools
Outputs from my RHEL 8 box:

Last metadata expiration check: 3:23:23 ago on Mon Feb 22 05:56:16 2021.
Dependencies resolved.
 Package         Architecture Version                        Repository    Size
 net-tools       x86_64       2.0-0.52.20160912git.el8       baseos       322 k
Transaction Summary
Install  1 Package
Total download size: 322 k
Installed size: 942 k
Is this ok [y/N]: y
Downloading Packages:
net-tools-2.0-0.52.20160912git.el8.x86_64.rpm   689 kB/s | 322 kB     00:00    
Total                                           271 kB/s | 322 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : net-tools-2.0-0.52.20160912git.el8.x86_64              1/1 
  Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64              1/1 
  Verifying        : net-tools-2.0-0.52.20160912git.el8.x86_64              1/1 

Red Hat Linux and friends users should use the net-tools package, which may be installed by default. The command name is ether-wake.

Installing wakeonlan on macOS Unix

First, install Homebrew on macOS and then run:
$ brew install wakeonlan
See “macOS – Wake Up Servers Using Wake-on-LAN ( WOL ) Command Utility” for more info.

How Do I Send WOL Magic Packets Under Linux?

Type the following command:
$ wakeonlan MAC-Address-Here
$ etherwake MAC-Address-Here
$ etherwake -D MAC-Address-Here

RHEL / Centos / Fedora Linux user, try:
$ ether-wake MAC-Address-Here
If your MAC address were xx:yy:zz:11:22:33, you would type:
$ wakeonlan xx:yy:zz:11:22:33
$ etherwake xx:yy:zz:11:22:33

  • xx:yy:zz:11:22:33 is remote servers mac address. You can obtained mac address using combination of the ping command and arp command:
    ping -c 4 server3 && arp -n


Here is how to use the limited broadcast address (
$ wakeonlan mac
$ wakeonlan mac-1 mac-2

Using a subnet broadcast address:
$ wakeonlan -i mac
We can use another destination port too
$ wakeonlan -i -p PORT mac
$ wakeonlan -i -p 4242 mac

We can use a file as source of hardware and IP addresses:
$ wakeonlan -f homelab.wol
$ wakeonlan -f homelab.wol mac

The following is an example of a text file containing hardware addresses (macs). Let us display it using the more command or cat command/less command:
more homelab.wol
Sample config file:

# File structure
# --------------
# - blank lines are ignored
# - comment lines are ignored (lines starting with a hash mark '#')
# - other lines are considered valid records and can have 3 columns:
#       Hardware address, IP address, destination port
#   the last two are optional, in which case the following defaults
#   are used:
#       IP address: (the limited broadcast address)
#       port:       9 (the discard port)
00:16:3e:a3:9d:a8		9

How Do I Verify That Remote Linux Server Supports Wake-on-LAN (WOL)?

First, reboot the remote server and go to BIOS > Power Management > “Wake On LAN”. Please turn WoL on. Next, save and close the bios settings. After activating Wake On LAN (WoL) in your BIOS hardware option for the network interface card, it is also necessary to activate it using ethtool. The ethtool command will configure eth0 to respond to the magic packet:
# ethtool -s eth0 wol g

  1. -s eth0 : Your NIC. Feel free to replace eth0 with your actual network interface device name.
  2. wol g : Sets Wake-on-LAN options using MagicPacket.

Type the following command to see current status of wol for eth0:
# ethtool eth0
Output from my NAS server:

Settings for eth0:
	Supported ports: [ ]
	Supported link modes:
	Supports auto-negotiation: No
	Advertised link modes:  Not reported
	Advertised auto-negotiation: No
	Speed: 100Mb/s
	Duplex: Full
	Port: MII
	Transceiver: internal
	Auto-negotiation: off
        Supports Wake-on: g
       Wake-on: g
	Link detected: yes

If you are using RHEL / SL / Fedora / CentOS Linux, edit /etc/sysconfig/network-scripts/ifcfg-eth0:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add / modify the following line:



ETHTOOL_OPTS="wol g autoneg off speed 100 duplex full "

Save and close the file. If you are using Debian / Ubuntu Linux, edit /etc/network/interfaces:
# vi /etc/network/interfaces
Append the following to eth0:

auto eth0
iface eth0 inet static
        post-up /sbin/ethtool -s eth0 wol g
        post-down /sbin/ethtool -s eth0 wol g

How to use the wakeonlan in your backup scripts

Here is a sample shell script that will wake up my laptop (IP and mac 48:2a:e3:5c:16:bc) from my rsnapshot Linux backup server:

# load ssh keys from keychain 
. /home/backups/.keychain/backup-ssh-key
# Try to wake up sleeping laptop at night and odd time as per cronjob
/usr/bin/wakeonlan 48:2a:e3:5c:16:bc
# Sleep for 30 seconds to that laptop comes online
/bin/sleep 30
# Verify and start backup
/sbin/ping -q -c 30 >/dev/null
if [ "$1" != "" ]
     # start backup
     /usr/local/bin/rsnapshot "$1"
     # push everything offsite to aws-s3 buckets and exit this session due to slow upload links
     echo '/home/backups/push-mirror-to-aws-s3' | /usr/bin/at now + 5 minute
     echo "Usage: $0 [hourly|daily|montly|weekly|yearly]"
     exit 1

Summing up

I explained how to set ‘magic packets’ to wake-on-lan (WoL) enabled ethernet adapters and motherboards to switch on the PC or server. The magic packets also work when your system is in suspend or deep sleep mode. For example, my backup FreeBSD and Linux server can wake up my laptop at midnight and backup files. Of course, your BIOS must support the WoL option. Otherwise, it will not work. See the following man pages using the man command:
$ man wakeonlan
$ man ethtool

Also see the WikiPedia page about WoL.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

17 comments… add one
  • anand vamsi Apr 4, 2012 @ 3:41

    really a helpful command need to experiment.

  • Russell Gadd Apr 4, 2012 @ 8:53

    I’m no expert but looking at Synaptic there is also a wakeonlan command which can be installed.

    In the Synaptic blurb for this package it says:
    You need the MAC addresses of machines to construct the WOL packets, but,
    in contrast to ‘etherwake’, you do not need root privileges to use the
    program itself as UDP packets are used.

    • 🛡️ Vivek Gite (Author and Admin) nixCraft Apr 4, 2012 @ 10:53

      Yes, wakeonlan can be run as non-root user, but etherwake must run as root.

  • zam Apr 4, 2012 @ 15:44


    can any one please tell me How to shutdown the Computers Using Linux Command [ Wake-on-LAN ( WOL ) ]

    • Alex May 8, 2012 @ 21:32

      ssh into the box and, as root, “shutdown -h now”

      • Ion Jan 27, 2015 @ 19:20

        or poweroff

  • Dan Apr 8, 2012 @ 20:50

    Shutdown a linux machine with : “sudo halt “.
    Of course it can work without sudo if you have enough user rights.. ( see doc/ groups)

    WOL is only for wake.

  • Nora Apr 18, 2012 @ 5:55

    Should be possible, yes. But then I’d rehatr do a management interface where you can add all the MACs you possible want to wake and make the other thing a drop down menu. This would separate the admin from the user which may be a good thing.

  • Simon Apr 27, 2012 @ 13:35

    Hey there.
    I am searching for a way to send a magic packet with wakeonlan on startup, after the network is there. I already wrote a script but that doesn´t work on startup. The stop-command works though, so the command I give is right. Don´t know what I am doing wrong.

    • 🛡️ Vivek Gite (Author and Admin) nixCraft Apr 29, 2012 @ 8:52

      Can you paste your script using pre tags here?

    • Rich May 18, 2014 @ 15:23

      Did you ever figure this out? I’m trying to do the same thing.

  • Roger Jollie Mar 22, 2013 @ 22:46

    If you want to shut down or reboot a remote computer such as a Windows box you can do the following:

    net rpc shutdown -I ip or name of computer -U username%password

    If you don’t want to have the password in plain text on the screen omit the %password and you will be prompted for it. if you use a -r switch the computer will reboot. If you are on a domain network you can use your domain account by using the following


  • Ahmed Feb 5, 2016 @ 8:03

    One useful bash script if you want to automate WOL wake and inform user depending on the stats of it.
    NOTE: “hppl-1” is the hostname in the script

    VAR=`ping -s 1 -c 2 hppl-1 > /dev/null; echo $?`
    if [ $VAR -eq 0 ];then
    echo -e "hppl-1 is UP as on $(date)"
    elif [ $VAR -eq 1 ];then
    wakeonlan 9c:b6:12:09:8d:22 | echo "hppl-1 not turned on. WOL packet sent at $(date +%H:%M)"
    sleep 3m | echo "Waiting 3 Minutes"
    PING=`ping -s 1 -c 4 hppl-1 > /dev/null; echo $?`
    if [ $PING -eq 0 ];then
    echo "hppl-1 is UP as on $(date +%H:%M)"
    echo "hppl-1 not turned on - Please Check Network Connections"

    Saw this on this website www. howtovmlinux .com


  • Pulipuli Mar 25, 2017 @ 4:15

    Very useful. Thanks.

  • ynys Jul 10, 2021 @ 22:58

    Found this worked:
    wakeonlan xx:yy:zz:11:22:33
    but this:
    etherwake xx:yy:zz:11:22:33
    did NOT

  • Викуля May 16, 2022 @ 17:30

    Интересует включение компьютера по сети удаленно linux

  • Надежда May 16, 2022 @ 21:50

    Где узнать про включение компьютера по сети удаленно linux

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.