1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

Linux Commands on Android

Discussion in 'Android Hacks and Help' started by christim, Feb 26, 2010.

  1. christim
    Offline

    christim Super Moderator

    Joined:
    Jan 23, 2010
    Messages:
    5,112
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New England
    I thought I'd start a thread on what some of the commands mean people are typing when rooted and see if there was any interest in this. I searched but did not find a similar thread but if there is let me know. I'll also include some other commands you can try out that you may not have used, especially if you are not familar with Linux or Unix.

    These are typed in the terminal emulator, available for free from the market place as Android Terminal Emulator. Once downloaded it shows as Terminal Emulator in your app drawer.

    Don't just randomly try commands. Some delete things so know what you are doing.

    • chmod - give/take rights away from files. The numbers you see in the how-to's is a little complicated. It has to do with the rights you are assigning the file or folder. http://wiki.linuxquestions.org/wiki/Chmod for further reading.
    • cat - look at, modify, or combine a file. You can also copy files with this command by "reading" it to another file instead of to the screen.
    • cd - change from one directory to another
    • cp - Copy a file from one location to another
    • dd - copies exact locations to other locations. Can be an entire drive, a folder, etc. dd if=<file directory> of=<other directory>. uses an input file and an output file.
    • exit - exits the shell you are in. When you type su you start up a shell.
    • ls - lists all files with in a directory try ls - l too.
    • mv - Move a file from one location to another. At the same time you can rename a file.
    • su - Substitute User. We type this to switch to the root user. You need to type this command first to do a lot of the other commands.
    • tar - creates taped archives. Compresses files like winzip, 7zip, winrar and others tar /? for details.
    • rm - followed by a file name with delete the file
    • sync - synchronizes any data on disk with data in memory. We type this before rebooting to ensure we've got all data written
    Other commands of interest:


    • df - how much free disk space. In linux you can add a switch "df -h" but the "-h" does nothing for me on Android.
    • top - like task manager, it displays running processes. in Linux the q key quits. On Android I don't know how to make it quit other than closing the app.
    • uptime - displays how long it has been since you last rebooted the system. Interestingly enough the "Menu Key > System > About Phone > Status > Up time" on my phone does not match "uptime" typed in the terminal emulator.


    • busybox - a tool that combines many linux commands into a single compact file. Typing this displays all the commands at your disposal.
      • busybox df - a much easier to read display of free diskspace. This display shows how full (use%) each file system is.
        • Search the internet for what some of the other busybox commands do by just searching for something like "linux df".

    If there are other good commands of interest post them here and I'll add them to this. Searching the internet will show you others as well.

    You also can put a /? after the command so ls /? will display options. ls -l will do a long list vs the list short view
  2. thebowers
    Offline

    thebowers Premium Member Theme Developer Premium Member

    Joined:
    Nov 24, 2009
    Messages:
    2,548
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Iowa
    Here is some more

    ls - lists all files with in a directory
    rm - followed by a file name with delete the file

    there are many other commands and you can also make custom ones to shorten commands.

    Edit: I think your first command is suppose to be chmod
  3. adrynalyne
    Offline

    adrynalyne Premium Member Premium Member Developer

    Joined:
    Dec 21, 2009
    Messages:
    2,896
    Likes Received:
    4
    Trophy Points:
    0

    chmode should be chmod.

    Many of these commands require busybox to not only be installed, but used in the command, unless you symlink the commands.

    For example, cp would be used as busybox cp.
  4. adrynalyne
    Offline

    adrynalyne Premium Member Premium Member Developer

    Joined:
    Dec 21, 2009
    Messages:
    2,896
    Likes Received:
    4
    Trophy Points:
    0
    cat can also be used to rename/move files.
    tar is used as a command line compress/decompress utility.
  5. christim
    Offline

    christim Super Moderator

    Joined:
    Jan 23, 2010
    Messages:
    5,112
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New England
    Right you are..I fixed "chmod", thanks. I was a little worried posting the rm command but if you have a backup you are all set. There's some recursive stuff that I won't be posting though :)

    I'm used to the up-arrow at a command prompt scrolling through your history of commands. I don't know if that's terminal emulator not passing it through (d-pad?) or if this version of Linux just doesn't support it.

    uname -a will display the version of Linux you are running.
    for me it says:
    2.6.29-Smoked_Glass #9
    I'm running the SG4.5 rom at the moment.
  6. christim
    Offline

    christim Super Moderator

    Joined:
    Jan 23, 2010
    Messages:
    5,112
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New England
    two good ones. cat is one used in instructions here too. dd is another one I just added as well, thanks!

    cat is an interesting one to use for copying because it normally is used for viewing a file. By redirecting that viewing to another file, instead of defaulting to the screen we read the contents into another file...thus making a copy
    cat file1.txt > file2.txt
  7. christim
    Offline

    christim Super Moderator

    Joined:
    Jan 23, 2010
    Messages:
    5,112
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New England
    hey hey hey...this is a family rated site :)

    Do you have an example of where you saw this in use? It is not a command I am familar with and when I try to FU it says "not found" so it isn't installed on my phone.
  8. h1br1d7heory
    Offline

    h1br1d7heory New Member

    Joined:
    Feb 18, 2010
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Long Island
    I am trying to use chmod so I can write to /system/app.

    I have tried the following with the following results:

    chmod 755 /system/app
    Unable to chmod /system/app: Read-only file system


    The goal: I am trying to move some .apk files from my sdcard into that folder.

    Can someone tell me what I am doing wrong?
  9. gustofusion
    Offline

    gustofusion New Member

    Joined:
    Aug 10, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0



    run this fro a terminal then you can chmod

    mount -o remount,rw -t ext3 /dev/block/mmcblk1p21 /system
  10. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Good idea to put this all in one place!

    The "-h" on df is to display in "human readable" format - ie, it splits sizes up into kb, mb, gb instead of just showing a really large number of kb. I believe some versions use this mode by default, so the -h may be unnecessary.

    /? is for windows and does nothing for linux commands. In linux, the parameter is usually -h, or --help, and sometimes -?. Always a dash, though, never a slash.

    Some other useful commands:
    du - show disk usage of files. Add "-h" to get human readable. Especially useful when you add "-d1" to limit the directory depth to 1. If you run "du -h -d1", it will tell you how much space each directory occupies, including their contents summed.

    rmdir - remove a directory. rm can't do it unless you remove recursively with -R
    pm - android package manager. LOTS of useful things in here, type pm by itself for the help screen
    ps - list processes. Useful to see what is running
    kill - kill a process by PID
    top - graphical display of processes, including cpu and memory use. hit 'q' to exit.
    reboot - reboot
    grep - search within a file for a text string. Also useful for parsing command output. 'ls | grep something' is a quick way to list files that contain the string "something" (although "ls *something*" would do it, too, but grep can do a lot more)
    ping - see if an internet host is alive
    ifconfig - get network interface configuration. Good for getting your own IP address.
  11. jeffe65
    Offline

    jeffe65 New Member

    Joined:
    Mar 8, 2010
    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Phoenix, AZ
    Anybody know if there's a way to start a program on boot using commands, or does it have to be set within the program itself? I'm using AutoKill, and it works great, but you have to set it back to your preferences after reboot.
  12. solar
    Offline

    solar New Member

    Joined:
    Dec 8, 2009
    Messages:
    801
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    So Cal
    I just came across this thead. Pretty cool stuff. I"m always interested in learning more about android.
  13. knuckleheadTech
    Offline

    knuckleheadTech New Member

    Joined:
    Dec 9, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Idaho USA
    I do love some good command line lovin'. Thank you for posting this. If anyone has more keep it coming.
  14. Jsk19
    Offline

    Jsk19 New Member

    Joined:
    May 26, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    busybox and uptime do not work for me =(
  15. contractorslim
    Offline

    contractorslim New Member

    Joined:
    May 13, 2011
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    0
    Just curious does anyone know what a command used to download a file? I'm trying to partition my sd card and found a way using the following command via code.google.com

    $ su
    # cd /data
    # wget http://64.105.21.209/bin/lib/droid/sdsplit
    # chmod 555 sdplit
    # exit

    I get wget: not found.

    Is there any way to use a different command from terminal emulator to download the executeable? I tried through a browser but it looks like a script...showing source code only. Maybe everyone can help me out.
  16. ronaldguilmet
    Offline

    ronaldguilmet New Member

    Joined:
    Dec 31, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Philadelphia, PA
    can't su from terminal

    I can start my terminal with the option of starting in root, and it works. Just curious why I can't SU from term. it says unknown user root, but I do have root. should i be typing something else?
  17. Never
    Offline

    Never New Member

    Joined:
    Nov 2, 2011
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Is there any command for rebooting into emergency mode? My back button is not working.
  18. ebgb17
    Offline

    ebgb17 New Member

    Joined:
    Jul 18, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I don't have a roofed phone but I can still use the emulator. Also if you have a file viewed look for the folder BIN.
    The location is /system
    It has all the commands your phone can use.​
Search tags for this page
android busybox commands
,
android command
,
android command line
,
android command line commands
,

android commands

,
android commands list
,

android linux commands

,

android terminal commands

,
android terminal commands list
,

android terminal emulator commands

,
android terminal emulator commands list
,
linux commands for android
,

terminal emulator android commands

,
terminal emulator android commands list
,
terminal emulator commands android