Mobile devices based on Android have long ceased to be just phones for calls and have turned into powerful pocket computers with an open architecture. The ability to interact with the operating system at a low level opens up enormous prospects for the user to fine-tune the interface, remote control and automate routine tasks. Executing commands is a fundamental way to make the device do exactly what you need, and not what is built into the shell by default by the manufacturer.

There are several levels of access to the command command line: from simple USSD codes available to every smartphone owner to complex scripts entered via a computer using a debug bridge Android Debug Bridge. Understanding how to correctly form and send a request to the system allows you to solve problems with freezes, hidden network settings or removing system garbage that cannot be removed using standard means.

In this article we will analyze in detail all known input methods (commands), the necessary tools and precautions. Any intervention in system files through ADB Shell with root access can lead to a complete loss of warranty and the inability to boot the system (bootloop). Be careful when copying syntax, as even one extra letter can change the meaning operations.

Use of engineering codes and USSD requests

The easiest and safest way to execute a command on Android is to use built-in codes that processed directly by the modem or the “Phone” system application. These character sequences begin with an asterisk or hash and end with a challenge character. They do not require an Internet connection or installation of additional software.

However, it is worth considering that smartphone manufacturers often modify the standard set of codes Google, adding their own or blocking access to critical functions. For example, on devices Samsung codes may differ from those that work on pure Android smartphones Pixel or Xiaomi.

⚠️ Attention: Some codes, such as factory resets or hardware tests, are performed instantly and without additional confirmation. Make sure you enter the correct code to avoid accidental data loss.

Below is a table of the most useful and common commands that can be executed through dialing:

Command Function Risk of data loss
*#06# Display device IMEI No
##4636## Test menu (information about battery, Wi-Fi, usage) No
#0# Engineering menu for testing display and sensor (Samsung) No
##7780## Resetting application and account settings (Factory Reset without media) High
##4636## Alternative entry to the information menu (does not work on all models) No

To perform these actions you do not need special superuser rights. Just open the Phone app, enter a sequence, and the action will be performed automatically or a hidden menu will open. This is the basic level of interaction with hardware smartphone.

📊 Do you use Android hidden codes?
Yes, all the time
Sometimes, to check IMEI
Never tried it
I'm afraid to break something

Terminal emulators directly on the device

For those who lack the functionality of standard codes, there are terminal emulator applications. They allow you to run shell commands Linux (bash, sh) directly on your smartphone. Popular applications such as Termux or Terminal Emulator for Androidturn your phone into a full-fledged console.

It is important to understand the difference between normal operating mode and superuser mode. Without rights root you are limited to the rights of the current application user and will not be able to change system files or settings of other apps. However, to work with files in your own folder, run scripts on Python or Perl, as well as for network utilities (ping, curl, ssh), this is quite enough.

💡

The Termux application requires separate installation of packages via the pkg install command. Do not try to use apt-get commands without first setting up the repositories, as Termux has its own package structure.

To get started, install the emulator from Google Play or F-Droid. Once launched, you will see a command prompt. Enter commands, for example, to check communication: ping google.com. If you want to see a list of processes, use ps. To navigate the file system, standard commands are used cd, ls, mkdir.

If your device has root access, you can run the command suin the terminal to gain full access. This allows you to edit the file /etc/hosts, change the processor frequency or remove uninstallable applications. However, remember that with great power comes great responsibility: an error in the command syntax rm -rf can destroy your personal data beyond recovery.

Connecting via ADB from a computer

The most powerful tool in the arsenal of an advanced user is Android Debug Bridge (ADB). It is a client-server app that allows a computer to communicate with an Android device. ADB is part of the package Android SDK Platform-Toolswhich can be downloaded from the official website of the developers.

To get started, you need to activate developer mode on your smartphone. Go to Settings → About phone and quickly click 7 times on the “Build number” item. After this, a new section “For Developers” will appear in the settings menu. In it you need to enable the “USB Debugging” item.

☑️ Preparing to work with ADB

Done: 0 / 5

After connecting the cable, open the command line (CMD or Terminal) on computer in the folder with ADB. Enter the command:

adb devices

A request for permission to debug from this computer will appear on the smartphone screen. Click "Always Allow" and "OK". If the list displays the serial number of the device with status device, it means the connection is established. Now you can execute commands that manage the file system, install applications (adb install), take screenshots (adb shell screencap) or broadcast the screen to a monitor.

⚠️ Attention: USB port interfaces and drivers may differ depending on the computer operating system (Windows, macOS, Linux). On Windows, manual installation of drivers for a specific vendor is often required.

Working with Shell and system files

Command adb shell opens a remote command line session on the device itself. While in this environment, you can perform the same actions as in the terminal emulator, but from the PC keyboard, which is much more convenient for entering long scripts. Utilities for managing processes, network and files are available here.

One ​​of the most useful features of ADB Shell is the ability to hide or remove system applications without obtaining root access, using the command pm uninstall --user 0 . This allows you to clean the system from bloatware (junk software), which manufacturers often preinstall. To find the package name, you can use the command pm list packages with a filter.

You can also manage application permissions through the shell. For example, you can force or deny access to the microphone, camera, or geolocation for any application, even if there is no such option in the standard settings menu. The command looks something like this: pm grant com.example.app android.permission.CAMERA.

List of dangerous commands that should be avoided

The 'rm -rf /' command will delete all files in the root directory, which will lead to system inoperability. The 'wipe data' command will initiate a full reset. Always double-check paths and arguments before pressing Enter.

To change system settings that are hidden in the database settings.db, use the commands settings get and settings put. This allows you, for example, to change the screen auto-lock time, brightness or behavior of notifications at a deep level.

Task automation and scripts

Executing single commands is useful, but the real power of Android is revealed through automation. Scenarios allow you to launch chains of actions based on a schedule or event. For this, specialized automation applications are used, such as Tasker, MacroDroid or Automate.

These apps can emulate keystrokes, launch applications, send SMS, change system settings and, most importantly, execute shell commands. For example, you can create a scenario: “When I connect to my home Wi-Fi, turn on GPS, set the brightness to 100% and launch the Smart Home application.”

  • 🚀 Tasker - the most powerful tool with a huge number of plugins, but difficult for beginners to master.
  • 🐰 MacroDroid - a more friendly interface with the “Trigger → Action” logic, ideal for start.
  • ⚙️ Automate —uses visual programming in the form of flowcharts, which is convenient for visual learners.

Executing commands inside these applications often requires granting special permissions via ADB. For example, for MacroDroid you need to run the command: adb shell pm grant com.macrodroid.android.macrofree com.macrodroid.android.deviceid. This gives the application the right to control system functions without root access.

Common errors and problem solving

When working with the command line, users often encounter syntax errors or connection problems. The most common error is “command not found”. This means that the system does not know such a command, or it is not included in the standard set, or you are in the wrong directory.

If ADB does not see the device, check the cable. Cheap cables are often for charging only and have no data lines. Try a different USB port or cable. Also make sure that the latest drivers are installed on your computer.

⚠️ Attention: Android versions are constantly updated, and some commands may stop working or change syntax in new versions of the OS. Always check the documentation for your version of Android.

Another problem is (permissions). If the command requires root access and you do not have them, the system will display a “Permission denied” error. In this case, either get root access or look for alternative methods of solving the problem through standard APIs or ADB Shell without privileges.

💡

The main key to success is attention to detail. One misspelled letter in the command line can lead to unpredictable results, so always check the syntax before executing.

FAQ: Frequently Asked Questions

Is it safe to execute commands through ADB for a normal user?

Yes, if you follow proven instructions. Commands like adb shell screencap or adb pull are safe. Commands that modify system partitions or delete files are dangerous. Always make a backup copy of your data before experimenting.

Do you need Root to run commands in Termux?

No, Termux runs in an isolated environment without root access. You can install packages, compile code, and work with files inside your directory. Root is only needed to access system files outside the application folder.

How to find the application package name for the uninstall command?

Use the command adb shell pm list packages to list all packages. You can add a filter, for example adb shell pm list packages | grep facebookto find the application you need.

Is it possible to execute a command on a locked screen?

Through standard means - no. However, if USB debugging is enabled and the computer is already authorized, some ADB commands can be executed even when the screen is locked, but with security restrictions.

Where to download the official Platform-Tools?

You should download tools only from the official Android developer website (Android SDK Platform-Tools section). The use of third-party assemblies may carry security risks.