Useful Terminal Commands

OffWorld

Senior Member
Oct 5, 2010
460
67
If you're familiar with Linux you might think you can just use Linux commands on an Android device, but even on a rooted tablet you quickly discover a LOT of the commands you wouldn't think twice about entering on Linux don't work on Android, or the commands are there but flags and parameters you'd assume you can use aren't recognized. Why? Because they didn't include a lot of the little "helper" programs that usually ship with Linux. Thankfully they do ship some of them, though many are simplified versions. Here is my list of useful commands to enter in a Terminal on the tablet (or via adb shell), some of them may require root though, I'm not sure. Feel free to add your own favorites to this thread!

STORAGE SPACE

Code:
#df

Shows the storage space in kilobytes (it doesn't appear df as implemented on Android accepts the -H flag so you're stuck with kilobytes). Pay particular attention to the /sdcard and /nand as those are where users can store files. If you add up all the the numbers (except /sdcard) you'll find out how much total built-in storage you actually have on your tablet. For example, my tablet shows /nand is 1422144 K but if I add up all the internal storage it totals 1992976 K (or 1.9 GB).

MEMORY INFO

Code:
#cat /proc/meminfo

"MemTotal" = physical memory minus whatever is being shared with devices (such as the radio, DMA buffers, etc), so it will always be less than the advertised RAM for your tablet.

"MemFree" = whatever is not being used at all. This number will vary depending on what apps and services are running.

"Cached" = typically around 20 MB, that's just how it is.

"SwapCached" = will always read zero. Android doesn't actually use this apparently.

Note: I couldn't get any of the usual Linux methods to find the actual physical RAM amount to work.

FILE SYSTEM SUPPORT

Code:
#cat /proc/filesystems

Will show you what file system support was rolled into the kernel. So if you connect a drive that is formatted in something odd you can see if it's even possible for your tablet to read it.

KERNEL MODULES

Code:
#cat /proc/modules
or
#lsmod

Shows you a list of the modules baked into the kernel. If you can't get your tablet to recognize something this may help you determine if it is even supported.

FIRMWARE VERSION

Code:
#cat /proc/version

Will show you the Linux kernel version (not particularly useful), but the number after the "#" sign will be the firmware build and it will also show you the full date of the build (useful since some firmware is referred to by the date rather than the build number).

LOTS OF DATA

Code:
#dmesg

Gives you a major info-dump on your tablet. Sorting through it (if you know how to read it) will be info on memory, networking, and of particular interest to some people the MAC address of the tablet.
 
Top