Monday, July 5, 2010

Restart Windows Services from Your Linux PC

Restart Windows Services from Your Linux PC

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.

The simple


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:
# net rpc service list -I IPADDRESS -U USERNAME%PASSWORD
Once you've identified the service name that you want to restart, you can issue separate stop and start commands.

To stop the service:
# net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD
Then you can start the service again with the following command:
# net rpc service start 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.

No comments:

Post a Comment