linuxubuntu

Wake-on-LAN on Linux (Pop!_OS)

1 min read

Setting up the service:

Install the software:

text
sudo apt-get install ethtool

To set up a systemd service, we create the file wol.service:

text
vim /etc/systemd/system/wol.service

And add the following content:

text
[Unit]
Description=Enable Wake On LAN

[Service]
Type=oneshot
ExecStart = /usr/sbin/ethtool --change enp4s0 wol g

[Install]
WantedBy=basic.target

The following command makes systemd recognise the newly created service:

text
systemctl daemon-reload

And we enable the service so that it runs when the computer boots:

text
systemctl enable wol.service

Then we can reboot the computer.

Consistency

After suspending the computer once, it no longer wakes up the next time. So we create a suspend command as an alias, editing the aliases file as follows:

text
vim ~/.bash_aliases

and add the following content:

text
suspend="sudo systemctl restart wol.service; sudo systemctl suspend"

Next we apply the changes made to the .bash_aliases file by running the following:

text
. .bashrc

Now we can use our suspend command.

This was tested on an MSI laptop.


Photo by Jordan Harrison on Unsplash

#pop_os!#wake-on-lan#wol