If you've ever wanted to remotely restart a service on your Windows PC from your Linux machine, the Command-Line fu web site has you covered with the quick and easy command to use.
In order to actually use this command, you'll need to make sure that you have the samba-common package installed for Ubuntu, or the corresponding package for your Linux distribution.
# sudo apt-get install samba-common
command will do it for any Debian-based Linux.
Now you can list the services available on a Windows machine by using the following command, making sure to use credentials that have administrative privileges on the remote machine:
Once you've identified the service name that you want to restart, you can issue separate stop and start commands.
# net rpc service list -I IPADDRESS -U USERNAME%PASSWORD
To stop the service:
Then you can start the service again with the following command:
# net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD
Readers should note that a number of factors may influence whether this technique actually works—if the machine has a desktop firewall installed or the file sharing services are disabled it probably won't work, but it's still a very helpful technique that might come in handy.
# net rpc service start SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD