[Linux 250 Common Commands Quick Reference Manual] Follow [Beginner Station], reply “1001” in the background to get it.
Do you know how to screen mirror an Android phone to a Linux system? This article will explain how to screen mirror an Android phone to Ubuntu using the Scrcpy software.
1. Introduction to Scrcpy
First, let’s get to know Scrcpy.
Scrcpy is an open-source command-line tool designed to allow computer users to control their Android devices through Android ADB or via USB cable, supporting operations on Android devices using mouse and keyboard, and importantly, does not require root access.

2. Main Features of Scrcpy
-
Free and open-source -
No root access required -
Can run on Linux, Windows, and Mac systems -
Clipboard sharing -
Lightweight (native, only displays device screen) -
Performance (30~60fps) -
Quality (resolution up to 1920×1080 or higher) -
Low latency (35-70ms) -
Fast startup (can start displaying within seconds) -
Non-intrusive (does not require any program installation on Android devices)
3. Usage Requirements
-
The Android device system version needs to be Android 5.0 (API 21) or above. -
Ensure that you have enabled ADB debugging on your device. -
On some devices, you may also need to enable additional options to control with mouse and keyboard.
4. Installing Scrcpy on Ubuntu
Install via the default software repository, the command is as follows:
sudo apt-get install scrcpy
Of course, you can also download the source code and compile it yourself, the command is as follows:
# runtime dependencies
sudo apt install ffmpeg libsdl2-2.0-0 adb
# client build dependencies
sudo apt install gcc git pkg-config meson ninja-build \
libavcodec-dev libavformat-dev libavutil-dev \
libsdl2-dev
# server build dependencies
sudo apt install openjdk-8-jdk
5. Running Scrcpy on Ubuntu
Connect the computer and Android device via USB and execute:
scrcpy
Supports execution with command line parameters, view the parameter list:
scrcpy --help
6. Introduction to Scrcpy Functions
1. Screen Settings
(1). Reduce Resolution
Sometimes, lowering the resolution of the device screen can effectively improve performance.
We can limit both the height and width to a certain size (e.g., 1024):
scrcpy --max-size 1024
scrcpy -m 1024 # short version
The shorter side will be proportionally reduced to maintain the display ratio of the device. Thus, a device with 1920×1080 resolution will display at 1024×576 resolution.
(2). Change Bitrate
The default bitrate is 8Mbps. If you want to change the bitrate (for example, change it to 2Mbps):
scrcpy --bit-rate 2M
scrcpy -b 2M # short version
(3). Limit Frame Rate
The frame rate can be limited with the following command:
scrcpy --max-fps 15
This feature is only officially supported by Android 10 and later, but it may also be available on earlier versions.
(4). Crop Screen
The device screen can be mirrored after cropping to display a portion of the screen.
This feature can be used, for example, to only show one eye of the Oculus Go.
scrcpy --crop 1224:1440:0:0 # 1224x1440 at offset (0,0)
If –max-size is specified at the same time, the resolution change will occur after the screen is cropped.
(5). Lock Screen Orientation
scrcpy --lock-video-orientation 0 # natural orientation
scrcpy --lock-video-orientation 1 # 90° counterclockwise
scrcpy --lock-video-orientation 2 # 180°
scrcpy --lock-video-orientation 3 # 90° clockwise
This setting affects recording.
2. Screen Recording
You can record video while mirroring the screen:
scrcpy --record file.mp4
scrcpy -r file.mkv
Record without enabling screen mirroring:
scrcpy --no-display --record file.mp4
scrcpy -Nr file.mkv
# Press Ctrl+C to stop recording
The “skipped frames” in the display will be recorded, although they are not displayed in real-time due to performance reasons. Each frame in the transmission has a timestamp, so variation in packet delay does not affect the recorded file.
3. Connection Methods
(1). Wireless
Scrcpy uses ADB to connect to Android devices. Meanwhile, ADB can connect to Android devices via TCP/IP:
-
Connect your Android device and computer to the same Wi-Fi. -
Get the IP address of the Android device (in Settings – About phone – Status). -
Enable the ADB TCP/IP function on the Android device: adb tcpip 5555. -
Disconnect your device from the computer. -
Connect to your device: adb connect DEVICE_IP:5555 (replace DEVICE_IP with the device IP). -
Run scrcpy.
Lowering the bitrate and resolution may help with performance:
scrcpy --bit-rate 2M --max-size 800
scrcpy -b2M -m800 # short version
(2). Multiple Devices
If multiple devices are listed after executing adb devices, you must specify the device’s serial number:
scrcpy --serial 0123456789abcdef
scrcpy -s 0123456789abcdef # short version
If the device is connected to the computer via TCP/IP:
scrcpy --serial 192.168.0.1:5555
scrcpy -s 192.168.0.1:5555 # short version
You can start multiple scrcpy instances simultaneously to display multiple devices’ screens.
(3). Auto Start on Device Connection
You can use AutoAdb:
autoadb scrcpy -s '{}'
(4). SSH Connection
Local ADB can connect remotely to another ADB server (assuming both ADB versions are the same), to connect to the device remotely:
adb kill-server # close the local ADB server on port 5037
ssh -CN -L5037:localhost:5037 -R27183:localhost:27183 your_remote_computer
# Keep this window open
From another terminal:
scrcpy
To avoid starting remote port forwarding, you can force a forwarding connection (note the difference between -L and -R):
adb kill-server # kill the local ADB server on 5037
ssh -CN -L5037:localhost:5037 -L27183:localhost:27183 your_remote_computer
# Keep this window open
From another terminal:
scrcpy --force-adb-forward
Similar to wireless network connections, the following settings may help improve performance:
scrcpy -b2M -m800 --max-fps 15
4. Window Settings
(1). Title
The window title defaults to the device model. You can change it with the following command:
scrcpy --window-title 'My device'
(2). Position and Size
You can specify the initial window position and size:
scrcpy --window-x 100 --window-y 100 --window-width 800 --window-height 600
(3). No Border
Close the border:
scrcpy --window-borderless
(4). Keep Window on Top
You can keep the window on top with the following command:
scrcpy --always-on-top
(5). Full Screen
You can directly start scrcpy in full screen with the following command:
scrcpy --fullscreen
scrcpy -f # short version
Full screen mode can be changed in real-time by pressing MOD+f.
(6). Rotate
The window can be rotated with the following command:
scrcpy --rotation 1
Optional values are:
-
0: No rotation -
1: Rotate 90° counterclockwise -
2: Rotate 180° -
3: Rotate 90° clockwise
Note that scrcpy controls three different orientations:
-
MOD+r requests the device to switch between portrait and landscape (if the foreground application does not support the requested orientation, it may reject the request). -
–lock-video-orientation changes the orientation of the mirror (the orientation of the device mirror to the computer). This affects recording. -
–rotation (or MOD+← (left) and MOD+→ (right)) only rotates the window’s display. This only affects the display, not the recording.
5. Other Mirroring Settings
(1). Read-Only
Disable the computer’s control over the device (such as keyboard input, mouse movement, and file transfer):
scrcpy --no-control
scrcpy -n
(2). Display Screen
If multiple displays are available, you can choose a specific display for mirroring:
scrcpy --display 1
You can find the display ID with the following command:
adb shell dumpsys display # search for "mDisplayId=" in the output
The second display may only be controllable if the device is running Android 10 or above (it may display on the computer but cannot be operated via the computer).
(3). Keep Awake
Prevent the device from sleeping while connected:
scrcpy --stay-awake
scrcpy -w
The device settings will revert after the program is closed.
(4). Turn Off Device Screen
When starting screen mirroring, you can turn off the device’s screen with the following command:
scrcpy --turn-screen-off
scrcpy -S
Or press MOD+o when needed.
To turn the screen back on, you need to press MOD+Shift+o.
On Android, the power button can always turn the screen on.
For convenience, if the power button event is sent via scrcpy (by right-clicking or MOD+p), it will turn off the screen after a short delay.
The physical power button can still turn on the device screen.
This feature can also be used to prevent the device from sleeping:
scrcpy --turn-screen-off --stay-awake
scrcpy -Sw
(5). Render Expired Frames
To reduce latency, scrcpy defaults to rendering the most recent successfully decoded frame and skipping any previous frames.
Force rendering of all frames (may increase latency):
scrcpy --render-expired-frames
(6). Show Touch
During presentations, you may sometimes need to display touch points (shown on the device).
Android provides this feature in Developer Options.
Scrcpy offers an option to enable this feature at startup and restore the initial settings upon exit:
scrcpy --show-touches
scrcpy -t
Note that this feature can only display physical touches (requires touching the screen with your hand).
(7). Disable Screensaver
Scrcpy does not disable the screensaver by default.
To disable the screensaver:
scrcpy --disable-screensaver
6. Input Control
(1). Rotate Device Screen
Use MOD+r to switch between portrait and landscape mode.
Note that switching will only occur if the foreground application supports the requested mode.
(2). Copy and Paste
Each time the Android clipboard changes, it is automatically synchronized to the computer’s clipboard.
All Ctrl shortcuts will be forwarded to the device. Among them:
-
Ctrl+c: Copy -
Ctrl+x: Cut -
Ctrl+v: Paste (after the clipboard synchronization from computer to device is complete)
This usually works as you would expect.
However, the actual behavior depends on the foreground program on the device. For example, Termux sends SIGINT when Ctrl+c is pressed, while K-9 Mail will create a new email.
In this case, cut, copy, and paste (only available in Android >= 7):
-
MOD+c: Inject COPY (copy) -
MOD+x: Inject CUT (cut) -
MOD+v: Inject PASTE (paste) (after clipboard synchronization from computer to device is complete)
Additionally, MOD+Shift+v can convert the computer’s clipboard content into a series of key events input to the device. This feature can be useful when the application does not accept paste (like Termux). Note that this feature may cause non-ASCII encoded content to appear incorrectly.
Warning: Pasting content from the computer’s clipboard to the device (whether via Ctrl+v or MOD+v) requires the content to be saved to the device’s clipboard. Thus, any application can read it. You should avoid transferring sensitive content this way (like passwords).
(3). Pinch to Zoom
Simulate “pinch to zoom”: Hold Ctrl and move the mouse.
More specifically, you need to hold Ctrl while pressing and moving the mouse. After releasing the left mouse button, any cursor operation will occur relative to the center of the screen.
Specifically, scrcpy uses “virtual fingers” to generate touch events at the opposite position relative to the center of the screen.
(4). Text Injection Preference
When typing, the system generates two types of events:
-
Key event, representing a key being pressed/released. -
Text event, representing text being input.
The program defaults to using key events to input letters. Only in this way will the keyboard work normally in games (especially WASD keys).
But this can also cause issues. If you encounter such issues, you can avoid them with the following operation:
scrcpy --prefer-text
(this may cause the keyboard to not work correctly in games)
(5). Key Repeat
When you hold down a key, the program defaults to generating multiple key events. In some games, this may cause performance issues. Search for the public account: Xinan Hacker Technology on WeChat, reply: Hacker to receive materials.
To avoid forwarding repeated key events:
scrcpy --no-key-repeat
7. File Transfer
(1). Install APK
If you want to install an APK, drag and drop the APK file (file name ending with .apk) into the scrcpy window.
This operation will not show any changes on the screen but will output a log in the console.
(2). Push Files to Device
If you want to push files to the device’s /sdcard/, drag and drop files (not APK files) into the scrcpy window.
This operation has no visible response and will only output logs in the console.
You can modify the target directory at startup:
scrcpy --push-target /sdcard/foo/bar/
(3). Hotkeys
In the table below, MOD is the modifier key for hotkeys. The default is (left) Alt or (left) Super.
You can use the –shortcut-mod suffix to modify it. Optional keys include lctrl, rctrl, lalt, ralt, lsuper, and rsuper. For example:
# Use the right Ctrl key
scrcpy --shortcut-mod=rctrl
# Use the left Ctrl, Alt, or Super key
scrcpy --shortcut-mod=lctrl+lalt,lsuper
Generally, Super is Windows or Cmd.

-
1. Double-click the black border to close the black border -
2. Right-click the mouse to light up the screen when it is off; otherwise, it is considered to press the back key. -
3. Requires Android version Android >= 7.
All Ctrl + key hotkeys are forwarded to the device for processing, so they will actually be responded to by the current application.
(4). Custom Path
To use the ADB you want, you can set its path in the ADB environment variable:
ADB=/path/to/adb scrcpy
If you need to override the scrcpy-server path, you can set it in SCRCPY_SERVER_PATH.
[Linux 250 Common Commands Quick Reference Manual] Follow [Beginner Station], reply “1001” in the background to get it.
