Shell
Die Shell ist die Verbindungsschnittstelle zwischen dem Benutzer und dem Smartphone. Diese Schnittstelle kann dabei in Form einer Kommandozeile oder einer GUI auftreten. Meist wird allerdings die Shell als Kommandozeile bezeichnet. (ebenso in diesem Artikel)
Funktion
Die Shell ist eine auf Kommandozeilenebene funktionierende Schnittstelle, die es dem Nutzer ermöglicht, Funktionen auf dem Android auszuführen. Theoretisch lassen sich über die shell alle Funktionen des Androidsmartphones ausführen, wobei es bei vielen durch die fehlende grafische Oberfläche aufwendiger ist als mittels den GUI's möglich ist.
Aufruf der Shell
Die Shell ist bei Android allgegenwärtig. Eine Interaktion mit dem Nutzer ist dabei meist nicht direkt, sondern indirekt mittels einer App und einer GUI gewünscht. Um trotzdem die shell-Befehle ausführen zu können, gibt es zwei Möglichkeiten:
- eine App, die die shell-Befehle ausführt (z.B.: Terminal Emulator), ähnlich dem cmd in Windows
- mit den adb-Tools
mit einer App
Die einfachere Variante ist es, die shell direkt auf dem Androidsmartphone zu starten. Dazu gibt es diverse Apps, die die eingegebenen Befehle direkt in der Shell ausführt und die Ergebnisse wiedergibt. Die App kann dabei noch einzelne Komfortfunktionen wie das farbige Hervorheben oder das Speichern oft verwendeter Befehle unterstützen.
mit den ADB-Tools
eine weniger bequeme Variante ist das Aufrufen der Shell mittels den ADB-Tools. Hierfür ist immer noch ein PC von Nöten, an dem das Smartphone angeschlossen ist. Außerdem werden noch die USB-Treiber benötigt. Mehr dazu siehe hier. Um eine neue shell-Session zu initiieren, stellt man zunächst sicher, das ein Android Smartphone erkannt wurde. Danach kann man eine shell-Session mittels folgendem Befehl starten:
adb shell
Danach erscheint in dem cmd-Fenster entweder ein "$"-Zeichen, oder eine "#". Je nachdem, ob die shell Root-Rechte hat oder nicht. Nun kann man jeden beliebigen shell-Befehl ausführen und bekommt das Ergebnis angezeigt.
Befehle
Da die Shell direkt mit dem Kernel in Verbindung steht, und dieser auf Linux basierend ist, funktionieren die meisten Linux-Kommandos, die in den Kernel implementiert sind. Zusätzlich lassen sich auch shell-Sripts erstellen, die, ähnlich wie die Stapelverarbeitungsdateien von Windows (Batch), eine Befehlsreihenfolge ausführen. Bekannte und häufig verwendete Befehle sind:
Befehl | Funktion |
---|---|
ls | zeigt den Inhalt des aktuell ausgewählten Verzeichnisses an |
cd | Wechselt in das angegebene Verzeichnis (wie Windows) |
rm | Löscht die Datei im ausgewählten Verzeichnis |
mkdir | Erstellt ein neues Verzeichnis |
Diese Befehle sind lediglich zum Verwalten von Dateien. Eine Referenz für vorhandene Kommandos gab es bislang hier:
http://en.androidwiki.com/wiki/ADB_Shell_Command_Reference
Da diese Quelle leider nicht mehr verfügbar ist, veröffentlichen wir den Inhalt unverbindlich hier:
akmd: no response, system hangs up using connectbot v1.7.1, logged in as local $ am [subcommand] [options] start an Activity: am start [-D] [-W] <INTENT> -D: enable debugging -W: wait for launch to complete start a Service: am startservice <INTENT> send a broadcast Intent: am broadcast <INTENT> start an Instrumentation: am instrument [flags] <COMPONENT> -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT) -e <NAME> <VALUE>: set argument <NAME> to <VALUE> -p <FILE>: write profiling data to <FILE> -w: wait for instrumentation to finish before returning start profiling: am profile <PROCESS> start <FILE> stop profiling: am profile <PROCESS> stop <INTENT> specifications include these flags: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-c <CATEGORY> [-c <CATEGORY>] ...] [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] [--esn <EXTRA_KEY> ...] [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] [-n <COMPONENT>] [-f <FLAGS>] [--grant-read-uri-permission] [--grant-write-uri-permission] [--debug-log-resolution] [--activity-brought-to-front] [--activity-clear-top] [--activity-clear-when-task-reset] [--activity-exclude-from-recents] [--activity-launched-from-history] [--activity-multiple-task] [--activity-no-animation] [--activity-no-history] [--activity-no-user-action] [--activity-previous-is-top] [--activity-reorder-to-front] [--activity-reset-task-if-needed] [--activity-single-top] [--receiver-registered-only] [--receiver-replace-pending] [<URI>] app_process cat $ chmod <MODE> <FILE> $ cmp Usage: cmp [-b] [-l] [-n count] file1 file2 dalvikvm $ dalvikvm Dalvik VM requires a class name $ date -s yyyyMMdd.HHmmss $ dbus-daemon No configuration file specified. dbus-daemon [--version] [--session] [--system] [--config-file=FILE] [--print-add ress[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect dd debug_tool debuggerd $ dexopt Usage: don't use this $ df output /dev: 319124K total, 0K used, 319124K available (block size 4096) /system: 558668K total, 398176K used, 160492K available (block size 4096) /data: 1178068K total, 259136K used, 918932K available (block size 4096) /cache: 294628K total, 42992K used, 251636K available (block size 4096) /devlog: 21100K total, 15980K used, 5120K available (block size 4096) /mnt/asec: 319124K total, 0K used, 319124K available (block size 4096) /app-cache: 8192K total, 5540K used, 2652K available (block size 4096) /mnt/sdcard: 7763968K total, 277088K used, 7486880K available (block size 32768) /mnt/secure/asec: Permission denied /mnt/asec/com.RunnerGames.game.YooNinja_Lite-1: 6236K total, 5012K used, 1224K a vailable (block size 4096) /mnt/asec/com.glu.android.gunbros_free-1: 4164K total, 2104K used, 2060K availab le (block size 4096) dhcpcd dmesg dumpcrash dumpstate dumpsys dvz fillup flash_image getevent getprop hciattach hcid $ hd usage: hd [-b base] [-c coun] [-r delay] file hostapd hostapd_cli htclogkernel id ifconfig iftop $ input usage: input [text|keyevent] input text <string> input keyevent <event_code> id $ insmod usage: insmod <module.o> installd ioctl itr kill linker ln $ log USAGE: log [-p priorityChar] [-t tag] me ssage priorityChar should be one of: v,d,i,w,e logcat logwrapper ls lsmod mediaserver mkdir mkdosfs mount $ monkey usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...] [-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...] [--ignore-crashes] [--ignore-timeouts] [--ignore-security-exceptions] [--monitor-native-crashes] [--ignore-native-crashes] [--kill-process-after-error] [--hprof] [--pct-touch PERCENT] [--pct-motion PERCENT] [--pct-trackball PERCENT] [--pct-syskeys PERCENT] [--pct-nav PERCENT] [--pct-majornav PERCENT] [--pct-appswitch PERCENT] [--pct-flip PERCENT] [--pct-anyevent PERCENT] [--pkg-blacklist-file PACKAGE_BLACKLIST_FILE] [--pkg-whitelist-file PACKAGE_WHITELIST_FILE] [--wait-dbg] [--dbg-no-events] [--setup scriptfile] [-f scriptfile [-f scriptfile] ...] [--port port] [-s SEED] [-v [-v] ...] [--throttle MILLISEC] [--randomize-throttle] COUNT mountd $ mv USAGE: mv <source...> <destination> netcfg netstat $ notify Usage: notify [-m eventmask] [-c count] [-p] [-v verbosity] path [path ...] ping playmp3 $ pm usage: pm [list|path|install|uninstall] pm list packages [-f] pm list permission-groups pm list permissions [-g] [-f] [-d] [-u] [GROUP] pm list instrumentation [-f] [TARGET-PACKAGE] pm list features pm path PACKAGE pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH pm uninstall [-k] PACKAGE pm enable PACKAGE_OR_COMPONENT pm disable PACKAGE_OR_COMPONENT pm setInstallLocation [0/auto] [1/internal] [2/external] The list packages command prints all packages. Options: -f: see their associated file. The list permission-groups command prints all known permission groups. The list permissions command prints all known permissions, optionally only those in GROUP. Options: -g: organize by group. -f: print all information. -s: short summary. -d: only list dangerous permissions. -u: list only the permissions users will see. The list instrumentation command prints all instrumentations, or only those that target a specified package. Options: -f: see their associated file. The list features command prints all features of the system. The path command prints the path to the .apk of a package. The install command installs a package to the system. Options: -l: install the package with FORWARD_LOCK. -r: reinstall an exisiting app, keeping its data. -t: allow test .apks to be installed. -i: specify the installer package name. -s: install package on sdcard. -f: install package on internal flash. The uninstall command removes a package from the system. Options: -k: keep the data and cache directories around. after the package removal. The enable and disable commands change the enabled state of a given package or component (written as "package/class"). The getInstallLocation command gets the current install location 0 [auto]: Let system decide the best location 1 [internal]: Install on internal device storage 2 [external]: Install on external media The setInstallLocation command changes the default install location 0 [auto]: Let system decide the best location 1 [internal]: Install on internal device storage 2 [external]: Install on external media printenv ps $ qemudqemud: permission denied $ radiooptions Usage: radiooptions [option] [extra_socket_args] 0 - RADIO_RESET, 1 - RADIO_OFF, 2 - UNSOL_NETWORK_STATE_CHANGE, 3 - QXDM_ENABLE, 4 - QXDM_DISABLE, 5 - RADIO_ON, 6 apn- SETUP_PDP apn, 7 - DEACTIVE_PDP, 8 number - DIAL_CALL number, 9 - ANSWER_CALL, 10 - END_CALL 11 rsp - FAKE_UNSOL 12 num_of_rsp rsp - FAKE_UNSOL_EXT, 13 command - UNIAT, : Unknown error: 0 reboot renice rild rm rmdir rmmod route schedtop sdptool sdutil sendevent service servicemanager setconsole setprop sh sleep smd ssltest start stop surfaceflinger svc sync system_server telnetd toolbox top umount vmstat watchprops wipe wlan_loader wpa_cli wpa_supplicant
Quelle: http://en.androidwiki.com/wiki/ADB_Shell_Command_Reference[1]
Allerdings ist es davon abhängig, wie viele von diesen Befehlen in der Rom implementiert wurden. Grundsätzlich kann man sagen, das die StockRoms entgegen zu den CustomRoms deutlich weniger Funktionen implementiert haben.
Einzelnachweise
- ↑ Interner Lua-Fehler: Der Interpreter beendet sich mit dem Status 127.