[REF][DEV]Terminal Emulator Commands

Search This thread

hetunandu

Senior Member
May 8, 2011
322
226
Always wondered what the terminal emulator app does? Dont now what commands to type? Well this thread is all about that :)



ALERT!!! ALERT!!
BELOW ARE THE COMMANDS AND THE PROCESSES THAT WILL HAPPEN BY TYPING THE COMMANDS!!!

IF YOU DO NOT UNDERSTAND SOMETHING PLEASE SO NOT TRY IT.. IT IS RISKY AND WILL POTENTIALLY HARM YOUR DEVICE!!

DO NOT BLAME ME THEN!!

THIS IS A REFERENCE AND DEV THREAD. NOOBS SHOULD NOT LINGER AROUND HERE



The Android Shell
A "shell" is a program that listens to keyboard input from a user and performs actions as directed by the user. Android devices come with a simple shell program. This shell program is mostly undocumented. Since many people are curious about it I thought I'd write up some documentation for it.

Currently this documentation is incomplete, sorry!

Common problems
The built-in shell has very limited error handling. When you type a command name incorrectly it will say "permission denied", even though the real problem is that it couldn't find the command:

Code:
$ dir
dir: permission denied  <---- this is a misleading error message, should say 'dir: not found'
$ ls
... listing of current directory

The PATH variable

The Android shell will run any program it finds in its PATH. The PATH is a list of directories. You can find out what your shell's PATH is set to by using the built-in echo command:

Code:
$ echo $PATH
/data/local/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
Depending upon your shell, you may see a different result.

Built in Commands
Every shell has a few built-in commands. Some common built-in commands are:

  • echo -- prints text to stdout.
  • set -- sets shell variables
  • export -- makes shell variables available to command-line programs
  • cd -- change the current directory.
  • pwd -- print name of the current directory.

Commands

To find out what commands you have available to you, use the "ls" command on each of the directories in the PATH variable.

Finding documentation for the Android commands.

Many of the Android commands are based on standard Linux (or bsd) commands. If you're curious about a command, you can sometimes learn how it works by using the "man" command on a desktop Linux or OSX (Apple Macintosh) computer. The Linux or OSX version of the command may be different in details, but much of the documentation will still apply to the Android version of the command.

Another source of documentation for people without a Linux or OSX machine handy is to use a web browser and use a web search engine to search for the text: "man Linux command-name".

List of commands

The following is a list of the commands that are present on a Nexus S phone running an Android 2.3.3 "user-debug" build. Many of these commands are not present on a "user" phone. (They are missing from a "user" phone because they are specific to developing or debugging the Android operating system.)

Code:
$ ls /data/local/bin
/data/local/bin: No such file or directory

Notice that by default there is no /data/local/bin directory. You can create this directory using the "mkdir" command if you like.

Code:
$ ls /sbin
opendir failed, Permission denied

The /sbin directory exists, but you don't have permission to access it. You need root access. If you have a developer phone, or otherwise have root access to your phone you can see what's in this directory.

Code:
$ su
# ls /sbin
ueventd
adbd
# exit
$

Notice that the shell prompt changes from a '$' to a '#' to indicate that you have root access.

Notice also that neither of the /sbin commands are useful to the shell -- the adb and ueventd files are 'daemon' programs used to implement the Android Debugger "adb" program that is used by developers.

Code:
$ ls /vendor/bin
gpsd
pvrsrvinit

Vendor/bin is where device vendors can put device-specific executables. These files are from a Nexus S.

Code:
$ ls /system/sbin
/system/sbin: No such file or directory
This directory does not exist on a Nexus S.

Code:
$ ls /system/bin
am
am is the Android Activity Manager. It's used to start and stop Android activities (e.g. applications) from the command line. Type am by itself to get a list of options.

Code:
amix
aplay
Command line audio file player.

Code:
app_process
applypatch
Used to apply patches to android files.

Code:
arec
Command line audio recorder.

Code:
audioloop
bluetoothd
BlueTooth daemon

Code:
bmgr
Backup manager - type command by itself to get documentation.

Code:
bootanimation
Draws the boot animation. You may have to reset your phone to get out of this.

Code:
brcm_patchram_plus
bugreport
cat
Copy the contents of a file to standard output.

Code:
chmod
Change the mode of a file (e.g. whether it can be read or written.)

Code:
chown
Change the owner of a file.

Code:
cmp
Compare two files byte-by-byte

Code:
dalvikvm
The dalvik virtual machine. (Used to run Android applications.)

Code:
date
Prints the current date and time

Code:
dbus-daemon
dd
Convert and copy a file. By default copies standard in to standard out.

Code:
debuggerd
dexopt
df
Shows how much space is free on different file systems on your device.

Code:
dhcpcd
dmesg
dnsmasq
dumpstate
dumpsys
dvz
fsck_msdos
gdbserver
getevent
getprop
gzip
hciattach
hd
id
ifconfig
iftop
ime
input
insmod
installd
ioctl
ionice
iptables
keystore
keystore_cli
kill
Send signals to processes.

Code:
linker
ln
Used to set up a file system link.

Code:
log
logcat
Prints the Android runtime log.

Code:
logwrapper
ls
Lists files.

Code:
lsmod
lsof
make_ext4fs
mediaserver
mkdir
Make a directory.

Code:
monkey
A program that sends random events, used to test applications. (Like having a monkey playing with the device.)

Code:
mount
mtpd
mv
Move a file from one directory to another. (Only on the same file system. Use "cat a > b" to copy a file between file systems.

Code:
nandread
ndc
netcfg
netd
netstat
newfs_msdos
notify
omx_tests
pand
ping
pm
pppd
printenv
ps
List active processes.

Code:
qemu-props
qemud
racoon
radiooptions
reboot
Reboot the device.

Code:
record
renice
rild
rm
Remove a file.

Code:
rmdir
Remove a directory.

Code:
rmmod
route
rtp_test
run-as
schedtest
schedtop
sdcard
sdptool
sendevent
service
servicemanager
setconsole
setprop
setup_fs
sh
showlease
sleep
smd
stagefright
start
Starts the Android runtime.

Code:
stop
Stops the Android runtime.

Code:
surfaceflinger
svc
sync
system_server
tc
testid3
toolbox
top
Shows which processes are currently using the most CPU time.

Code:
umount
uptime
Prints how long your device has been running since it was last booted.

Code:
vdc
vmstat
vold
watchprops
wipe
wpa_cli
wpa_supplicant

$ ls /system/xbin
add-property-tag
btool
check-lost+found
dexdump
dhdutil
hcidump
latencytop
librank
opcontrol
oprofiled
procmem
procrank
rawbu
scp
Secure copy program. (Used to copy files over the network.)

Code:
showmap
showslab
sqlite3
Used to administer SQLite databases.

Code:
strace
System trace command - use to see what system calls a program makes.

Code:
su
Start a shell with root privileges.

Versions of the Android Shell
Android 1.0 used a shell that had no tab completion or history editing.
Android 2.3 added history editing. You can for example use the up/down arrows to edit previous commands.

Other shells
Busybox
Busybox is a program that contains a shell and a set of command line utilities. Search Android Market for "Busybox" and you should find some versions you can install. The Busybox shell includes tab completion and history editing. Some versions of Busybox for Android do not require that you root your phone.

Debian utilities
You can install the full Debian shell and utilities. (Debian is a popular desktop Linux distribution.) I don't know the details, and it may require a "rooted" phone. Try a web search for "Debian Android install".

Custom ROMs
Some custom ROMs come with their own shells and utilities. If you are using a custom ROM, check its documentation to find out what's available.
 
Last edited:

scandiun

Senior Member
Jul 12, 2010
1,903
983
How can I view stdout outputs in terminal emulator window?
For example with dd command, not specifying output should display it at current terminal, like in linux, but actually doesn't. Any ideas?
 

SpyderX

Senior Member
Mar 5, 2011
933
932
Singapore
Great guide!

IMO dmesg is also important. Maybe you should add in a description for it?

Dmesg --> prints the Linux kernel output, which is different from the Android system output, logcat. Useful for checking hardware and to see if modules started up succesfully. Also useful for debugging in conjunction with logcat.
Code:
cat /proc/kmsg > /sdcard/dmesg.txt
Copies the dmesg output to a file fled dmesg.txt on the sdcard

And
Code:
cat /dev/log/system > /sdcard/logcat.txt
Copies the logcat output to a file named logcat.txt on your sdcard.


Also, you missed out the parted and e2fsck commands, used for partitioning and checking filesystem integrity.

Also, the command free (display free ram/swap) is not included.


Sent from my E15i using Tapatalk 2
 
Last edited:
  • Like
Reactions: g_ding84

dspPunk

Senior Member
Apr 13, 2012
155
16
Is there a command for check disk utility as in windows.. chkdsk...

my memory card is not working hence thought of running the check disk if possible... :)
 

dspPunk

Senior Member
Apr 13, 2012
155
16
I don't have a Xperia X8 actually, does it support mass storage mode for internal sdcard?

http://www.jayceooi.com/2012/03/14/...storage-on-android-4-0-ics-samsung-galaxy-s2/

I am having SGS2 and yes it supports mass storage for internal sdcard...

When i connect to my computer it shows only internal sdcard and not external card which is present in the external sdcard slot...

actually the problem is that my sdcard gets detected some times and sometimes it doesnt...

i searched a lot and many of them told that it is a kernel version issue.. i updated kernel still no luck..

then i got one thread which gave me the solution of check disk so was thinking whether terminal emulator has any commands for check disk..
 

piloro

Member
Sep 29, 2012
6
0
Hi hetunandu, great guide,
but still I don't understand few things:

1: how to run a specific action of an app?
2: how to KNOW the exact sintax of possible actions of an app?
3: is it possible to launch these commands via SSH (through an SSH server)?

eg: I want to start a audio-recording app on my phone from my computer, AND start recording from remote. Is it possible?

Thank you
(and sorry for my english..)
 

Duckboy44

New member
Oct 19, 2012
2
0
reading traffic stats

I am trying to get the traffic stat getMobileRxBytes (or any other traffic stat) to output a usable result in the terminal emulator. The goal is simply to be able to copy the rx bytes total to be used in Tasker. However, I can't seem to be able to get any output. I would appreciate it if anybody knows the proper command/syntax to show this traffic data. Thanks.

I am on a stock rooted 4.1.1 Galaxy Nexus.
 

aditqyen

New member
Jun 23, 2012
4
0
[Q] Is there a command to show some configuration ?

I have run this command on terminal emulator:

u0_a9@android:/ $ su
u0_a9@android:/ #setprop net.cdma.rstp.proxy.addr 0.0.0.0;
u0_a9@android:/ #setprop net.cdma.rstp.proxy.port 0;
u0_a9@android:/ #setprop net.cdma.httppd.proxy.addr 0.0.0.0;
u0_a9@android:/ #setprop net.cdma.httppd.proxy.port 0;

Is above command right..???

after that i ran "getprop" i don't see effect of that command.

Can you tell me the right way or command to change my rstp & httppd setting...? cause my Epic4G cannot play video streaming after flashing CM10 nightly.

thanks,

adit
 

leventgirgin

Member
Nov 23, 2011
13
0
permission denied

:(china telecom infotmic m7206 not root because no usb i want to root tablet pc
terminal is boot "permission denied" why
help me please ???:(
 

PutraMasyers97

Senior Member
Dec 5, 2012
322
59
Kuala Lumpur
Hi... Before this I have rooted my phone since yesterday when I accidentally copy su file from "/system" to "/system/bin/" andnow I can't get root access because on Superuser I check the su version was 3.1.1 but there got red words maybe it try saying that I put su file in wrong location and I can't move it back because my root explorer can't get root access and it just show Root Explorer acess denied by Superuser. Terminal emulator also access denied. One more I'm using Sony Ericsson W8 and it can't unlock bootloader. Could someone help me to remove su file from "/system/bin". Thanks You
 

Gogeta

Senior Member
Oct 9, 2012
6,547
810
28
Gingertown
Hi... Before this I have rooted my phone since yesterday when I accidentally copy su file from "/system" to "/system/bin/" andnow I can't get root access because on Superuser I check the su version was 3.1.1 but there got red words maybe it try saying that I put su file in wrong location and I can't move it back because my root explorer can't get root access and it just show Root Explorer acess denied by Superuser. Terminal emulator also access denied. One more I'm using Sony Ericsson W8 and it can't unlock bootloader. Could someone help me to remove su file from "/system/bin". Thanks You

Just root ur W8 again as u did before

see boot animation without rebooting:eek:
 
  • Like
Reactions: PutraMasyers97

Top Liked Posts

  • There are no posts matching your filters.
  • 39
    Always wondered what the terminal emulator app does? Dont now what commands to type? Well this thread is all about that :)



    ALERT!!! ALERT!!
    BELOW ARE THE COMMANDS AND THE PROCESSES THAT WILL HAPPEN BY TYPING THE COMMANDS!!!

    IF YOU DO NOT UNDERSTAND SOMETHING PLEASE SO NOT TRY IT.. IT IS RISKY AND WILL POTENTIALLY HARM YOUR DEVICE!!

    DO NOT BLAME ME THEN!!

    THIS IS A REFERENCE AND DEV THREAD. NOOBS SHOULD NOT LINGER AROUND HERE



    The Android Shell
    A "shell" is a program that listens to keyboard input from a user and performs actions as directed by the user. Android devices come with a simple shell program. This shell program is mostly undocumented. Since many people are curious about it I thought I'd write up some documentation for it.

    Currently this documentation is incomplete, sorry!

    Common problems
    The built-in shell has very limited error handling. When you type a command name incorrectly it will say "permission denied", even though the real problem is that it couldn't find the command:

    Code:
    $ dir
    dir: permission denied  <---- this is a misleading error message, should say 'dir: not found'
    $ ls
    ... listing of current directory

    The PATH variable

    The Android shell will run any program it finds in its PATH. The PATH is a list of directories. You can find out what your shell's PATH is set to by using the built-in echo command:

    Code:
    $ echo $PATH
    /data/local/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
    Depending upon your shell, you may see a different result.

    Built in Commands
    Every shell has a few built-in commands. Some common built-in commands are:

    • echo -- prints text to stdout.
    • set -- sets shell variables
    • export -- makes shell variables available to command-line programs
    • cd -- change the current directory.
    • pwd -- print name of the current directory.

    Commands

    To find out what commands you have available to you, use the "ls" command on each of the directories in the PATH variable.

    Finding documentation for the Android commands.

    Many of the Android commands are based on standard Linux (or bsd) commands. If you're curious about a command, you can sometimes learn how it works by using the "man" command on a desktop Linux or OSX (Apple Macintosh) computer. The Linux or OSX version of the command may be different in details, but much of the documentation will still apply to the Android version of the command.

    Another source of documentation for people without a Linux or OSX machine handy is to use a web browser and use a web search engine to search for the text: "man Linux command-name".

    List of commands

    The following is a list of the commands that are present on a Nexus S phone running an Android 2.3.3 "user-debug" build. Many of these commands are not present on a "user" phone. (They are missing from a "user" phone because they are specific to developing or debugging the Android operating system.)

    Code:
    $ ls /data/local/bin
    /data/local/bin: No such file or directory

    Notice that by default there is no /data/local/bin directory. You can create this directory using the "mkdir" command if you like.

    Code:
    $ ls /sbin
    opendir failed, Permission denied

    The /sbin directory exists, but you don't have permission to access it. You need root access. If you have a developer phone, or otherwise have root access to your phone you can see what's in this directory.

    Code:
    $ su
    # ls /sbin
    ueventd
    adbd
    # exit
    $

    Notice that the shell prompt changes from a '$' to a '#' to indicate that you have root access.

    Notice also that neither of the /sbin commands are useful to the shell -- the adb and ueventd files are 'daemon' programs used to implement the Android Debugger "adb" program that is used by developers.

    Code:
    $ ls /vendor/bin
    gpsd
    pvrsrvinit

    Vendor/bin is where device vendors can put device-specific executables. These files are from a Nexus S.

    Code:
    $ ls /system/sbin
    /system/sbin: No such file or directory
    This directory does not exist on a Nexus S.

    Code:
    $ ls /system/bin
    am
    am is the Android Activity Manager. It's used to start and stop Android activities (e.g. applications) from the command line. Type am by itself to get a list of options.

    Code:
    amix
    aplay
    Command line audio file player.

    Code:
    app_process
    applypatch
    Used to apply patches to android files.

    Code:
    arec
    Command line audio recorder.

    Code:
    audioloop
    bluetoothd
    BlueTooth daemon

    Code:
    bmgr
    Backup manager - type command by itself to get documentation.

    Code:
    bootanimation
    Draws the boot animation. You may have to reset your phone to get out of this.

    Code:
    brcm_patchram_plus
    bugreport
    cat
    Copy the contents of a file to standard output.

    Code:
    chmod
    Change the mode of a file (e.g. whether it can be read or written.)

    Code:
    chown
    Change the owner of a file.

    Code:
    cmp
    Compare two files byte-by-byte

    Code:
    dalvikvm
    The dalvik virtual machine. (Used to run Android applications.)

    Code:
    date
    Prints the current date and time

    Code:
    dbus-daemon
    dd
    Convert and copy a file. By default copies standard in to standard out.

    Code:
    debuggerd
    dexopt
    df
    Shows how much space is free on different file systems on your device.

    Code:
    dhcpcd
    dmesg
    dnsmasq
    dumpstate
    dumpsys
    dvz
    fsck_msdos
    gdbserver
    getevent
    getprop
    gzip
    hciattach
    hd
    id
    ifconfig
    iftop
    ime
    input
    insmod
    installd
    ioctl
    ionice
    iptables
    keystore
    keystore_cli
    kill
    Send signals to processes.

    Code:
    linker
    ln
    Used to set up a file system link.

    Code:
    log
    logcat
    Prints the Android runtime log.

    Code:
    logwrapper
    ls
    Lists files.

    Code:
    lsmod
    lsof
    make_ext4fs
    mediaserver
    mkdir
    Make a directory.

    Code:
    monkey
    A program that sends random events, used to test applications. (Like having a monkey playing with the device.)

    Code:
    mount
    mtpd
    mv
    Move a file from one directory to another. (Only on the same file system. Use "cat a > b" to copy a file between file systems.

    Code:
    nandread
    ndc
    netcfg
    netd
    netstat
    newfs_msdos
    notify
    omx_tests
    pand
    ping
    pm
    pppd
    printenv
    ps
    List active processes.

    Code:
    qemu-props
    qemud
    racoon
    radiooptions
    reboot
    Reboot the device.

    Code:
    record
    renice
    rild
    rm
    Remove a file.

    Code:
    rmdir
    Remove a directory.

    Code:
    rmmod
    route
    rtp_test
    run-as
    schedtest
    schedtop
    sdcard
    sdptool
    sendevent
    service
    servicemanager
    setconsole
    setprop
    setup_fs
    sh
    showlease
    sleep
    smd
    stagefright
    start
    Starts the Android runtime.

    Code:
    stop
    Stops the Android runtime.

    Code:
    surfaceflinger
    svc
    sync
    system_server
    tc
    testid3
    toolbox
    top
    Shows which processes are currently using the most CPU time.

    Code:
    umount
    uptime
    Prints how long your device has been running since it was last booted.

    Code:
    vdc
    vmstat
    vold
    watchprops
    wipe
    wpa_cli
    wpa_supplicant
    
    $ ls /system/xbin
    add-property-tag
    btool
    check-lost+found
    dexdump
    dhdutil
    hcidump
    latencytop
    librank
    opcontrol
    oprofiled
    procmem
    procrank
    rawbu
    scp
    Secure copy program. (Used to copy files over the network.)

    Code:
    showmap
    showslab
    sqlite3
    Used to administer SQLite databases.

    Code:
    strace
    System trace command - use to see what system calls a program makes.

    Code:
    su
    Start a shell with root privileges.

    Versions of the Android Shell
    Android 1.0 used a shell that had no tab completion or history editing.
    Android 2.3 added history editing. You can for example use the up/down arrows to edit previous commands.

    Other shells
    Busybox
    Busybox is a program that contains a shell and a set of command line utilities. Search Android Market for "Busybox" and you should find some versions you can install. The Busybox shell includes tab completion and history editing. Some versions of Busybox for Android do not require that you root your phone.

    Debian utilities
    You can install the full Debian shell and utilities. (Debian is a popular desktop Linux distribution.) I don't know the details, and it may require a "rooted" phone. Try a web search for "Debian Android install".

    Custom ROMs
    Some custom ROMs come with their own shells and utilities. If you are using a custom ROM, check its documentation to find out what's available.
    4
    Great guide, but you have forgot a very useful command: grep
    It allows to apply filters to the output of the commands. The syntax is:
    Code:
    command | grep filter
    For example, to list only the apk files inside a folder:
    Code:
    ls /folder/to/list | grep .apk
    ;)
    1
    Great guide!

    IMO dmesg is also important. Maybe you should add in a description for it?

    Dmesg --> prints the Linux kernel output, which is different from the Android system output, logcat. Useful for checking hardware and to see if modules started up succesfully. Also useful for debugging in conjunction with logcat.
    Code:
    cat /proc/kmsg > /sdcard/dmesg.txt
    Copies the dmesg output to a file fled dmesg.txt on the sdcard

    And
    Code:
    cat /dev/log/system > /sdcard/logcat.txt
    Copies the logcat output to a file named logcat.txt on your sdcard.


    Also, you missed out the parted and e2fsck commands, used for partitioning and checking filesystem integrity.

    Also, the command free (display free ram/swap) is not included.


    Sent from my E15i using Tapatalk 2
    1
    Hi... Before this I have rooted my phone since yesterday when I accidentally copy su file from "/system" to "/system/bin/" andnow I can't get root access because on Superuser I check the su version was 3.1.1 but there got red words maybe it try saying that I put su file in wrong location and I can't move it back because my root explorer can't get root access and it just show Root Explorer acess denied by Superuser. Terminal emulator also access denied. One more I'm using Sony Ericsson W8 and it can't unlock bootloader. Could someone help me to remove su file from "/system/bin". Thanks You

    Just root ur W8 again as u did before

    see boot animation without rebooting:eek: