Useful Commands in Terminal Emulator - Galaxy Ace S5830 General

Hi guys!
I created this thread mainly because many useful things can be done in Terminal emulator. I will show you some simple commands which are useful.
Very useful if you don't have Root explorer when you need it.
Make sure you take a Nandroid backup before you try out just in case you can restore when you do something wrong!
You can get terminal Emulator from here: https://play.google.com/store/apps/details?id=jackpal.androidterm&hl=en
Note: Most commands need root. So type su and press enter and grant superuser permissions to Terminal Emulator!
First type this command before using any of the commands below just in case(needs root)
Code:
su
Some useful commands:
Turning device off (Turns your device off very fast!! ):
Code:
poweroff
Rebooting:
Code:
reboot
Rebooting to Recovery
Code:
reboot recovery
Rebooting to download mode:
Code:
reboot download
Forcing Most Apps to install to SDcard(Root needed with Terminal Emulator, no need root with ADB):
Code:
pm setInstallLocation 2
Alternatively, you can type 0 at the end instead of 2 for Auto location install mode or 1 for Internal memory install mode
To check what the current install location is:
Code:
pm getInstallLocation
Mounting R/W in system(Use with caution)
Code:
mount -o rw,remount -t /system
If above one doesnt work, try this.
Code:
mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system
Unmounting R/W in system.
Code:
mount -o ro,remount -t /system
If above code doesn't work, try this
Code:
mount -o ro,remount -t ext3 /dev/block/mmcblk1p21 /system
Moving files from sdcard to system (Use after mounting R/W):
Code:
busybox cp /sdcard/<path> /system/<path>
Example: busybox cp /sdcard/demo/framework-res.apk /system/framework/
Changing file permissions to rw-r--r-- (Use after mounting R/W):
Code:
chmod 644 <path>
Example 1: chmod 644 /system/app/mms.apk
Example 2: chmod 644 /system/app/*.apk (This command changes the file permission of all apps in the folder to rw-r--r--)
Changing the current directory:
Code:
cd <path>
Example: cd /sdcard
Listing all the files and folders under the current directory:
Code:
ls
If you want to view all the files and folders in your sdcard, type:
cd /sdcard
ls
Making a new folder:
Code:
mkdir <path>
Example: mkdir /sdcard/newfolder
Removing files (For System files, Use after mounting R/W)
Code:
rm <path>
Example: rm /system/app/demoapp.apk
Removing Folders:
Code:
rmdir <path>
Get info of your build.prop values
Code:
getprop
That's all for now. I will add a few more later!
If you have any more new commands or if I have given an improper command, feel free to post it in the thread
Thanks for reading.

Have you any idea on why if I were to enter pm set-install-location 2(SD card), the next line would be "Killed"?

UserU said:
Have you any idea on why if I were to enter pm set-install-location 2(SD card), the next line would be "Killed"?
Click to expand...
Click to collapse
I don't understand your question...
Anyways...Thanks for reminding me of that command!

system.img said:
I don't understand your question...
Anyways...Thanks for reminding me of that command!
Click to expand...
Click to collapse
No problem. This is the output from the Terminal Emulator. The bold command changes the default install dir to the SD card:
u0 [email protected]:/ $ pm set-install-location 2
Killed
137|u0 [email protected]:/ $
Click to expand...
Click to collapse

UserU said:
No problem. This is the output from the Terminal Emulator. The bold command changes the default install dir to the SD card:
Click to expand...
Click to collapse
I never got that problem on adb.
Let me see....

This:
mount -o remount rw system
Is much easier than the previous one to mount readwrite.
Sent from my GT-P7300 using xda app-developers app

panpjp said:
This:
mount -o remount rw system
Is much easier than the previous one to mount readwrite.
Sent from my GT-P7300 using xda app-developers app
Click to expand...
Click to collapse
Isnt it /system?
ok...will add to op.
Thanks.

system.img said:
Isnt it /system?
ok...will add to op.
Thanks.
Click to expand...
Click to collapse
Not necessary for it to be /system
Sent from my Desire using xda app-developers app

panpjp said:
Not necessary for it to be /system
Sent from my Desire using xda app-developers app
Click to expand...
Click to collapse
Ok....

system.img said:
I never got that problem on adb.
Let me see....
Click to expand...
Click to collapse
Here's a thread which shed some light on the similar issue.
http://forum.xda-developers.com/showthread.php?t=1495423

UserU said:
Here's a thread which shed some light on the similar issue.
http://forum.xda-developers.com/showthread.php?t=1495423
Click to expand...
Click to collapse
I got it.
It needs root.
So type
su
pm set-install-location 2
Then you are done!

wow thanks !!

Bassesh said:
wow thanks !!
Click to expand...
Click to collapse
Welcome!

Useful
A question: once i tried to type
bootanimation
Click to expand...
Click to collapse
The boot animation started but..i couldn't stop it!! I could "use" the phone (i caught 4 or 5 screens) but the only thing i saw was the bootanimation.. i had to pull the battery off and restart my ace.. any solution??

Toni5830 said:
Useful
A question: once i tried to type
The boot animation started but..i couldn't stop it!! I could "use" the phone (i caught 4 or 5 screens) but the only thing i saw was the bootanimation.. i had to pull the battery off and restart my ace.. any solution??
Click to expand...
Click to collapse
That is the use of the bootanimation command. You can stop it either by pulling battery or closing terminal emulator!
But what I did to stop it was to rotate my phone to landscape and somehow close terminal emulator.
But in ADB it is easier to stop using exit command.

how to get info about /system memory and /data memory ?

rajxelton said:
how to get info about /system memory and /data memory ?
Click to expand...
Click to collapse
What info do you exactly want? Free Space, Partition Size or Used space?

system.img said:
What info do you exactly want? Free Space, Partition Size or Used space?
Click to expand...
Click to collapse
partition size. well can you tell me for all.

Anyone know a command to trigger media scanner?

Thanks for the commands. Quite new to all of this and these will help me understand things a little better

Related

[Q] How to make Android a read and write system

How can I do this in terminal emulator
iloveandroid said:
How can I do this in terminal emulator
Click to expand...
Click to collapse
adb remount
http://www.pocketmagic.net/?p=757
^tells you how
you pretty much just type "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3", then "chmod 777 /system".
iloveandroid said:
How can I do this in terminal emulator
Click to expand...
Click to collapse
I attached a file called sys. push this file to the bin directory and give it permissions then you can just mount the system by typing "sys -rw" to mount read and write and to mount read only you type "sys -ro"
to push the file and give it permissions :
Code:
adb push sys /system/xbin
adb shell chmod 775 /system/xbin/sys
I like the script because its easier to remember than the long command.
If you want to edit the script just open it in notepad and change what you like.
I got that script from Bugless Beast By Pete and modified it to display my rom info.
Remove the ".txt" from the script I had to put that to be able to upload it.

[SCRIPT] Remove Cell Standby Service (No Effect on Battery Life!)

WARNING: I've added this to my script and for some reason it has an adverse effect on the "n" button and Lock Screen if used BEFORE you complete the SetupWizard !!!
WARNING: Again BE WARNED if you do this mod before you finish the setup wizard you will loose the functionality of your "n" button and Lock Screen !!!
I have a feeling poster before me copied and pasted this from somewhere because notice how in his first sentence he says "Phone.apk and TelephonyProvider.apk" but then his script says "Mms.apk"....what happened to Phone.apk because there is no Mms.apk in the system folder on any Nook I have. So below is the corrected script and also this entire process in done in dos instead of in adb;
Code:
adb shell mount -o remount,rw /dev/block/mmcblk0p5 /system
adb shell mv /system/app/Phone.apk /system/app/Phone.OLD
adb shell mv /system/app/TelephonyProvider.apk /system/app/TelephonyProvider.OLD
adb reboot
There is no adverse effect from doing this & it's confirmed after while in NookTools there is no Cell Standy service running.
Download [REMOVAL]
Want to undo this process?
Code:
adb shell mount -o remount,rw /dev/block/mmcblk0p5 /system
adb shell mv /system/app/Phone.OLD /system/app/Phone.apk
adb shell mv /system/app/TelephonyProvider.OLD /system/app/TelephonyProvider.apk
adb reboot
Download [UNDO REMOVAL]
thanks, just got my NC yesterday, and already updated/rooted + done this hack
xmas_spirit said:
thanks, just got my NC yesterday, and already updated/rooted + done this hack
Click to expand...
Click to collapse
Run my script too from the other post?
xboxexpert said:
Run my script too from the other post?
Click to expand...
Click to collapse
No, I just manually entered commands in adb shell
xboxexpert said:
I have a feeling poster before me copied and pasted this from somewhere because notice how in his first sentence he says "Phone.apk and TelephonyProvider.apk" but then his script says "Mms.apk"....what happened to Phone.apk because there is no Mms.apk in the system folder
Click to expand...
Click to collapse
90% of the internet are sites posting info from other sites. Be glad he didn't slap on some ads.
I'm new here, but trying to learn.
Your code is:
adb shell mount -o remount,rw /dev/block/mmcblk0p5 /system
adb shell mv /system/app/Phone.apk /system/app/Phone.OLD
adb shell mv /system/app/TelephonyProvider.apk /system/app/TelephonyProvider.OLD
adb reboot
would it make sense to add:
adb shell mount -o remount,ro /dev/block/mmcblk0p5 /system
before the reboot? Or does that get done automatically upon reboot? I assume it is bad to leave it rw and not reset it to ro?
Thanks for this, I ran 'most' of your other script.
Auto-nooter, your script, adw launcher and it is coming along nicely. Still debating remapping the volume keys to back/menu...
DC_Rob said:
I'm new here, but trying to learn.
Your code is:
adb shell mount -o remount,rw /dev/block/mmcblk0p5 /system
adb shell mv /system/app/Phone.apk /system/app/Phone.OLD
adb shell mv /system/app/TelephonyProvider.apk /system/app/TelephonyProvider.OLD
adb reboot
would it make sense to add:
adb shell mount -o remount,ro /dev/block/mmcblk0p5 /system
before the reboot? Or does that get done automatically upon reboot? I assume it is bad to leave it rw and not reset it to ro?
Thanks for this, I ran 'most' of your other script.
Auto-nooter, your script, adw launcher and it is coming along nicely. Still debating remapping the volume keys to back/menu...
Click to expand...
Click to collapse
yes, the system partition goes back to RO after a reboot
Can this be done using terminal emulator
Sent from my PC36100 using XDA App
Ben74 said:
yes, the system partition goes back to RO after a reboot
Click to expand...
Click to collapse
Great, now I know. I write code for a living so, I try to be tidy....
Thanks
worked perfectly, thanks.......
midnightmaraude said:
Can this be done using terminal emulator
Sent from my PC36100 using XDA App
Click to expand...
Click to collapse
Just use Root Explorer; rename those two files to anything else and reboot. Really, you could just remove them, renaming is just a precaution.
Thanks for this, makes the nook even better!
Mike
sent from my nookcolor using the xda app
Just to play devil's advocate, does anyone know if it's really improving battery life, rather than just no longer reporting cell standby under battery use details?
wvcachi said:
Just to play devil's advocate, does anyone know if it's really improving battery life, rather than just no longer reporting cell standby under battery use details?
Click to expand...
Click to collapse
I wondered that, but I also have no reason to run unused services so it can't hurt.
wvcachi said:
Just to play devil's advocate, does anyone know if it's really improving battery life, rather than just no longer reporting cell standby under battery use details?
Click to expand...
Click to collapse
I've been playing angry birds for 30 minutes and only lost 4% battery life. Seems to be awesome.
ummmmmm where is the script
ADB commands are only in OP lol
Therefore you need adb
No such file or directory?
I keep getting an error message stating the following:
"failed on '/system/app/phone.apk' - No such file or directory"
If I navigate to that file using Astro File Manager I can see the files, so I can't figure out what I'm missing here.
Salt72 said:
I keep getting an error message stating the following:
"failed on '/system/app/phone.apk' - No such file or directory"
If I navigate to that file using Astro File Manager I can see the files, so I can't figure out what I'm missing here.
Click to expand...
Click to collapse
Try capitalizing the file names.
Not to beat a dead horse, but this can easily be done in Root Explorer. All you're doing is renaming two files.
Not to be a cheapskate, but is there a free version of Root Explorer or a similar app that will do the same?
No
try Astro or Linda, thats free but ads supported

[EXPANDSD] Join your external SD with internal SD!

WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
I tried gscript and init.d, but doesn't seem to be working
woohoo a great dev has come. glad you got here mate! love your work on Desire section.
harrynghiem said:
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
Click to expand...
Click to collapse
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
dexterdave said:
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
Click to expand...
Click to collapse
Does it work for you?
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
problems when connecting phone to pc
hi,
tried the "mount --bind" in order to try your script.
works fine. the directory contents is shared between the 2 path's,
but i have a problem when i connect the phone to a pc.
when i try to disconnect, the sdcard and external_sd are not
available anymore until i reboot the phone
note: the commands that i have executed are:
Code:
mkdir /mnt/sdcard/external_sd/foo
echo "test" > /mnt/sdcard/external_sd/foo/test
mkdir /mnt/sdcard/foo
mount --bind /mnt/sdcard/external_sd/foo /mnt/sdcard/foo
Can this script be placed in init.d folder for autorun at boot?
Edit: sorry, already answered above: no, it cannot.
Sent from my GT-P1000 using Tapatalk
Seems abandoned by @ownhere
Sent from my GT-I9100
Idan73 said:
Seems abandoned by @ownhere
Sent from my GT-I9100
Click to expand...
Click to collapse
too bad, it could be very useful..
TheFirstBen said:
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
Click to expand...
Click to collapse
got the same problem please help
How to use?
ownhere said:
WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Click to expand...
Click to collapse
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
dawabz94 said:
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
Click to expand...
Click to collapse
Then why not share with us please !
Let us know how you did
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Chairmansaab said:
Then why not share with us please !
Let us know how you did
Click to expand...
Click to collapse
Hi,
it's very easy indeed, once you got the point.
I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.
Also I like simple implementation so my script is the strict minimum needed to mount necessary folders
I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/
I suggest you do the test on a dummy folder before applying on a real folder.
So start by creating a folder called /sdcard/dummy
Do it the way you want , I do it with an "adb shell" session
Code:
cd /sdcard
mkdir dummy
Then copy some files in it (photos for examples)
Code:
cd /sdcard
cd DCIM
cd Camera
cp `ls -1 |tail -5` /sdcard/dummy
From now on, we consider we want to move transparently /sdcard/dummy to the external SD
1. move the folder to the external sd
CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
Standard samsung sdcard mount is /sdcard/external_sd
The path might be different according to your brand and rom
Moving the folder code
Code:
cd /sdcard
mv dummy /mnt/emmc/
2. Create the mount point in the indernal SD
Code:
cd /sdcard
mkdir dummy
3.a Check the mount is successful by manually doing it
Code:
mount --bind /mnt/emmc/dummy /sdcard/dummy
3.b Check you see exactly the same thing on both folders
Both commands should return exactly the same output
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
If everything is fine, then you're good to go
4. Automate mount at boot time
Create a script in /etc/init.d to automate the mount at boot time
I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way
So basically you would go root,remount /system in read/write mode and create the file
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
vi 90binds
Insert following lines, save and exit
Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)
Code:
#!/system/bin/sh
sleep 60
mount --bind /mnt/emmc/dummy /sdcard/dummy
Change owner and permissions, flush disk cache and remount /system in read only
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
chown root:shell
chmod 6755 90binds
sync
mount -o remount,ro /dev/block/mmcblk0p9 /system
To check, run
Code:
su
cd /etc/init.d
ls -l 90binds
The output should look like this :
Code:
-rwsr-sr-x 1 root shell [I]0 MMM D HH:MM[/I] 90binds
5. Now you can reboot and check - after reboot - that the mount is done
Both commands should return exactly the same output (always ran in an "adb shell" session)
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
6. Now you're good to move other folders
Basically, you move the folder to external SD
Create the mount point on the internal SD
Append the mount command in the 90binds script
And that's it
Hope this helps
---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------
benc88 said:
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Click to expand...
Click to collapse
Just posted
Take time to read and understand the idea

(urgent) How to give write permission for system using terminal emulator?

What the command?
I need it quick please.
First you need root acces on your phone.
Then type this in your terminal:
Code:
su
mount -o rw,remount,rw /system
Myst3rion09 said:
First you need root acces on your phone.
Then type this in your terminal:
Code:
su
mount -o rw,remount,rw /system
Click to expand...
Click to collapse
thanks bro.
almost forgot everything on terminal

"rm -r" a file on root with terminal

Hi, does anyone know how to delete a file on root with terminal, as rm -r returns screenshotted error.
kriki200 said:
Hi, does anyone know how to delete a file on root with terminal, as rm -r returns screenshotted error.
Click to expand...
Click to collapse
Did you execute this command as root ? If not enter "su" then enter your command. (Make sure you hit "Allow" when the prompt for you to allow root accès to the shell appears)
And maybe it sounds stupid but try chmod commands if your command doesn't work.
I'm not an expert with android terminal so if the problem is persistent you can try this with a root explorer.
Hope all of this helped
Have a good day
kriki200 said:
Hi, does anyone know how to delete a file on root with terminal, as rm -r returns screenshotted error.
Click to expand...
Click to collapse
The partitition you want to deal with must be mounted as READ-WRITE before.
Raiz said:
Did you execute this command as root ? If not enter "su" then enter your command. (Make sure you hit "Allow" when the prompt for you to allow root accès to the shell appears)
And maybe it sounds stupid but try chmod commands if your command doesn't work.
I'm not an expert with android terminal so if the problem is persistent you can try this with a root explorer.
Hope all of this helped
Have a good day
Click to expand...
Click to collapse
I did, kinda don't want to change permissions... same.
jwoegerbauer said:
The partitition you want to deal with must be mounted as READ-WRITE before.
Click to expand...
Click to collapse
How do I do and undo that, will it change any file permissions?
Example:
Code:
su
cd /
mount -o rw,remount -t auto /system
jwoegerbauer said:
Example:
Click to expand...
Click to collapse
Thank you, it worked, do you know how to undo it, the below command deosn't seem to work and do you know what the "auto" is for in the command?
Code:
mount -o ro,remount -t auto /system

Categories

Resources