Use Scrcpy to Mirror and Control Android on Linux

Scrcpy Feature Image

Scrcpy (pronounced as Screen Copy) is an open-source application you can use to seamlessly control and mirror your Android device on Linux. You can connect to your Android device via USB cable or wirelessly and control it using your keyboard and mouse. Here we show you how to control your Android device on Linux.

Why You Need Scrcpy in Linux

You might be thinking, out of all screen-sharing applications and Android mirroring applications, why do you need Scrcpy on your Linux system? The answer is simple: Scrcpy doesn’t require you to install any app on your phone nor does it require root access to your device. Additionally, it’s an open-source, lightweight, and high-performance command-line tool, making it ideal for anyone looking to mirror and control their Android device on a Linux system while enjoying the freedom of scripting and customization.

Moreover, it allows you to record your Android screen video and audio with numerous customization options such as bitrate and resolution, making it ideal for creating tutorials or capturing gameplay.

Note: To use Scrcpy, you must have at least Android version 5.

Features of Scrcpy

Here are some of the best features of Scrcpy:

  • Doesn’t require the internet and a user account
  • Allows you to record your device screen
  • Mirror Android with high-quality (1920×1080 or above) and low latency (35~70ms)
  • Supports audio forwarding (Android 11+)
  • Enables you to use the clipboard in the bi-direction
  • Supports OpenGL and OTG mode
  • Allows mirroring Android as a webcam
  • Supports camera mirroring (Android 12+)
  • Available for Linux, Windows, and macOS
  • Physical keyboard and mouse simulation
  • Allows you to use your phone while its screen is off
  • Enables you to crop the Android device screen while mirroring
  • Supports mirroring multiple devices simultaneously

Scrcpy also has many other interesting features. You can explore all these features by experimenting with this utility.

Installing Scrcpy in Linux

Before installing Scrcpy, you should install adb (Android Debug Bridge) in your system. For this purpose, execute one of the following commands, depending on your distro:

# Debian-based system
sudo apt install adb
 
# Fedora-based system
sudo yum install adb
 
# Arch-based system
sudo pacman -S android-tools
Install adb

After installing adb, install the stable version of Scrcpy:

# Debian-based system
sudo apt install scrcpy
 
# Fedora-based system
sudo dnf copr enable zeno/scrcpy && dnf install scrcpy
 
# Arch-based system
sudo pacman -S scrcpy
Install Scrcpy

You can also install the stable version of Scrcy using snap:

sudo snap install scrcpy
Install Scrcpy using Snap

After the successful installation, you can verify its version using the scrcpy -v command:

scrcpy -v
Scrcpy Version

Install the latest version of Scrcpy for more features

If you need features like audio forwarding and camera mirroring, you need to install the latest version of Scrcpy (currently it’s version 2.4).

For this purpose, you need to install it via its source code.

Firstly, ensure that your system has all the required dependencies:

# Debian-based system
sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
                 gcc git pkg-config meson ninja-build libsdl2-dev \
                 libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
                 libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
Scrcpy Dependencies

Then, clone the Scrcpy repository using the git clone command:

git clone https://github.com/Genymobile/scrcpy
Clone Scrcpy Repository

Next, navigate to its directory and run the Scrcpy installation script:

cd scrcpy
./install_release.sh
Install Latest Scrcpy

This way, the latest version of Scrcpy will be installed in your Linux system. To verify it, execute the following command:

scrcpy -v

Now, you’re all set to connect with your Android device via USB or wirelessly.

Connecting to Your Android via USB Cable

To connect to your Android device, you need to enable Developer options and USB debugging.

For this, head to your device Settings -> System option:

Android Settings

Open the About phone option and click on the Build number multiple times until you receive a message saying “You are a developer“:

Tap on the Build Number for 7 times

Next, head back to System settings and here you’ll be able to see Developer options. In the Developer options, enable the USB debugging option:

enable Developer options and USB debugging

After enabling the USB debugging option, you’ll get a prompt confirming your choice. Here, press the OK button:

Allow USB Debugging

Now, connect your phone to your Linux system with a USB cable. After doing this, you’ll observe a USB debugging mode notification on your Android.

Next, open the terminal in your Linux system and execute the scrcpy command to mirror your device:

scrcpy
Scrcpy Connect Via Usb Cable

Notably, you can see your Android mirroring on your system.

To disconnect your phone, simply press the Ctrl + C key.

Connecting to Your Android via Wireless Connection

You can also connect your Android device wirelessly. First, connect your phone to Linux via a USB cable and execute the following adb command to see Linux recognizes your Android device:

adb devices

Find out the IP address of your Android:

adb shell ip route
adb devices and adb shell ip route commands output

Keep in mind: Your Linux and Android must be connected to the same Wi-Fi connection.

You can also check the IP address of your phone by going to its Settings -> Wireless & network -> Wi-Fi option and pressing the Configure button:

Find IP address in Android Wi-Fi settings

After knowing your phone’s IP address, you’ve to configure a port for your TCP/IP connection. For instance, I set it to 5000:

adb tcpip 5000

Note: You can configure any unassigned port.

Now, disconnect your phone from the USB cable. Then, connect your phone to your Linux system using its IP address and the specified TCP/IP port over a network:

sudo adb connect 192.168.1.121:5000
Adb Connect

In case of multiple devices, you can use the serial number of your Android to connect to it over a network:

scrcpy -S <serial-number>

Finally, execute the scrcpy command to control and mirror your Android:

scrcpy
connect to phone Via TCP/IP

As mentioned earlier, you can disconnect this connection by pressing Ctrl + C key.

Scrcpy Usage Examples

Let’s explore some examples of the Scrcpy command to understand how it works.

Change Window Title

You can change the title of the window displaying your Android by using the --window-title flag in the scrcpy command:

scrcpy --window-title='Make Tech Easier'
Change the window title of Scrcpy Android screen

Record Android Screen

You can record the screen of your Android by using the -r or --record flag. For example, you can record your device screen and save it in a new file named “maketecheasier.mp4“:

scrcpy --record maketecheasier.mp4
Scrcpy Record Screen

You can also combine the -r flag with the -N flag, which means no display. This way, your Android screen will not show up on Linux. However, the entire screen will still be recorded to a file:

scrcpy -Nr MTE.mp4
Scrcpy No Display Recording

Customize Window Screen

Additionally, you can set the maximum size (width and height) of your window using the -m or --max-size option:

scrcpy -m 950
Scrcpy set Max Size

You can even limit the mirror to read-only mode by using the -n or --no-control flag. This way, you’ll be able to only view your Android screen on Linux:

scrcpy --no-control

Furthermore, you can limit the screen capture framerate using the --max-fps flag in the Scrcpy command:

scrcpy --max-fps=50

Scrcpy also offers a --show-touches flag, which enables you to see the physical touches of the device in real-time on your Linux:

scrcpy --show-touches

You can use the -S flag of the Scrcpy command to lock your device and still be able to control it. This flag helps save the energy of your Android:

scrcpy -S

Lastly, you can use the --rotation flag to set the initial display rotation. The default value is 0. However, the possible values are 0, 1, 2, and 3, with each value adding 90 degrees of rotation counterclockwise:

scrcpy --rotation=3
Scrcpy Rotation

Scrcpy offers numerous other useful options, you must explore and try them out.

Removing Scrcpy from Linux

You can execute any of the following commands to uninstall Scrcpy from your system depending on your installation method:

# Debian-based system
sudo apt remove scrcpy
 
# Fedora-based system
sudo dnf remove scrcpy
 
# Arch-based system
sudo pacman -R scrcpy
 
# snap
sudo snap remove scrcpy
 
# Latest version via source code
sudo ninja -Cbuild-auto uninstall
Remove Scrcpy

This way, you’ve successfully removed Scrcpy from your system. In case you don’t like Scrcpy you can try other Android mirroring apps to control your device from your Linux system.

Image credit: Nimrach Chaudhry. All alterations and screenshots by Nimrah Chaudhry.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Nimrah Chaudhry
Nimrah Chaudhry - Contributor

With 2+ years of experience, I'm a technical writer holding a Bachelor's in Software Engineering and Cyber Security Certification. I'm passionate about simplifying Linux complexities into bite-sized wisdom for the community.