10 Android terminal commands every smartphone owner should know
The average user doesn't typically use terminal commands to interact with their phone. It might seem like it's too complicated or takes too much work to learn, but there are a few useful and easy terminal commands. Android and your computer communicate through the Android Debug Bridge (ADB). It works on Windows, macOS, Linux, and even budget Chromebooks. ADB is a powerful tool, and we show you how to use it with terminal commands to do things like install apps and custom ROMs.
Before you begin
Before using ABD, go to the Android developer's site to get the SDK (Software Development Kit) tools you'll need to get started, and turn on Android Developer Options in your settings. We cover everything you need to know in our ADB install guide. It only takes 5 to 10 minutes until you can open a terminal and test these commands.
You can use the adb --help command to see all the command options for ADB.
How to install and use ADB on Windows, Mac, Linux, Android, Chromebooks, or even in a browser
Want to set up and use ADB? Read this
Initiate communication
Two simple commands to start and stop ADB
After connecting your phone to your computer, you can tell it you're ready to send commands with the adb start-server command. When you're done or want to disconnect to test something, adb kill-server stops the communication bridge.
Make sure you're connected
The easiest way to make sure ADB is ready
If ADB is up and running, type adb devices and press Enter to return a string of numbers and the word device. The string of numbers is your device's unique serial number. While most of us only connect to one device at a time, if you have several phones plugged in, the number is how you tell them apart.
Using the command adb devices -l gives you additional information about your Android phone, including the product name and model. Many phones are released with different variants. This helps you narrow it down if you use ABD to flash a custom ROM.
If you're in the bootloader, which is where you'll install custom ROMS, unlock your device, and perform other low-level system operations, use fastboot devices instead of adb devices to make sure you're connected.
In Command Prompt, make your font bigger on Windows by right-clicking the upper-left corner of the window, choosing Properties, selecting the Font tab, and choosing your Size. If you use a macOS Terminal, press Command and + until you reach the size you want.
Reboot to different areas
You can reboot into the bootloader or recovery mode
When you are done using ADB, you can reboot your phone as you normally would, using the adb reboot command. You can also reboot into recovery (adb reboot recovery), fastboot (adb reboot fastboot), or the bootloader (adb reboot-bootloader) with their commands.
Root superuser privileges
Advanced Android commands require elevated privileges
You'll need heightened permissions to access special areas of your operating system or storage. These commands only work if you have a rooted device. When you want to perform advanced operations, adb root restarts the Android Debugging Bridge in the same way you use abd kill-server and adb start-server, but it starts with root privileges activated. If you want to return to being a normal user, use the adb unroot command.
Send files to or get files from your device
Push or pull files with the command line
You can interact with the storage on your device in the command prompt using these ADB commands.
- To push (send) files, use adb push [local file location] [device file location]
- To pull (receive) files, use adb pull [device file location] [local file location]
Here's a simple example you can try. Replace the file paths with your own. Create a basic text file (.txt), write something in it, and save it as file.txt.
adb push /path/to/local/file.txt /sdcard/file.txtNow, use your phone as you normally would to check if your text file is on your SD card. To test getting that file back from your phone, use:
adb pull /sdcard/file.txt /path/to/local/file.txtThe main benefit over moving files the way you normally would is that you can copy files to or extract files from restricted areas (file system or app data directories) as long as you have root access.
Install or uninstall apps
This is how you sideload an app
Sideloading installs things directly, like apps with their .apk files, using ADB or other methods outside an official app store. This can be confusing because there is an adb sideload command that we cover later. That command isn't used to sideload apps. You'll use adb install instead.
Here's the syntax for the two commands:
- To install files, use adb install [path/to/app_name.apk]
- To uninstall files, use adb uninstall [app_name.apk]
When using adb install, use your local file directory where you stored your .apk (without the brackets). When using adb uninstall, use the name of your .apk app file.
Troubleshoot issues (debugging)
ADB is a great way to troubleshoot problems
Logcat returns real-time logs from an Android device, including system messages, error reports, logs for specific apps, and other information you can use to diagnose a problem. There are several options for this command that you can look up when you're ready to use it.
The command terminal on your computer returns a limited number of lines. To test this, we'll send an output file with the logcat information to your computer. The -d in the command tells it to send the information as it is and discontinue monitoring after the command. The file location works the same as the other examples we've given. Replace the path without the brackets.
If you don't use -d and only use adb logcat, you get a continuous running output in your command terminal. If you want to give it a try to see what happens, use Control + C to exit out of it, on both Mac and Windows.
Advanced debugging
Get even more debugging info
Dumpsys gets information on different system services on your device. You can take a look at the full log in the same way we used logcat, and send the output file to your computer.
adb shell dumpsys > [path/to/dumpsys_output.txt]There are several options for dumpsys, and you can target specific things like adb shell dumpsys battery or adb shell dumpsys wifi.
Use Linux commands
Get access to the Android OS and its file system
We used our first ADB shell command with dumpsys. The adb shell command opens a command-line interface (CLI) or "shell" on your Android device or Android emulator. You can test it with the simple list (ls) command above, which returns a list of commands that are available in the system directory /system/bin.
You can use several Linux commands with adb shell that you can't use with ADB alone. This is getting into advanced user commands. You can do things like make a directory (mkdir), filter log outputs (grep), check network statistics (netstat), and see what's in your current working directory (pwd).
Manually install firmware
Install custom ROMs and OTA updates
Let's end with one of the main reasons people use the Android Debug Bridge: installing custom ROMs or OTA updates. The abd sideload command installs .zip files of your firmware, whether it's an official version for your device or a custom ROM like LineageOS.
adb sideload name_of_file.zipDon't try this without following the instructions for the firmware you want to install. Installing firmware manually can brick your device if you do it wrong.
Become an Android power user
ADB is a powerful tool, and there's a lot you can do with it. Custom firmware can bring new life to an old phone, with a more current Android version than the manufacturer supports. Did you know you can install Android 14 on an old Samsung Galaxy S9 with the LineageOS ROM? Starting with the basics is a great way to get used to tools that are new to you.