Android Terminal Emulator commands for Android. Android terminal commands

Users who use Android smartphones or tablet computers not only for making calls, watching videos, and so on, but also use all the capabilities of this operating system a little more deeply, I think they have heard about such a thing as a terminal, and that some commands are executed exclusively in it. In this material we will describe what each of the available commands actually does.

Let us immediately make a reservation that for users of the Linux operating system these commands are already familiar. First, let's launch the terminal itself. Naturally, you first need to download and install it on your Android device.

We see the following on the screen:

Device_name:/$

Device_name – this is the name of your Android device.

This command gives Root rights, that is, it allows you to perform any actions, of course, you first need to get Root access for the device. Until this command is executed, you are limited to guest rights and access.

Device_name:/$

The “$” symbol means that at the moment you only have guest rights, that is, you can do little.

Device_name:/#

The “#” symbol means that you currently have Root rights.

You can see in the terminal, for example, the following natural sequence after entering the command S.U.:

Device_name:/$su

Device_name:/ #

A command that moves to any folder (directory), for example:

Device_name:/ # cd dir1

Device_name:/dir1 #

Note, " CD..» moves to a directory one level higher.

This command lists the contents (files and directories) of the current directory, for example:

Device_name:/ # ls

bin

Note, " LS-A» displays a complete list of the contents of the current directory, including hidden files. Unlike Windows, hidden files have the form dot-Name, for example . name

Displays the text that is in the file, for example:

Stroka2

Displays the text that is in the file, but in reverse order, that is, the last line first, the first at the end. For example:

Device_name:/sdcard # cat test

This command creates a directory (folder), for example like this:

Device_name:/sdcard # mkdirtestdir1

It is important that in Linux-like systems, which includes the Android operating system, the case in the names of files and folders matters, so testdir1 And Testdir1– different directories.

A command that deletes the specified file.

R.M.R

The command that deletes the specified folder. For example:

Device_name:/sdcard # rm -r dir1

Performs a file copy.

CP-R

Copies a directory.

Renames the specified file. Example:

Device_name:/sdcard # mv filetest FileTest

Shows the full path to the current directory on the screen.

A command that creates an empty file. For example:

Device_name:/sdcard # touch file1

Device_name:/sdcard #wget http://video.mkv

Displays the current date and time.

Displays the calendar for the current month on the screen.

Note – if you enter, for example, “ CAL 2012", then the calendar table for 2012 will be displayed on the screen.

Displays current processes on the screen.

Mount the specified path.

Dismantle the specified path.

The command performs a quick and correct complete shutdown of the system.

FREE –M

Displays the current state of RAM on the screen (in megabytes).

Displays the current storage usage on the screen.

Clears all output characters from the terminal screen.

Displays how much storage space the user's data takes up.

Displays the amount of time the operating system has been running since the previous startup.

Sets access rights to the listed files, for example:

Setting permissions on the listed files

chmod 777 file1 file2 file3

For group (g = group) and for others (o = others) add read flag (r)

chmod go+r /home/user2/folder1/filexxx.txt

For group (g = group) and for others (o = others) remove the read flag (r)

chmod go-r /home/user2/folder1/filexxx.txt

Now let's look at the permission or access rights that we just assigned to the files. They are divided into two groups: file access rights and directory access rights. As for file access rights, they can have the following attributes:

r - (read) right to read data from the file.

w - (write) the right to write or change data (not delete!).

x - the right to execute the file.

Directory access rights can have the following attributes:

r - right to read the directory.

w - the right to change the contents of the folder, that is, you can delete and create objects in this directory.

x - the right to enter the directory.

Access rights are divided into three broad categories:

u - “user”, or owner of the file.

g - "group". A member of the same user group as the owner of the object.

o - “world”, or all the others.

Permissions are written in the following order: permissions for the owner (“u”) first, then for the group (“g”), and finally for everyone else (“o”). Rights are written in the form RWX, and if there is a “-” in place of any of the letters, this means that there is no right to act.

For example, the following set of attributes:

means that the owner of the object has absolutely all rights, that is, read, write and execute, and the remaining categories have only the right to read the file.

Also, in addition to the literal expression of rights, a numeric expression is possible, where:

"r" is 4

"w" is 2

"x" is 1

"-" is 0

The sum of these numerical values ​​expresses rights, that is:

7 (rwx) = 4 + 2 +1 (full rights)

5 (r-x) = 4 + 0 + 1 (read and execute)

6 (rw-) = 4 + 2 + 0 (read and write)

4 (r-) = 4 + 0 + 0 (read only)

Sometimes rights are expressed not from three, but from four digits - this means that in addition to the owner, group and others, there is Superuser, that is, the main administrator. The numerical value responsible for its rights is in first place.

What interesting commands are there for the terminal emulator?

Answers (2)

  1. Terminal emulator is an application for Android through which you can use commands to control the system and make changes to it. This mechanism is based on the fact that the Android system includes the Linux kernel.

    On the computer, using the command line and utilities, you configure the system and connect additional modules. Android has inherited many similar features that can be used for various purposes.

    That is, there are binary files that interact directly with the hardware. Each such file corresponds to a text command that is launched through a terminal emulator.

    Before you start working with the command line, it should be noted that the greatest scope for modifications will be after rooting the Android device.

    In addition, you should install busybox - a binary file that will allow you to use more commands, since the built-in ones are often not enough. To install it you need:

    • download BusyBox from Play Market;
    • open and grant him superuser rights;
    • be sure to wait until the application scans the device;
    • click the “install busybox” button;
    • define the location “/system/xbin”;
    • press "ok".

    After this, you can start installing the terminal on Android and working with it. For this:

    Other commands may take a long time to complete and a white cursor will appear. If an error was made when writing, the message “/system/bin/sh: kv: not found” and a prompt for input will appear. This message indicates that the kv command was not found among those available.

    Close the terminal by clicking on the cross in the upper right corner, then a window will appear in which we click “ok”.

  2. There are a lot of commands, to see them all you need to write “busybox” without quotes. In principle, the description of each can be viewed in the terminal itself; to do this, you need to enter the command that you want to learn about and “—help”. Information will appear, but in English. When working with the terminal, you need to take into account some features:

    • the path to files and folders must be written completely after the commands, for example, rm /storage/sdcard0/download/file;
      there should be no errors or extra spaces;
    • The command is launched by pressing the “enter” button, that is, entered and pressed.

    Here are the most popular android terminal commands:

    • cat - reading contents, cp - copying, rm - deleting a file, rmdir - deleting a folder, touch - creating a file, mkdir - creating a folder, - after these commands, enter the path to the desired object or location;
    • mv - move, cp - copy, - first write the path to the file or folder, then to the new location;
    • ls - displays the contents;
    • cd - navigates to the desired directory;
    • pwd - shows the full path to the folder being used;
    • date - displays the real date;
    • df - shows the size of objects in the specified folder;
    • du - prints the file size;
      pm install - installs the program from an apk file;
    • pm list packages - shows package files of installed applications;
    • service list - displays a list of running processes;
    • pm uninstall - uninstalls the application, and you must specify the path /data/app/file name, which can be found with the pm list packages command;
    • ln - creates a symbolic link to a file, the syntax is the same as cp.

    You need to be very careful when executing terminal emulator commands, which I will discuss later, since they are used to modify the system and, if used incorrectly, can seriously damage the device:

    • su - provides full access to the system on rooted devices, after entering it the prompt line will look like this “root@android:/ #”;
    • chown and chgrp, the first to change the owner, the second - groups that are specified after the command and then write the file name;
    • chmod - a utility for changing file permissions, the syntax is the same as the previous one - first the rights, then the file;
    • insmod and rmmod use the first to connect modules to the kernel, the second to remove them; these commands are best used only by advanced users;
    • kill - stops a process by its identifier, which can be found using the ps utility - it displays information about all activities;
    • mount, umount are intended for mounting and unmounting file systems and partitions; use only after a detailed study of the system.

    Special commands that are executed by the Android terminal emulator:

    • reboot - used after the su command to reboot the device;
    • exit - closes the terminal, you can also log out of the administrator through it.

    That is, we used su for utilities that require root rights, and then, so as not to accidentally change something, we enter exit, and the prompt will again become “u0_a106@android:/$”.

    There is another unusual utility called dd - it copies one file or section to another byte by byte. Its syntax is:

    dd if=/dev/block/platform/mmcblk0p1 of=/storage/external_SD/image
    if= device from which we are copying of= file to which we are copying. This command will create an image of the mmcblk0p1 partition.
    It has 2 more parameters - count= fragment, which will be used to write a new file, bs= volume of fragments in bytes. For example, the command dd if=/storage/sdcard0/file1 of=/storage/external_SD/file2 bs=500 count=7 will copy 7 pieces of 500 bytes from file1 to file2.

These commands are relevant for all operating systems built on Linux (Unix), including Android. To use the following commands on Android OS, you need to get Root rights, install terminal emulator and application busybox(This application contains all the commands below). To display a list of all supported busybox"om commands, you need to type the command in the terminal emulator busybox.

This article lists the commands busybox in the Android system, divided into categories. At the end, the features of working with the command line and terminal emulators in Linux are given. More detailed information about commands will be collected in the article BusyBox Commands in Android.

Getting help about commands

man
Description of the command or configuration file. Synonym for info. The description is scrolled with arrows, exit with the q key.
Example: man fstab
apropos
Search man descriptions.
Example: apropos iso

BusyBox commands for working with files and folders

CD Change the current folder. Example: cd ~ or simply CD always goes to the current user's home directory. cd /etc- go to the /etc folder
cp Copying files and directories from one to other directories ls Lists files and folders in the order specified by the options. Unlike dir Highlights files by type. With parameter -l displays additional information about files: rights, owner, creation date, etc. ls Without parameters, displays the contents of the current folder. ls /proc Lists all running processes (see Virtual folder /proc in Android). mv Move or rename files. If the names of two files are given as arguments, then the name of the first file will be changed to the name of the second. Example: mv file1 file_1- renames the file
If the last argument is the name of an existing directory, then mv moves all specified files to that directory.
Example: mv file ./dir/- moves "file" to "dir/file" relative to the current directory rm Deleting a file. With the -R switch, deletes in subdirectories. Example: rm -R ~/killme mkdir Creating a directory. pwd Displays the current path rmdir Removing an empty directory. touch Creating an empty file. Example: touch /home/primer - creates an empty file /home/primer

BusyBox commands for working with access rights to files and folders

chown Change of owner. chgrp Change owner group. chmod Change of rights. Example: chmod -R 777 /var/www gives everyone access to all files and directories below /var/www.

BusyBox Commands for Viewing Files

cat File output. Example: cat /etc/fstab. tail End of file output. Convenient when working with logs and large files. Example: tail /var/log/messages.

Utilities for working with archives

Utilities for processing file contents

awk, ed (text editor), patch, sed, vi (text editor).

Editing files

nano And pico- the most sane editors that work in text mode directly in the terminal. To change the /etc/fstab file, for example, you need to type nano /etc/fstab. Exit the editor CTRL+X. Editors vi And vim designed to work with the blind ten-finger method.

Commands for mounting and unmounting disks

mount[parameters] device path Mount the device. Example: mount /dev/sda1 /mnt/Disk1. umount device/path Unmount. Example: umount /mnt/Disk1. eject Unmount and eject CDROM.

BusyBox commands for working with the kernel and kernel modules (device drivers)

lsmod Shows a list of all modules loaded into the kernel and the dependencies between them. insmod rmmod modprobe module-name [parameters] Installing the module, configuring its autoload. The result can be viewed in the system log. Modules are stored in /lib/modules in files with the extension .ko (“kernel object”) Example: modprobe radio-aztech io=0x350. modinfo module-name Information about the module, including a list of parameters. modconf A convenient program for viewing all modules by category, enabling and disabling modules. It is usually not installed by default; in Debian, Ubuntu and Kubuntu it is installed using the package of the same name with the command apt-get install modconf.

BusyBox commands for managing processes:

ps– displays information about currently active processes.
top– displays information about active processes, as well as system resources.
kill pid– kills the process whose id is equal to the specified processed value.
killall process– kills all active processes with the name process.
bg– displays a list of stopped and background tasks; continues execution of a stopped task in the background.
fg– Brings the latest active tasks to the forefront.
fg n– brings the task with the specified name (in this case, n) to the foreground.

BusyBox commands for working with date and time:

adjtimex- allows you to change time variables in the kernel in order to correct the speed of the system clock

date- setting the system clock

hwclock- setting the hardware clock

Utilities for working with system accounts

adduser, addgroup, deluser, delgroup, login, passwd, su

Network commands

arp, arping, dnsd, ftpget, ftpput, httpd (with authorization support, CGI), ifconfig, inetd, netstat, nslookup, ping/ping6, route, telnetd, tftp, traceroute, udhcpd, wget.

ifconfig- setting up the network interface wget- downloading a file via HTTP/FTP.

Other Useful Linux Console Programs and Commands

hdparm Manage hard drives and CD drives. Example: hdparm -E8 /dev/cdrom reducing CDROM rotation speed. watch Periodic execution of a command. Example: watch -n 60 hdparm -E8 /dev/cdrom slow down the disk once a minute so that the drive does not overclock it and does not make noise while watching a DVD. pppconfig A simple and reliable program for setting up Dial-Up Internet access via a modem. pon, poff and plog are commands for establishing, breaking and viewing the connection log, respectively. pppoeconf Similarly, setting up Internet access via an ADSL modem. whoami Allows you to find out your username if you forgot iftop command to view network connections from console netstat The command displays the contents of various network-related data structures in different formats depending on the options specified. iwconfig displaying information about wi-fi network interfaces iwlist scan displaying information about access points within range free free memory

Superuser root

Has unlimited rights. Using superuser rights is necessary when installing drivers and changing important Linux settings. The root user password is usually requested when installing the distribution. Then immediately after installation you can log in to the system with the specified password and login root.

If you are logged in as a regular user, you can obtain superuser rights in a specific terminal instance with the command su, after entering which you must enter the superuser password. You can return to the regular user session with the command exit.

However, distributions such as Ubuntu and Kubuntu do not create a superuser during installation. You will not be able to log in as root or use su. Superuser rights in these distributions can be obtained with the command sudo. It must be written before each command that requires superuser rights. For example sudo nano /etc/fstab. After the first sudo command, you must enter a password current user. Users who are members of the sudo or admin group (depending on the Linux distribution) can use sudo, which is done automatically for the first user of Ubuntu and Kubuntu when installing the distribution.

Features of Linux terminals

The commands written to the file are executed by the command sh filename.

Standard commands in Linux are different from DOS and Windows commands - they are usually shorter. When working with the command line as usual, a blinking cursor indicates the text entry position, the command line begins with the current path and computer name, followed by a $, %, or # symbol. The latter means that the commands will be executed as the root superuser. The ~ symbol indicates the path to the user's current home directory.

Most Linux commands that do not require any output to the user do not output anything to the screen if they complete successfully. Only errors and warnings are output if the command does not run normally. Those. In Linux, the general principle is “silent means it works.”

In any Linux terminal, using the up/down arrows on the keyboard, you can scroll through the command history, which is saved between work sessions and differs for different users and hosts (in the case of connecting from the command line to another computer via ssh). A partially typed command or file or directory name in the current directory can be automatically appended with the TAB key. If more than one option is found and it is impossible to clearly continue the command via TAB, then all suitable options are displayed.

When working in a graphical environment, terminal emulators are convenient. As a rule, they support bookmarks - several terminals in one window, support color schemes. The most common terminal emulators are Gnome Terminal, Konsole, XFCE Terminal.

Almost every user who is at least a little versed in modern technology knows that the Android mobile operating system is based on Linux. And if we talk about Linux, then you can get full access to the system only through the command line. Android, among other features, also has support for a command prompt, which can also be called a terminal. However, almost all device manufacturers do not install such utilities on their devices, since an inexperienced user can make irreversible changes that will affect the performance of the smartphone or tablet.

Option 1 - Installing the application on Android

The easiest way to access the command line is to install a special application. There are plenty of similar programs in the official Play Store. Just enter the words or in the search. Almost any of the applications found will allow you to use the command line. It’s worth taking into account that to access the system partition you will have to first obtain Root rights.

Option 2 - Using a computer with ADB

You can also use a personal computer, but you will have to perform a number of simple steps. Install the appropriate driver for your gadget in advance. After this, you will need to enable USB debugging. The last step is to install

Terminal commands are relevant for all operating systems based on Linux (Unix), including Android.
To use the following commands on Android OS, you need to getRoot rights, install terminal emulator and application busybox(This application contains all the commands below).
To display a list of all supportedbusybox"om commands, you need to type the command in the terminal emulatorbusybox. This is the shell.

Getting help about commands

man
Description of the command or configuration file. Synonym for info. The description is scrolled with arrows, exit with the q key.
Example: man fstab
apropos
Search man descriptions.
Example: apropos iso

Working with files and folders

CD Change the current folder. Example: cd ~ or simply CD always goes to the current user's home directory. cd /etc- go to the /etc folder
cp Copying files and directories from one directory to another ls Lists files and directories in the order specified by the options. Unlike dir Highlights files by type. With parameter -l displays additional information about files: rights, owner, creation date, etc. ls Without parameters, displays the contents of the current folder. ls /proc displays all running processes mv Move or rename files. If the names of two files are given as arguments, then the name of the first file will be changed to the name of the second. Example: mv file1 file_1- renames the file
If the last argument is the name of an existing directory, then mv moves all specified files to that directory.
Example: mv file ./dir/- moves "file" to "dir/file" relative to the current directory rm Deleting a file. With the -R switch, deletes in subdirectories. Example: rm -R ~/killme mkdir Creating a directory. pwd Displays the current path rmdir Removing an empty directory. touch Creating an empty file. Example: touch /home/primer - creates an empty file /home/primer

File and folder permissions

chown Change of owner. chgrp Change owner group. chmod Change of rights. Example: chmod -R 777 /var/www gives everyone access to all files and directories below /var/www.

View files

cat File output. Example: cat /etc/fstab. tail End of file output. Convenient when working with logs and large files. Example: tail /var/log/messages.

Utilities for working with archives

ar, bzip2, dpkg, gzip, rpm, tar, zip

Utilities for processing file contents

awk, ed (text editor), patch, sed, vi (text editor).

Editing files

nano And pico- the most sane editors that work in text mode directly in the terminal. To change the /etc/fstab file, for example, you need to type nano /etc/fstab. Exit the editor CTRL+X. Editors vi And vim designed to work with the blind ten-finger method.

Commands for mounting and unmounting disks

mount[parameters] device path Mount the device. Example: mount /dev/sda1 /mnt/Disk1. umount device/path Unmount. Example: umount /mnt/Disk1. eject Unmount and eject CDROM.

Working with the kernel and kernel modules (device drivers)

lsmod Shows a list of all modules loaded into the kernel and the dependencies between them. insmod rmmod modprobe module-name [parameters] Installing the module, configuring its autoload. The result can be viewed in the system log. Modules are stored in /lib/modules in files with the extension .ko (“kernel object”) Example: modprobe radio-aztech io=0x350. modconf modinfo module-name Information about the module, including a list of parameters. apt-get install modconf.

A convenient program for viewing all modules by category, enabling and disabling modules. It is usually not installed by default; in Debian, Ubuntu and Kubuntu it is installed using the package of the same name with the command

ps– displays information about currently active processes.
top– displays information about active processes, as well as system resources.
kill pid– kills the process whose id is equal to the specified processed value.
killall process– kills all active processes with the name process.
bg– displays a list of stopped and background tasks; continues execution of a stopped task in the background.
fg– Brings the latest active tasks to the forefront.
fg n– brings the task with the specified name (in this case, n) to the foreground.

Process management:

Working with date and time:

date- setting the system clock

adjtimex - allows you to change time variables in the kernel to correct the speed of the system clock

Utilities for working with system accounts

adduser, addgroup, deluser, delgroup, login, passwd, su

Network commands

arp, arping, dnsd, ftpget, ftpput, httpd (with authorization support, CGI), ifconfig, inetd, netstat, nslookup, ping/ping6, route, telnetd, tftp, traceroute, udhcpd, wget.

ifconfig Hwclock - setting the hardware clock wget- downloading a file via HTTP/FTP.

Other Useful Linux Console Programs and Commands

hdparm- setting up the network interface hdparm -E8 /dev/cdrom Managing hard drives and CD drives. Example: watch reducing CDROM rotation speed. watch -n 60 hdparm -E8 /dev/cdrom slow down the disk once a minute so that the drive does not overclock it and does not make noise while watching a DVD. pppconfig A simple and reliable program for setting up Dial-Up Internet access via a modem. pon, poff and plog are commands for establishing, breaking and viewing the connection log, respectively. pppoeconf Similarly, setting up Internet access via an ADSL modem. whoami Allows you to find out your username if you forgot iftop command to view network connections from console netstat The command displays the contents of various network-related data structures in different formats depending on the options specified. iwconfig displaying information about wi-fi network interfaces iwlist scan displaying information about access points within range free free memory

Superuser root

Has unlimited rights. Using superuser rights is necessary when installing drivers and changing important Linux settings. The root user password is usually requested when installing the distribution. Then immediately after installation you can log in to the system with the specified password and login root.

If you are logged in as a regular user, you can obtain superuser rights in a specific terminal instance with the command su, after entering which you must enter the superuser password. You can return to the regular user session with the command exit.

However, distributions like Ubuntu do not create a superuser during installation. You will not be able to log in as root or use su. Superuser rights in these distributions can be obtained with the command sudo. It must be written before each command that requires superuser rights. For example sudo nano /etc/fstab. After the first sudo command, you must enter a password current user. Users who are members of the sudo or admin group (depending on the Linux distribution) can use sudo, which is done automatically for the first Ubuntu user when installing the distribution.

Features of Linux terminals

The commands written to the file are executed by the command sh filename.

Standard commands in Linux are different from DOS and Windows commands - they are usually shorter. When working with the command line as usual, a blinking cursor indicates the text entry position, the command line begins with the current path and computer name, followed by a $, %, or # symbol. The latter means that the commands will be executed as the root superuser. The ~ symbol indicates the path to the user's current home directory.

Most Linux commands that do not require any output to the user do not output anything to the screen if they complete successfully. Only errors and warnings are output if the command does not run normally. Those. In Linux, the general principle is “silent means it works.”

In any Linux terminal, using the up/down arrows on the keyboard, you can scroll through the command history, which is saved between work sessions and differs for different users and hosts (in the case of connecting from the command line to another computer via ssh). A partially typed command or file or directory name in the current directory can be automatically appended with the TAB key. If more than one option is found and it is impossible to clearly continue the command via TAB, then all suitable options are displayed.

When working in a graphical environment, terminal emulators are convenient. As a rule, they support bookmarks - several terminals in one window, support color schemes.

Shell Scripting

A sequence of commands can be formatted as an executable file. This is a script.

The first line of the script describes the standard variable path