While this guide focuses on how to enable Wake-on-LAN in Ubuntu, you can apply it to Linux distros and even find the feature in Windows.

What Is Wake-on-LAN?

Wake-on-LAN or WOL is a feature that allows you to turn on your PC from another device via the network. It does this by sending a tiny “magic” packet of data from a host computer. The network driver of the receiver computer can receive this data and signal the device to power on.

How to Prepare Your Setup for Wake-on-LAN

For Wake-on-LAN to work, your Ethernet card needs to support the feature. It has been standard for at least 10 years, so chances are high your card will, but it is always good to double-check. Your Ethernet interface is the network card of your device. Every card has a unique name found with the following terminal command: The name you’re looking for is similar to “enp8s0.” This was the unique ID of the network card used in this tutorial. Ethtool is an open-source application that allows you to change network driver settings. For wake-on-LAN, it will allow your PC to understand the data it’s receiving. The command to install ethtool is: The tool is also available on pkgs.org if you encounter issues installing from the terminal. Next, find out whether your network card supports wake on LAN. You’ll be given detailed information on your Ethernet interface hardware. We are looking for: The first line tells you whether your PC supports Wake-On-LAN. There might be other letters along with the g. For now, we only need the “g.” The second line shows whether Wake-On-LAN is enabled. Don’t worry too much about that, as our next task will be to enable it.

Enable Wake-on-LAN

The command to enable Wake-on-LAN is as follows: This will enable the service and allow your PC to be turned on by a network device. To power on the device using this feature, type the following in terminal, Windows PowerShell or command prompt. This will enable it to power on once via a magic packet. However, the service doesn’t turn on on startup and is disabled after the first time. Ideally, you want to be able to power it on every time.

Automating Wake-on-LAN

First, you need to find where ethtool is installed. This terminal command will do that. Secondly, you need to create a file that enables the service on boot. You can do this in your favorite text editor and place the file in “/etc/systemd/system/.” The contents of the file should be: The vital bit in this section is the service and install parts. Oneshot is the default type parameter. It means that your service manager (systemd in Ubuntu) will execute the commands once sequentially, which is perfect because you want to change your wake-on-LAN setting to go once. The install section tells systemd that your WOL service should run on the first level. The concept of levels, grouping, and how the system manager works is another rabbit hole, but all you need to know for now is that it will start on boot. An issue you may run into in this section is permissions. By default, Ubuntu will not allow you to add files to the systemd folder. You can change this using chmod. You will need to have read and write permissions.

Final Steps

The final step is to restart daemon and enable the service. This will happen automatically if you restart your system, but it is quicker to do it in the terminal. Systemctl controls systemd, and daemons are essentially helper applications. What you’re doing here is restarting the supervisor, so that detects the new file in the systemd folder. You can check whether the service is running using:

Wireless Wake-on-LAN

Now you can turn on your PC via LAN, but what about wireless wake-on-LAN or woWLAN? As of this article, there is only one snap application (network-manager) that allows you to do this. You can install this from the snap store or the terminal using the following command: Beware, as this application is only rated one star in the store. During testing, the application ran as expected in the terminal, and it has full-length documentation by Canonical. You can attempt to enable woWLAN using another network manager, but the default (networkd) has no method of enabling it. You can enable wireless wake-on-LAN using this command: If you’re on an open network or wary of security threats, you can set a password using: There are some advantages to using this method over ethtool. It’s quicker to install and allows wireless wake-on-LAN. It has kernel level access, so if the computer loses power, you can still use wake-on-LAN when power returns. The issue is that Canonical only recommends it for Ubuntu core users. There is no specific reason for this, but it’s likely to keep the application contained and to prevent users from breaking their OS. Image credit: Technician team connect cable wire network to router by 123RF