Using terminal commands for Android may seem complicated, but it really doesn’t have to be. With the right knowledge, you can easily connect and perform all sorts of useful functions.
Most people don’t use terminal commands to communicate with their Android because it looks complicated and it seems difficult to learn. But there are a few handy and simple terminal commands that you can use without too much knowledge.
Android and your computer can talk to each other through something called the Android Debug Bridge (ADB). This works on Windows, macOS, Linux and even inexpensive Chromebooks. ADB is a powerful tool, and we’ll show you how to use it to do things like install apps and put custom software on your phone.
The best Android commands for your smartphone
Terminal commands are text commands that you enter into a special application on your computer, such as the terminal or command prompt. These applications allow you to interact with your operating system without using graphical interface. Instead, you give instructions in the form of text.
Before you get started with ADB, you must first download the SDK (Software Development Kit) tools from the Android developer’s site. It will only take you 5 to 10 minutes to set everything up completely. Once you have everything set up, you can run the commands below.
#1 Look up information about your Android
If ADB is on, type adb devices and press Enter. You will see a series of numbers and the word “device.” Those numbers are your device’s unique serial number. Most people only connect one device at a time, but if you have multiple phones, that number will help you tell them apart.
If you use the adb devices -l command, you’ll get additional info about your Android phone, such as the product name and model. A lot of different phones come out, so this helps you see which one you have, especially if you’re using ADB to flash a custom ROM.
(Image: unsplash/Ruan Richard Rodrigues)
#2 Installing and uninstalling apps
Sideloading means installing apps directly with their .apk files, and this can be done outside the official app store. This is ideal if you want to download an app on your Android that can’t be found in the Play Store. Here’s how to use the two commands:
To install an app, use: adb install [path/to/app_naam.apk]
To uninstall an app, use: adb uninstall [app_naam.apk]
For “adb install” you enter the path to the folder where you saved your .apk file (without the parentheses). And with “adb uninstall” you just use the name of your .apk app.
#3 Solve problems
Logcat is a handy tool that lets you see what’s happening on an Android phone. It gives you a real-time list of messages, such as system notifications, error messages and information from apps. This can help you if you want to fix a problem:
adb logcat -d > [path/to/logcat_output.txt]
If you use logcat on your computer, you will only see a limited number of lines. To test, you can store the information in a file and send it to your computer. The -d after the command means it should just pass the information as is, then stop looking. Where you save the file works the same way as the examples we gave earlier. Don’t forget to modify the path (without the parentheses).
If you just use adb logcat without -d, the program continues to display new information. If you want to stop that, you can press Control + C on both Mac and Windows.
Android is going for it (Image: Unsplash)
#4 Advanced debugging
Dumpsys gives you information about various system services on your device. You can view the log in the same way as with logcat and send the output file to your computer. There are several options for dumpsys, and you can target specific things, such as adb shell dumpsys battery or adb shell dumpsys wifi.
#5 Install firmware
Let’s close with one of the main reasons people use the Android Debug Bridge (ADB): installing custom ROMs or OTA updates. The adb sideload command lets you install .zip files of your firmware, whether it’s an official version for your device or a custom ROM like LineageOS. Then use: adb sideload name_of_file.zip