How to control Windows 10 via Linux terminal?
Solution 1
To interact with the windows desktop you need to:
1) Enable remote desktop connections via Control panel in the windows
2) Install a remote desktop client in Linux like rdesktop
3) Connect and authenticate using windows style domain and credentials.
Then you will be able to control your machine as if it was local (though with a lag)
If on the other hand you just want to send certain commands on windows to change settings, you will have to find their command line equivalent (I.e. how to change default screen via command line...) And issue this command over an ssh connection.
I hope this helps! Please do not hesitate for more information if required.
To open Firefox in windows remotely you would need a windowing system to render the graphics for you. Linux uses xwindows which is a client - server windowing application, so when you connect to Linux with SSH if you have Xwindows forwarding enabled you can open a graphics application on the server side (please note that the graphics are rendered on server side) and then see it on the client side. This is the magic of x-windows... In windows there is not a similar functionality (to my knowledge).
So if you need a graphical app like Firefox to be running on server side you have to connect to a full-fledged desktop environment via RDP (Remote desktop connection). There is an x-client for windows called xming but no x-server implementation.
Since, I believe that the question comes from a mixing up of the various remote connection protocols, I will include a brief description of what to do with them to help clarify things.
1 - Windows systems come with native support of RDPas server and as client, this is a protocol that provides remote access to a full-fledged desktop environment. The server needs to be enabled by allowing remote desktop connections, the client does not even need to be configured! RDP clients are available in linux too (e.g. FreeRDP
, rdesktop
).
2 - Most linux distributions come with embeded SSH and X11 servers. SSH can be combined
with X11 when the -X
option is used together with X11 allowing forwarding and SSH Daemon allowing X11 forwarding. When combined the user has the option to open graphical application without having to transmit and receiver a full-fledged desktop environment. Thus making the application a bit faster. Please, note that in this case, SSH provides the platform (or the underlying layer) and X11 is the application layer. Please, also note that the graphics are rendered (created) by the x-server and then just shown to the client.
It is possible to install an SSH server in windows quite easily. But in order to install an x-windows server in windows you would need an environment like cygwin (or MinGW though I am not sure about MinGW), which makes things a bit more complicated. You can however install X-ming quite easily which is an X-client windows application.
3 - There is VNC. The VNC protocol comes in server and client editions (many of them) for windows and linux and can be installed quite easily on both. For the differences between using SSH with X11 forwarding over VNC see:
Differences between VNC and ssh -X
4 - There are some "hybrid" solutions in linux:
xrdp using Xvnc or X11RDP. These solutions provide a full fledged x-windows desktop over VNC or RDP. Those solutions may be used in cygwin
too, for windows machines.
Some additional NOTES
According to the following X-architecture diagram the "application viewing part" of an X session is the client
and the "application running part" is the server
.
See:
https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/X_client_server_example.svg/440px-X_client_server_example.svg.png
According to the official website of Xming
the tool is described as an X-server
, this is kind of mixing me up. In any case I have used it only as a client, perhaps though it is possible to use it as a server too.
See:
http://www.straightrunning.com/XmingNotes/
Lastly, for instructions on how to install x-server over cygwin.
See this page:
http://x.cygwin.com/
Try to understand all the different options and possibilities
and thus make clear what you are after...
And also what concerns you?
- Is it perhaps security?
- Is it performance?
- Is it the difficulty of installation?
Lastly, I would like to remark about another potential interpretation of your question. What you may mean with controlling windows via linux could be to say run a command in linux and this command to result in firefox opening up in windows. This is also possible but only with programming. In such a case you could write a simple HTTP get server application (for instance using Perl and the Mojolicious framework), which would pop up firefox when receiving a specific HTTP get request. First you must install Perl and Mojolicious in your windows machine, then follow the rest of the description. You could write a CGI program that would respond to: wget http://ip_of_windows_machine:a_port/firefox with poping up firefox in your windows machine and enviorment or even more simply open this URL with a browser in windows or linux (or even your android mobile) and then the firefox application would popup in your windows machine.
As an example of such a solution (untested though): you could create a perl script named: expose_firefox.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/firefox' => sub {
my $c = shift;
# may have to specific the full path to firefox.exe
# if it is not in the PATH variable
system("firefox.exe");
$c->render(text => 'Firefox poping up!');
};
app->start;
then launch the server in your windows machine with:
morbo expose_firefox.pl daemon -l http://ip_of_windows_machine:a_port
Server available at http://ip_of_windows_machine:a_port
and then go to a linux machine connected to the same LAN with this machine and having the ability to communicate with this machine (i.e. belonging to the same subnet) and run this command :
$ curl http://ip_of_windows_machine:a_port/firefox
NOTE: I do know that this case description goes well beyond the limits of a Q&A session which is the primary purpose of this site, but I wanted to mention it because for some people, it would be helpful to know all their options, in order to be able to make a decision and perhaps, rephrase their answer to something more specific.
Solution 2
You can install an ssh server on your windows system and send commands remotely to it, by default, you will only have cmd.exe and powershell.exe shells available, but you can install additional shells.
You can try this project from Microsoft to get ssh server working on your Windows system. There is also a commercial software for that if you want official support form somewhere.
Once installed and configured, you will be able to send remote command line orders to your Windows computer from any computer with an SSH client of your choice.
You will need to properly configure NAT and Firewall to allow remote connection, but these are out of topic.
Once this setup is done, you can use psexec from sysinternals with the parameter "-i" to launch a graphical program to the remote computer.
Psexec has to be run on the target machine, because this is a windows tool, but if your client machine was running Windows, PSexec alone could suffice by itself to do that task.
Related videos on Youtube

k073l
Updated on October 03, 2022Comments
-
k073l less than a minute
Is there any possibility to control Windows via Linux? No GUI. I mean bash command for example: -app C:/firefox/firefox.exe "unix.stackexchange.com"
-
Eric Renouf about 6 yearsWhat would you like to have happen if you ran that command? Have you looked at something like cygwin?
-
k073l about 6 yearsI would like to see sth like that: I run command on linux and on barely same time I see results on Windows - for example firefox with opened unix.stackexchange.com
-
Eric Renouf about 6 yearsDo you want to have firefox open on the Windows machine or a remote Linux machine when you do that?
-
k073l about 6 yearsOn Windows machine
-
Eric Renouf about 6 yearsIt's pretty tough to get a remote command to interact with the desktop on a Windows machine. If you want to run "linux" like commands locally though you can install Cygwin, or perhaps the new bash for Windows, though I haven't tried it out yet myself
-
k073l about 6 yearsSo you think that the best would be connecting linux to cygwin and starting it loccaly on Windows via Cygwin?
-
Eric Renouf about 6 yearsWell, I don't know exactly what you're trying to do, so I don't know if that would meet your needs or not.
-
Gilles 'SO- stop being evil' about 6 yearsWhat do you mean by “control Windows via Linux”? Are you running Windows in a virtual machine on a Linux host? Are you using a Linux machine with a network connection to a Windows machine? Are you running Linux-on-Windows-10? Something else?
-
k073l about 6 years"contol Windows by Linux" I mean by this controlling Windows graphic interface by single bash command on Linux. Yep, Windows and Linux are connected to same WiFi, both are phisical computers.
-
Zulgrib about 6 yearsDid you try my solution already ?
-
k073l about 6 yearsWell, I didn't tried it yet.
-
-
Eric Renouf about 6 yearsMost of the time when I setup ssh servers I can run commands, but they can't interact with the default desktop
-
Zulgrib about 6 yearsThe question didn't tell about interacting with the default desktop.
-
Eric Renouf about 6 yearsThe comments I exchanged with the OP do clarify that point, but the question itself wasn't edited (yet) to reflect that requirement
-
Zulgrib about 6 yearsAdded solution to launch graphical programs on remote computer, but this is more a windows related question than a linux related question for this point.
-
k073l about 6 yearsI'm a bit concerned 'bout this idea, becouse it sounds for me like easy VNC. I mean more like: I type command on linux and I see effects on my Windows computer.
-
Angelos Asonitis about 6 years@k073I No, I believe that you are confusing the protocols (or rather the means of communication between the systems). There is VNC (which is a different protocol), there is RDP (the one that windows come with), there is SSH and there is the X11 protocol. I will update my answer with a brief description of these four protocols so that you form an accurate understanding.