How to install and setup ADB tools on Linux

ADB (Android Debug Bridge) has a vast amount of capabilities. We are going to feature a concise list of the most useful features ADB provides us and also guide to installing it on your Linux PC.

If you have an Android phone, you probably want to create backups relatively quickly and reliably. Chances are you have unnecessary built-in Google apps or apps from your manufacturer that you want to get rid of. This is not allowed by default, obviously, but there is a solution.

Its a rather elegant one, because it involves no third party programs, that could be potentially malicious, but a part of the open-source Android SDK (Software Development Kit). The utility we are going to use is ADB.

ADB features and how to install

ADB (Android Debug Bridge) has a vast amount of capabilities. We are going to feature a concise list of the most useful features ADB provides us.

Transferring files

Files can be transferred from the phone, or to the phone using ADB. It uses the utilities of ‘push‘ and ‘pull‘ to achieve the mentioned task.

You can even sync an already copied directory, that may have been modified.

Uninstalling app/services

ADB can be used to uninstall any app on your phone. Yes, you can get rid of those pre-installed apps that you never found a use for, and which only ended up making your phone messier.

Installing apps

APK files can be installed across the phone very quickly if you have it on your system. Just a simple code, no prolonged processes or prompts, and that app will be installed.

Check logs

The phone’s logs in real-time can be accessed using a straightforward command.

Backups

Backups can be created via ADB, and in fact, it has several useful options for that. These are the things that the yes/no options are provided for:

  • storing APK files of apps installed
  • storing OBB (saved) data of apps installed
  • storing the content of the device’s SD card

The restoring options are also available.

How to install

Installing ADB is quite simple. For Ubuntu/Debian and its derivatives, use the following command:

sudo apt-get install android-tools-adb

Or if it doesn’t work,

sudo apt-get install adb

ADB installing
ADB installing

On Fedora, use:

sudo dnf install adb

Setup

Now, we’ll show an essential guide to setting up your phone for using ADB. First of all, enable ‘USB Debugging‘ from the Developer Options in the settings. Go back to your system, and enter this command:

adb start-server

ADB starting
ADB starting

Now connect your phone to your system with a data cable. You will get a prompt asking whether or not do you want to allow USB debugging. Check ‘Always allow from this computer‘ and tap ‘OK.’

Now you can deploy commands.

Optional: Wireless connection

To connect to your phone wirelessly, make sure that your phone and computer system are connected to the same network. For now, connect your phone to your computer system through a data cable, with ‘USB Debugging‘ enabled in the Developer Options of your phone’s settings.

You will get a prompt on your phone whether to trust the computer it has been connected to, to which you need to answer with the positive remark.

Go to your phone’s settings, and navigate to ‘About Phone.’ Move to the ‘Status‘ menu. There will be a slot denoting the IP address of your phone. Make a note of it.

IP Address on phone
IP Address on phone

After completing the steps above, enter:

adb tcpip 5555

This enables connecting to your phone through the 5555 port.

You can now unplug your device. To connect to your phone wirelessly now, enter the command in the following format:

adb connect <IP ADDR OF PHONE>:5555

Enabling wireless connection
Enabling wireless connection

Now you are ready to deploy commands.

Usage

Transferring files

The files that you see on your phone’s file manager (Internal storage) are situated in the directory /storage/sdcard0. The data on your external SD card is on /storage/sdcard1. Now to transfer any data to and from the system, use the following commands:

Command to get a file from phone, taking an example of a file named ‘test‘ in the Download folder:

adb pull /storage/sdcard0/Download/test

From this syntax, you can understand how to get into more in-depth directories. Similarly, you can replace sdcard0 with sdcard1 if it is in your external storage.

Now an example for sending files:

To send data to your phone’s system from your computer’s Downloads directory to the Document folder of your phone:

adb push Downloads/test /storage/sdcard0/Document

Configure the basic syntax as you desire.

ADB transferring files
ADB transferring files

Installing/Uninstalling apps

To install an APK file to your phone, make sure APK is in the home directory, and use this simple syntax:

adb install <apk_file_name>

ADB installing
ADB installing

To uninstall, you first need to list all the programs on your phone. To do that, execute the following command:

adb shell pm list packages

ADB packages list
ADB packages list

Names are pretty complicated, so finding the app you want to remove might prove a little tricky, but the name usually stays the same. So try and find it, and when you’re sure that it is correct, execute the following command to uninstall:

adb uninstall --user 0 <app_name>

ADB uninstalling
ADB uninstalling

Logs

To get the logs in real-time, execute this command:

adb logcat

The logs are pretty complex to understand and get a hold of, but we mentioned it nevertheless, for users who would require it.

ADB logs
ADB logs

Creating backups

Creating backups has several options, as mentioned earlier. The general syntax is:

adb backup -f file [options]

Here, the file is the file where the backup will be stored. Other options available can be used this way:

  • Storing APKs
    • Backing up APKs: -apk
    • Not backing up APKs: -noapk
  • Storing application OBB data
    • Storing: -obb
    • Not storing: -noobb
  • Storing data of external storage:
    • Storing data: -shared
    • Not storing: -noshared
  • Backing up all data: -all
  • Whether to or not store APKs of system apps:
    • Storing: -system
    • Not storing: -nosystem

Sample command for backup (storing APKs, storing external storage, not backing up system apps), which will be saved as bckp in the home directory:

adb backup -f bckp -apk -shared -nosystem

Restoring backups

Restoring backups is pretty easy using ADB. This can be accomplished using:

adb restore <backup filename>

Conclusion

ADB is a great utility to work with and provides an enormous amount of flexibility to your phone. All required utilities are made easier to access and execute, all at the comfort of your computer system, no rooting needed, and even wirelessly, if that’s what you want.

Pulkit Chandak
Pulkit Chandak is a Linux enthusiast and has been using and experimenting with open source software and hardware too since a long time. He is a huge admirer of open source software and wants to ventilate it to all around him. He is interested in reviewing and writing tutorials on Linux and its many distributions. He believes that freedom in software leads to freedom of the mind from the chains of limits.

6 COMMENTS

  1. I have a Samsung android pad and I don’t see Developer Options in the settings – is there another name/path for this. I am waiting for more Pine64 development before I buy a linux (or any) modern phone – I live in the woods away from modern world, connected by dsl.

    • The Developer Options are disabled by default on many devices. To enable them, go into the About Device subsection of the settings and try to find ‘Build Number’. When you do, repeatedly tap it and you will soon get a prompt saying ‘You are now a developer’. After that, you will find the developer options in the settings.

  2. To do this properly, you need a file manager on the cell phone that displays the directory structure in Linux command line format. I installed RS File Manager from Google Play Store for this purpose (premium version not necessary). Foss is giving you a generic example above. I wanted to transfer a photo from my Samsung Galaxy J7 Android to my desktop. The correct path turned out to be /storage/E7C8-5994/DCIM/Camera/20200704_09521.jpg. Foss also left something out, which is easy to figure out from context. The adb pull command has two arguments, the first being source and the second being destination. So the full command to transfer my picture was adb pull /storage/E7C8-5994/DCIM/Camera/20200704_09521.jpg /home/rjs/Pictures/Zena.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,420FansLike
377FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

Getting Started with Linux Operating System

The Linux operating system brings forth a vibrant mix of features and security, making it the best alternative to macOS or Windows operating systems. In this post, we will give you a master guide on Getting started with Linux systems - taking you from a complete beginner to a level where you can begin testing the various Linux distributions available with much ease.

How to Create a Comprehensive Mail Server on Ubuntu

Postal is a free and open-source mail server used to send and receive emails. It comes loaded with tons of excellent features and functionalities, making it extremely popular among large organizations as well as in enterprise settings.

The 10 Best Linux Performance Monitoring Tools

Do you want to monitor the performance of your Linux system? Are you looking for some powerful performance monitoring tools to help you out? If you agree, it's your day as we have put together a detailed list of the ten best Linux performance monitoring tools.

How to Boot your Windows or Linux PC from a USB Drive

Sometime back, the process of installing an operating system required users to pop a bootable media disk into their DVD or CD drive and use it to boot the PC. But times have changed. Nowadays, the most common way of installing an OS is booting from a USB drive. The use of USB drives is further propelled by the current production of slim and lightweight laptops with no support for DVD/CD drives.

Python For Loop: Everything You Need to Know

Loops are one of the essential elements in any programming language, and Python is not an exception to it. Loops are used to repeat a statement or a block of statements multiple times. If there were no concept of loops in programming languages, we have to write each statement again and again for the number of times we want to execute it.

How to install LibreOffice on Fedora

If you are looking for a feature-rich and reliable Office Suite for your Fedora PC, then you have an excellent option at hand. LibreOffice, a free and opensource app, has stood the test of time and evolved into a beautiful alternative to Microsoft Office.

MUST READ

Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

Beaker Browser: A P2P web browser you must try

I think we can all agree on the fact that the web browser is an integral part of our Linux systems, or any computer system, for that matter. We have had several fulfilling options for browsing the web, like Firefox, Brave, Vivaldi, Tor, etc. and they have worked pretty well, but also pretty much in the same way, except for Tor, which is much better for anonymity.

Test drive a Linux distro online before you hate it

Enter DistroTest.net, a website that allows Linux users to test various distros online, without downloading the ISO or installing the distro. With DistroTest.net, you can check a distro with no muss, no fuss.

What is the difference between Linux and Unix?

When discussing Linux and Unix with average users, it's not uncommon that they will sometimes mistakenly interchange the terms Linux and Unix.  The two are not the same.  Though they share similarities in their overall structures and toolkits, they are decidedly not the same.

How to clone hard disk on Linux using Clonezilla

Disk cloning refers to the process of copying data from one disk to another, thus creating a one-to-one copy of the drive. Technically, this process is possible using the copy-and-paste method.