Got an Android Phone or Tablet? Here’s a step by step guide shows how to get remote control of the device in Linux Desktop either wirelessly or via USB!
This tutorial is inspired by this reddit post, but with more detailed information that could help for beginners.
NOTE: This tutorial is tested and works on Ubuntu 22.04, Linux Mint 20/21, Fedora 36. Though, it should work on most other Linux.
Step 1: Enable USB Debugging mode in Android
In this tutorial, I’m going to use “Android Debug Bridge (adb)” tool to communicate with mobile device. You need to first enable “USB Debugging mode” in Android device.
Technically, there’s NO security issue or performance loss with Dev mode enabled in Android. It just enables all options that you could use for app development!
1. Enable Developer option
Go to “Settings” in Android device, then navigate to “About Phone”. Then tap on “Build Number” seven times.
Depends on your device, you may need to type password and PIN code to get pass. And, it will prompt something like “You are now in Developer Mode“, if done successfully.
2. Enable USB Debugging Mode
After step 1, go back Android “Settings”. There should be new “Developer Options” in menu or sub-menu of “Additional Settings”.
Go into that menu, and finally turn on the option for “USB Debugging“.
The menu options may vary on different Android devices. So, I don't provide the screenshots here. For problem, you may see Android official document for enabling Developer Mode and USB Debugging.
Step 2: Install ADB and Scrcpy in your Linux
Scrcpy is a popular free open-source software for controlling Android device in your Windows, macOS, and Linux Desktop. Most Linux include the package in either official or optional repositories.
Install Scrcpy in Ubuntu:
Option 1.) Ubuntu user may simply search for and install the app in Ubuntu Software (Snap Store), if you’re OK with Snap package which runs in sandbox.
And, you need to manually install ADB tools by running
sudo apt install adb command in terminal.
Option 2.) For those prefer the classic .deb package, press Ctrl+Alt+T on keyboard to open terminal, and run the command below to install
scrcpy as well as
adb as dependencies:
sudo apt install scrcpy
This command works on Ubuntu 20.04+, Debian 11, Linux Mint 20+ and their based systems.
Install Scrcpy in Fedora:
For Fedora Linux, there’s a Copr repository that contains the software pacakges.
Firstly, open terminal either via start menu or by searching from ‘Activities’ overview.
When terminal opens, run command to add the repository:
sudo dnf copr enable zeno/scrcpy
And, install scrcpy via:
sudo dnf install scrcpy
It mentioned that it requires the rpmfusion external repositories for build dependencies. Though I’m NOT sure if it’s required during installing process, as I’ve already have it in my system.
Install Scrcpy in Arch / Manjaro:
For Arch Linux, the package is available in system repository. Simply run command below in terminal to install it:
sudo pacman -S scrcpy
Or, search for and install it via the powerful ‘pamac’ package manager in Manjaro:
For other Linux, Windows, and macOS, see the software in github project page.
Step 3: Connect Your Android in Linux
If you’ve successfully enabled USB Debugging in Android, and installed Scrcpy & ADB in Linux. Now, connect your mobile phone into Linux PC with USB cable.
And click “ALLOW” in Android screen if following pop-up occur in your device:
The above Android notification may occur multiple times, while connecting and/or running the commands below.
Option 1: Control Android in Linux via USB:
If you would like to mirror the Android screen in your Linux desktop via USB cable, open terminal and run commands below one by one (tested only in Fedora 36):
- Restart the service and listen on USB:
- Control Android through USB via scrcpy:
Option 2: Control Android wirelessly:
Or, you may connect wirelessly via TCPIP protocol, though MUST in same local network. Also, open terminal either from start menu or by searching from ‘Activities’ overview.
- Restart the service and listen on TCP port:
adb tcpip 5555
- Connect via your Android’s IP address (replace the IP below):
adb connect 192.168.0.158:5555
- Now, disconnect USB cable. It’s no longer required
- Finally, run scrcpy to start controlling Android remotely:
Here you may need to authenticate by click “ALLOW” USB Debugging in Android screen (if prompted).
Step 4: Assign a Keyboard Shortcut:
You don’t have to run the previous command any more. Just assign a shortcut key, then you may press the key combination any time on keyboard to start connecting your Android device. Though, it may require to authenticate each time in Android screen by clicking ‘Allow’.
NOTE: the steps below is for GNOME only, the default desktop environment in Ubuntu, Fedora Workstation, and optional in Debian, Arch, Manajaro, etc.
Firstly, go to top-right corner system menu and click “Settings” option to open Gnome Control Center.
When it opens, navigate to “Keyboard” in left, and then click “View and Customize Shortcuts” in bottom right.
In pop-up dialog, go to bottom “Custom Shortcuts“, click either ‘Add’ or ‘+’ to add new shortcut and type in:
- Name: whatever as you want.
- Command: scrcpy
- Shortcut: whatever key combination as you want.
Now, press the shortcut key at any time will start connecting your Android via Scrcpy, though authentication in Android screen may (or may not) be required.
You can close the app window in Linux desktop to stop mirroring the Android screen. And, re-connect via either
scrcpy command or the previous shortcut you set.
But, if you don’t want to remote screen your Android device any more. Disconnect it via command:
adb disconnect 192.168.0.158:5555
Replace the IP address to yours and done.