• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Android Console FAQ

paimon.soror

Android Enthusiast
Apr 29, 2010
413
76
Vernon, CT
Just wanted to start a quick FAQ for those users who havn't had a chance to toy around with the Linux console which is what the Android OS is based off of.

1. Commands like 'cat' 'mv' 'rm' are not working, why?

Chances are that these commands currently dont reside on your path, which is common when you start the phone in recovery mode. To remedy this, enter the following in your console

export PATH=/system/bin:$PATH
Note, it is important that the separator is a colon :)) not a semicolon (;)

2. How can I copy a file from locationX/app1.apk to locationY?

Depending on if you have busybox installed, and on your path, you may not be able to perform the 'cp' command because it doesn't exist on the system. The android system however, allows binary streaming. To copy from one location to another, perform the following action

cat locationX/app1.apk > locationY/app1.apk
Note, it is important that you include the carat ">" or else the cat command will push the contents of app1 to the console. This will result in the console outputting beeping noises until the phone is disconnected from the debugger

3. What exactly is the 'ln -s locationX/app1 locationY/app1' command doing?

Performing an 'ln -s [source] [dest]' is creating something called a symbolic link. This is similar to Windows' "shortcut". For example, if we wanted to create a "shortcut" to /system/bin/mycoolprogram on our sdcard, we can do something like this:

ln -s /system/bin/mycoolprogram /sdcard/mycoolprogram
Now when we execute 'mycoolprogram' from /sdcard, it is actually referencing the applicaiton that is in /system/bin.

4. How can I list the files in a directory?

Just like in Unix, you can perform the 'ls' command to list out all of the files in a directory. If you would like to list out all files, including those that are hidden (hidden files in unix have a leading period, i.e., .myhiddenfolder) you can add a few flags to the ls command.

- List files
ls

- List all files
ls -a

- List all files with detail
ls -a -l
5. What exactly am I doing when I type 'chmod #### [file]' ?

The 'chmod' command is actually changing the permissions for the file that you supply. When you perfrom an "ls -a -l" command you will see a large list of files with detail. If you look to the far left of a listing, you will see something similar to the following:

drwxr-xr-x 4 root
These are the permissions of the file. By executing the chmod you actually modify these permissions which translate to:

d rwx rwx rwx
dir owner group world
So applying a 'chmod 775 thisfile.txt' would change the permissions to

-rwxrwxr-x
Now the owner and the users of the owning group have read, write, execute access to the file, while the rest of the world can only read and execute the file. The 'd' identifier will signify if an item is a directory. For symbolic links you will see an 'l' instead, and files will have a '-' in its place.

6. I want to backup the files to my sdcard instead of deleting them, how can i do this?

The first thing you want to do, is to create a folder on your sdcard where you can store these apps. I personally like to create a hidden 'appbackup' folder on my sdcard. Lets say now I want to copy and remove the 'HtcWeatherWidget.apk' file, I would do the following:

  1. export PATH=/system/bin:$PATH
  2. mkdir /sdcard/.appbackup
  3. cat /system/app/HtcWeatherWidget.apk > /sdcard/.appbackup/HtcWeatherWidget.apk
  4. rm /system/app/HtcWeatherWidget.apk
What I did above was first, add the bin folder to my path so i can perform a "cat" and "rm" without sourcing its location. I then created a folder in on the sdcard for my apps. I then streamed out the file (a mv wont work here because the /sdcard/ and /system/ are two different mounts, and the file system will complain) to my new folder. Once the streaming is complete, i removed the old file.

7. When trying to move a file, I am getting an error that states "mv cannot unlink '[filename]': Operation not permitted" or something similar

The reason that this is happening is because you are trying to move a file from one partition (i.e. /system) to another partition on the same device (i.e. /sdcard). Because the two different partitions have different mounting points, a move cannot be safely performed. The alternative is to perform what is outlined in step 6

8. Are cronjobs available on the android system?

Crontab is available within the android console, however, when trying to modify the cron, or trying to stream the current cron to a file, the following error is thrown

crontab: unknown uid 0: No such file or directory

It is currently not known if the incredible nand unlock will help remedy this issue, or if the crontab is currently locked out of the rom

[More to come as I come across some FAQs, hope this helps]
 
Just out of curiosity is there a crontab?

the system does have a cron scheduler, but I am unsure exactly how we can modify it right now. If you try and type in 'crontab -l > /sdcard/tempcron' you get an error thrown that you need to have a special sudo permission. Maybe the nand unlock will help this, I am not sure. Sorry.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones