Switching On a local/remote PC via terminal

2 minute read

Steps to setup wake up on lan on a remote PC

Just show me solution


I have a local PC with a GPU which I use to run machine Learning models and some heavy processing (building release version of Android App). It only has a LAN port and is kept near to the router which is not next to my working desk. I us ethis system via ssh into it and shut it down when i’m not using it (save energy).


I have to move my chair or get up and go to the system(5 steps way) to switch it on and I’m nor thrilled to do that plus I can’t automate stuff vai tasker or IFTT due a physical step.


I observed that even when I shutdown the system the LED on the LAN port was glowing and after doing some research found that we can switch on the system remotely even if it is off.
Wake on Lan (WOL) to the Rescue
Using Wake on Lan you can switch on a system even when it is turned off. Given its plugged in and connected to the router/switch.

Server/PC configuration: Ubuntu 18.04 LTS

  1. ip a //get the ip broadcast and mac address for the interface ex: eno1 in my case
  2. sudo ethtool -s eno1 wol g //if not installed get it from apt
  3. Create a service for WOL so that it persists across restarts
    1. cd /etc/systemd/system
    2. sudo vi wol.service
      use the code below replace eno1 with the correct interface name
       Description=Configure Wake-up on LAN
       ExecStart=/sbin/ethtool -s eno1 wol g 
    3. Make the Service start with system
       systemctl daemon-reload
       systemctl enable wol.service
       systemctl start wol.service

On the Laptop or other PC side
I use MacBook so I installed wakeonlan from homebrew to send the magic packet to wake the system. There are multiple tools for systems and even simple python script which do the same.

  1. Install wakeon lan
    brew install wakeonlan
  2. run the command
    wakeonlan -i -p 7 xx:xx:xx:xx:xx:xx
  3. Optional add the above to an alias to make it easy to use


  • IP is not the system IP instead it is the broadcast address
  • port is by default 7
  • xx:xx:xx:xx:xx:xx = mac address of the remote system


Thats it, now I can sit on my chair for hours together. Which in the hindsight is not good for my back.


  1. blog.yucas.net
  2. apple.stackexchange.com