Linux Commands on Android

This is a discussion on Linux Commands on Android within the Droid Hacks forums, part of the Droid Hacking category; 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 ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Linux Commands on Android

  1. RS Admin
    christim's Avatar
    Member #
    30681
    Join Date
    Jan 2010
    Location
    New England
    Posts
    5,143
    Phone
    Moto-Droid - rooted
    Premium Member
    #1

    Linux Commands on Android

    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
    Last edited by christim; 02-26-2010 at 08:59 PM.
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     
  3. Beta Team
    thebowers's Avatar
    Member #
    8519
    Join Date
    Nov 2009
    Location
    Iowa
    Posts
    2,548
    Twitter
    dabowerman
    Phone
    Rooted Droid, OC @ 1.1 Ghz
    DroidForums.net Theme Developer
    Premium Member
    #2
    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
    If you like what I do, thanks



    Your can follow me as follows

    @dabowerman - Twitter
    Derek Bower - G+ - this is where I will be @ the most and where stuff gets released first.

    Theming Guides that might come in handy
    Theming Guide for Progress Bar
    Notification Text Color Change (How to)
    Theming Guide for System Text
  4. Developer
    adrynalyne's Avatar
    Member #
    18036
    Join Date
    Dec 2009
    Posts
    2,896
    Liked
    4 times
    Phone
    Droidzilla
    DroidForums.net Developer
    Premium Member
    #3
    Quote Originally Posted by christim View Post
    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.
    • chmode - 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.
    • cd - change from one directory to another
    • cp - Copy a file from one location to another
    • exit - exits the shell you are in. When you type su you start up a shell.
    • 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.
    • 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.

    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.
  5. Developer
    adrynalyne's Avatar
    Member #
    18036
    Join Date
    Dec 2009
    Posts
    2,896
    Liked
    4 times
    Phone
    Droidzilla
    DroidForums.net Developer
    Premium Member
    #4
    cat can also be used to rename/move files.
    tar is used as a command line compress/decompress utility.
  6. RS Admin
    christim's Avatar
    Member #
    30681
    Join Date
    Jan 2010
    Location
    New England
    Posts
    5,143
    Phone
    Moto-Droid - rooted
    Premium Member
    #5
    Quote Originally Posted by thebowers View Post
    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
    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.
  7. RS Admin
    christim's Avatar
    Member #
    30681
    Join Date
    Jan 2010
    Location
    New England
    Posts
    5,143
    Phone
    Moto-Droid - rooted
    Premium Member
    #6
    Quote Originally Posted by adrynalyne View Post
    cat can also be used to rename/move files.
    tar is used as a command line compress/decompress utility.
    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
  8. RS Admin
    christim's Avatar
    Member #
    30681
    Join Date
    Jan 2010
    Location
    New England
    Posts
    5,143
    Phone
    Moto-Droid - rooted
    Premium Member
    #7
    Quote Originally Posted by samiusmc View Post
    What does FU mean?
    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.
  9. Droid
    h1br1d7heory's Avatar
    Member #
    38707
    Join Date
    Feb 2010
    Location
    Long Island
    Posts
    71
    Phone
    Motorola DROID Bionic
    #8
    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?
  10. Droid Newbie
    gustofusion's Avatar
    Member #
    101956
    Join Date
    Aug 2010
    Posts
    2
    Phone
    Enter Current Phone Model Here
    #9
    Quote Originally Posted by h1br1d7heory View Post
    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?



    run this fro a terminal then you can chmod

    mount -o remount,rw -t ext3 /dev/block/mmcblk1p21 /system
  11. Droid Ninja
    Se7enLC's Avatar
    Member #
    5148
    Join Date
    Nov 2009
    Posts
    1,263
    Liked
    6 times
    Phone
    Samsung Galaxy Nexus
    #10
    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.
    Cool CM Tricks
    custom_backup_list.txt - make a list of files in /system that will survive a nightly install (ringtones, notifications, system apps, wallpapers, whatever)
    in Terminal Emulator, set this as your shell command: "/system/xbin/su -c /system/xbin/bash". You get all the features of bash, root access, and you can still use the initial command field for whatever you want (default is adding /data/local/bin to your path)

Sponsors

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Similar Threads

  1. Linux influence...
    By Martin030908 in forum Android Forum
    Replies: 1
    Last Post: 02-09-2010, 07:27 AM
  2. Virtualbox/Linux
    By liquidzoo in forum Droid General Discussions
    Replies: 1
    Last Post: 02-02-2010, 04:09 PM
  3. Linux on droid
    By Ack in forum Droid Hacks
    Replies: 14
    Last Post: 01-29-2010, 10:50 AM
  4. Linux On Droid?
    By Melon Bread in forum Droid Hacks
    Replies: 13
    Last Post: 01-09-2010, 05:31 PM
  5. Linux infestation
    By tdawg5480 in forum Off Topic Forum
    Replies: 4
    Last Post: 12-30-2009, 11:33 PM

Search tags for this page

android busybox commands
,
android command
,
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
,
busybox android commands
,

terminal emulator android commands

,
terminal emulator android commands list
,
terminal emulator commands android
,
terminal emulator commands android list
Click on a term to search our site for related topics.