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/About Device”. Then tap on “Build Number” seven times (under ‘Version’ tab in any).
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/Debian:
Scrcpy in system repository is old! For the latest release, see this step by step tutorial.
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 (but NOT for Debian 12), 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 (This is required until you click “ALLOW” in the ‘Allow USB debugging’ pop-up dialog. See the screenshot below).
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: To 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):
- Run command to start the daemon to listen on USB:
adb usb
Option 2: To 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.
- Start/Restart the adb daemon 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, start Scrcpy either by running scrcpy
command in terminal or by launching from start menu.
Here you may need to authenticate by click “ALLOW” USB Debugging in Android screen (if prompted). And if everything goes well, your Android screen should appear on your Linux desktop.
Or, start scrcpy from command line by running command: scrcpy --select-tcpip
(for wireless mode) or scrcpy --select-usb
(for usb mode) depends on how you started the adb daemon.
Step 4: Create App shortcut icon for Ubuntu/Debian
For Ubuntu/Debian users installed Scrcpy package through apt install scrcpy
command, there’s NO shortcut icon for the app. Instead of launching it every time by running command in terminal, here’s how to manually create a shortcut icon for it.
- First, open terminal either from start menu or by pressing Ctrl+Alt+T on keyboard.
- When terminal opens, run command to create a shortcut file and edit it via gedit text editor:
gedit ~/.local/share/applications/scrcpy.desktop
Depends on your desktop environment, replace
gedit
withgnome-text-editor
,xed
, ornano
text editor. - When file opens, paste following lines and save it. For nano command line text editor, press Ctrl+X, type y, and finally hit Enter to save file.
[Desktop Entry] Name=scrcpy GenericName=Android Remote Control Comment=Display and control your Android device # For some users, the PATH or ADB environment variables are set from the shell # startup file, like .bashrc or .zshrc… Run an interactive shell to get # environment correctly initialized. Exec=/bin/sh -c '"$SHELL" -i -c scrcpy' Icon=scrcpy Terminal=false Type=Application Categories=Utility;RemoteAccess; StartupNotify=false
After that, Debian/Ubuntu users should be able to search for and launch Scrcpy from start menu or ‘Activities’ overview. If missing icons file, grab it from the project page and store in ‘.local/share/icons
‘ folder.
(Optional) Disconnect
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.
Recent Comments