Using a screen of a remote computer is often using VNC (Virtual Network Computing), or other remote desktop solutions. These come in both commercial and open source flavors. But how do you go about mirroring, and using, your Android mobile phone to and from your Linux desktop?
It is all possible via ADB – the Android Debug Bridge, which is included in the stock Android SDK (Software Development Kit) and is available as an easy install on most modern Linux distributions. Setting up ADB and configuring is not the focus of this article, and you can find detailed instructions on how to do so in our How to Use ADB Android Debug Bridge to Manage Your Android Mobile Phone article.
In this tutorial you will learn:
- How to mirror your Android mobile phone screen to your Linux based workstation
- How to remotely control your Android mobile phone screen via ADB
- How to remote control your mobile phone via USB and via Wi-Fi
Software requirements and conventions used
|Category||Requirements, Conventions or Software Version Used|
|Software||Bash command line, Linux based system|
|Other||Any utility which is not included in the Bash shell by default can be installed using
|Conventions||# – requires linux-commands to be executed with root privileges either directly as a root user or by use of
$ – requires linux-commands to be executed as a regular non-privileged user
If you have not setup ADB yet, please read our How to Use ADB Android Debug Bridge to Manage Your Android Mobile Phone article first.
Once ADB setup, either using a physical USB cable or connected via your wireless network, starting a remote screen session for your Android mobile phone is exceedingly simple. The way to connect depends on whether you are connected via USB cable or via wireless.
If you are connected via USB, simple execute:
$ adb devices List of devices attached UI84762QNI3 device $ scrcpy
The first command (
adb devices) shows us that a single device is connected via USB (otherwise an IP address and port number would be shown). The second command (
scrcpy) starts a remote screen session.
You should remote an almost-immediate new dialog box which immediately shows your phone’s screen. If you do not see it, or if it is black, close it, unlock your phone, and re-issue the command. You may find it somewhat easier to just turn off automatic screen lock while using this functionality.
The Wi-Fi Alternative
Connecting via Wi-Fi is also easy, provided you set it up as per the ADB How-to article linked above. First, check if you can connect correctly:
$ adb connect 10.0.0.191:2233 connected to 10.0.0.191:2233 $ adb devices List of devices attached 10.0.0.191:2233 device
If you see output similar to this, your phone is connected correctly across your Wi-Fi network (via ADB) to your Linux desktop and you can now start to mirror your screen using the same
Remotely Controlling Your Phone
Now that you are setup, it easy to use your mobile phone. Enter your password etc., or use biometrics to unlock your phone. If you want to use biometrics, you will have to physically access your phone.
Moving your mouse around and clicking inside the screen works very similar to using your phone with your finger. For example, to go to the next page of icons on your desktop, press your left-mouse button and hold it, and make a sweeping move to the left. The next page of icons will be shown. Right-mouse clicks will generally do nothing.
You can also use the normal Android buttons near the bottom (by default) of the screen. Slightly more complex if you have enabled the flat-bar buttons, but one tends to quickly get used to it.
Missing the top menu? It is no different from using your phone; simply drag your mouse cursor down from the top of the screen (just under the title bar of the Linux dialog box) and the top menu will open. It is again a little tricky until you get used to it. If you cannot get it to work smoothly, start at the place where the clock is located (in other words, click on the clock with the left mouse button and keep it in.), and drag down your mouse slowly. See the top menu open? Go far enough for it to ‘lock into’ the menu in full.
In this article, we explored the screen mirroring and remote screen use function of the ADB toolkit. We looked at connecting via USB and via Wi-Fi as alternative ways of communicating with your phone via ADB. Finally, we looked at the
scrcpy command and explored how to use the mobile screen interface from your Linux desktop. Enjoy!