Using the command-line on Google Android, and other useful apps.

Terminal Emulator app for Android.

Terminal Emulator app for Android.

This terminal emulator application for the Google Android operating system allows the user to execute various commands on their Android devices. The command set is fairly restricted, but the ability to access the Linux command line on Android makes up for this. You may use the cat command to view the contents of files such as the /system/etc/hosts file. I typed this command: echo “127.0.0.1 doubleclick.net” >> hosts but I got the error that it was a read-only file-system and it could not write to the file. I guess I need to root my device and install a proper Linux installation to be able to properly use Linux on an Android device.

Winamp for Android is the best media player for music on Android, far better than the default media player that the Telstra T Tab comes with.

http://www.winamp.com/android. The Winamp player supports playlists and various music formats as well.

Tune in radio for Android is the best way to listen to the radio online whilst you are doing other things on your Android device. https://play.google.com/store/apps/details?id=tunein.player&hl=en. The local stations near you and many others will be available for online streaming.

The Telstra T Tab homescreen.

The Telstra T Tab homescreen.

Opera Mobile is the best web browser for Android, I can use my WordPress website in it just fine to upload screenshots from my tablet to the media library. https://play.google.com/store/apps/details?id=com.opera.browser&feature=search_result. The web apps and the terminal emulator would benefit from having a bluetooth keyboard available for your Android device to make typing faster and easier. There is a Linux install app for Android that gives you a minimal install of Linux, that might have a more complete feature set than the terminal emulator application. The Linux installer application allows you to install Debian or Ubuntu on an Android device. This requires a fair amount of space on your device depending on how many Linux applications you installed. This would be a good way to extend the functionality of your Android device.

Linux installer for Android.

Linux installer for Android.

The Linux installer can even run Lubuntu which would be a very fast and usable desktop on a mobile device indeed and there is no need to remove your Android installation to install the Linux distribution of your choice. With the terminal emulator app installed you can use the df command to see how much space is available on your device. An example below.

The df command in the terminal emulator command will not allow you  to use parameters like the df -Hla command in Linux, but it is still very good. To copy text, press and hold over the text and then tap on the Select Text option and then drag to select the text you desire, it will be automatically copied to the clipboard. But using the command-line on a mobile Android device elevates it above a Symbian phone.

# df
/dev: 212548K total, 20K used, 212528K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 163840K total, 144020K used, 19820K available (block size 4096)
/data: 179200K total, 144492K used, 34708K available (block size 4096)
/cache: 98304K total, 79884K used, 18420K available (block size 4096)
/sdcard: 3858432K total, 3345408K used, 513024K available (block size 32768)

Managing processes with the UNIX command line.

The Linux command-line has many powerful tools for viewing and managing running processes on your UNIX/Linux machine. The lsof command is a very useful command, it will display a list of all open files owned by active processes running on your system. Below is an excerpt from the output this command will give you.

root@deusexmachina:/home/neo# lsof | tail -n 20
lsof      26891        root    4r      DIR                0,3             0     630773 /proc/26891/fd
lsof      26891        root    5w     FIFO                0,8           0t0     630778 pipe
lsof      26891        root    6r     FIFO                0,8           0t0     630779 pipe
tail      26892        root  cwd       DIR               8,53          4096     651521 /home/neo
tail      26892        root  rtd       DIR               8,49          4096          2 /
tail      26892        root  txt       REG               8,49         61864    4072509 /usr/bin/tail
tail      26892        root  mem       REG               8,49       1583120    3407895 /lib/x86_64-linux-gnu/libc-2.13.so
tail      26892        root  mem       REG               8,49        136936    3407917 /lib/x86_64-linux-gnu/ld-2.13.so
tail      26892        root  mem       REG               8,49       1534592    4079033 /usr/lib/locale/locale-archive
tail      26892        root    0r     FIFO                0,8           0t0     628464 pipe
tail      26892        root    1u      CHR              136,1           0t0          4 /dev/pts/1
tail      26892        root    2u      CHR              136,1           0t0          4 /dev/pts/1
lsof      26893        root  cwd       DIR               8,53          4096     651521 /home/neo
lsof      26893        root  rtd       DIR               8,49          4096          2 /
lsof      26893        root  txt       REG               8,49        124976    4068930 /usr/bin/lsof
lsof      26893        root  mem       REG               8,49       1583120    3407895 /lib/x86_64-linux-gnu/libc-2.13.so
lsof      26893        root  mem       REG               8,49        136936    3407917 /lib/x86_64-linux-gnu/ld-2.13.so
lsof      26893        root  mem       REG               8,49       1534592    4079033 /usr/lib/locale/locale-archive
lsof      26893        root    4r     FIFO                0,8           0t0     630778 pipe
lsof      26893        root    7w     FIFO                0,8           0t0     630779 pipe
root@deusexmachina:/home/neo#

if you are having problems with umounting a partition or a hung process that is accessing a file, then this command will help you out. Once you find out the PID of the offending process you may then kill it with the kill -9 command to free up the file.

The ps command is also a good way to view a list of running processes. Use the ps aux command to view a complete list of all running processes. The pstree command will show a tree view of running processes. An example below, you use the pstree $LOGNAME command to view all running processes belonging to your user.

neo@deusexmachina:~/Documents$ pstree neo
bash───banshee───20*[{banshee}]

chrome─┬─chrome
       ├─chrome───2*[{chrome}]
       └─33*[{chrome}]

chrome-sandbox───chrome─┬─7*[chrome───3*[{chrome}]]
                        ├─chrome───4*[{chrome}]
                        ├─chrome───2*[{chrome}]
                        └─nacl_helper_boo

dbus-daemon

dbus-launch

dconf-service───2*[{dconf-service}]

gconfd-2

gnome-settings-───2*[{gnome-settings-}]

gvfs-afc-volume───{gvfs-afc-volume}

gvfs-gdu-volume

gvfs-gphoto2-vo

gvfsd

gvfsd-http───2*[{gvfsd-http}]

gvfsd-metadata

gvfsd-trash

lxsession─┬─lxpanel
          ├─openbox
          ├─pcmanfm
          ├─polkit-gnome-au───{polkit-gnome-au}
          ├─ssh-agent
          └─xscreensaver

lxterminal─┬─bash
           ├─bash─┬─pstree
           │      └─xclock
           ├─gnome-pty-helpe
           └─{lxterminal}

me-tv───{me-tv}

menu-cached

notification-da───{notification-da}

pulseaudio─┬─gconf-helper
           └─3*[{pulseaudio}]
neo@deusexmachina:~/Documents$

As you can see, the lxsession is the master process and the lxpanel, openbox and pcmanfm processes are running under that process. As with the lxterminal command, there are processes that were executed within that terminal, therefore they are under the lxterminal process.

The ps axjf command will also print out a process tree of running processes. Searching for a running process is easy, the grep command is used here.

neo@deusexmachina:~/Documents$ ps aux | grep bash
neo      25554  0.0  0.0  20556  3368 pts/0    Ss+  Apr16   0:00 /bin/bash
neo      26555  0.0  0.0  10748  1480 ?        S    10:31   0:00 bash /usr/bin/banshee --redirect-log --play-enqueued
neo      26830  0.0  0.0  20580  3512 pts/1    Ss   10:44   0:00 /bin/bash
neo      27346  0.0  0.0  20556  3380 pts/2    Ss   11:27   0:00 /bin/bash
neo      27430  0.0  0.0   7796   864 pts/2    S+   11:33   0:00 grep bash

This enables you to quickly find the PID of a certain process and kill it.