Noob guide: how to start terminal emulator as root. - Android Software/Hacking General [Developers Only]

The way to start the terminal as root is pretty easy.
Open term emulator and then hit the menu button and go into preferences. You need to go down to the bottom where it says something like initial command. Click that and at the end of the export command you see (I think the end is after $PATH) type ;su then hit enter. Now whenever you start TE you get su immediately.
Sent by breaking the sound barrier

Indirect said:
The way to start the terminal as root is pretty easy.
Open term emulator and then hit the menu button and go into preferences. You need to go down to the bottom where it says something like initial command. Click that and at the end of the export command you see (I think the end is after $PATH) type ;su then hit enter. Now whenever you start TE you get su immediately.
...
Click to expand...
Click to collapse
Sorry to re-open this old thread, but can anyone suggest modification to the terminal emulator that may allow it to START as root. Typing "su" afterwards switches the user, however the app DOESN'T start initially as root.

There's a better way to do it. Allow me to elaborate some logic:
In Terminal Emulator, whatever you set as the 'shell command line', basically is nothing more than the command you set as the 'initial shell command'. The key difference is that the 'shell command line' is initiated prior to the 'initial shell command'. Therefore, anything set as 'initial shell command' to automate root access comes secondary to the shell you have already started (through the 'shell command line'), which will cause you opening a shell in a shell and thus having to exit two shells. This is dirty. You could work around that with an 'initial shell command' like "su && exit", but it'll remain to be a dirty solution.
If you want the shell in Terminal Emulator to start as root, then set the following 'shell command line' (personally I prefer bash):
Code:
[SIZE="3"]/system/xbin/su -c "/system/xbin/bash -"[/SIZE]
That way only, Terminal Emulator will actually start your session as root and nothing more but root. When you exit the shell, you exit the one and only shell initiated as root ending your session at once.
Now for the 'initial shell command', which you no longer require to obtain root using the above method, I personally have the following set to keep things consistent and give the shell a nice looking start:
Code:
[SIZE="2"]mkdir -p /data/local/bin && export PATH=/data/local/bin:$PATH && clear && uname -a && echo[/SIZE]
I hope this clarified things a bit.
Albert

bitmaster2000 said:
There's a better way to do it. Allow me to elaborate some logic:
In Terminal Emulator, whatever you set as the 'shell command line', basically is nothing more than the command you set as the 'initial shell command'. The key difference is that the 'shell command line' is initiated prior to the 'initial shell command'. Therefore, anything set as 'initial shell command' to automate root access comes secondary to the shell you have already started (through the 'shell command line'), which will cause you opening a shell in a shell and thus having to exit two shells. This is dirty. You could work around that with an 'initial shell command' like "su && exit", but it'll remain to be a dirty solution.
If you want the shell in Terminal Emulator to start as root, then set the following 'shell command line' (personally I prefer bash):
Code:
[SIZE="3"]/system/xbin/su -c "/system/xbin/bash -"[/SIZE]
That way only, Terminal Emulator will actually start your session as root and nothing more but root. When you exit the shell, you exit the one and only shell initiated as root ending your session at once.
Now for the 'initial shell command', which you no longer require to obtain root using the above method, I personally have the following set to keep things consistent and give the shell a nice looking start (think twice before commenting about the mkdir if you don't like it):
Code:
[SIZE="2"]mkdir -p /data/local/bin && export PATH=/data/local/bin:$PATH && clear && uname -a && echo[/SIZE]
I hope this clarified things a bit.
Albert
Click to expand...
Click to collapse
Thanks a lot, I solved the problem somewhat differently, in a way that may cause some raised eyebrows from people concerned with security. I created a copy of "sh", did a chmod 6755 on it, and set it as the shell. The reason for this is that I don't have superuser installed on my phone.
Off topic, it's all moot now because I managed to drop it again and the LCD detached from the gorilla glass. Happens once every 9 months. I came to XDA to see from my old posts where I bought the screen before.

Initial Command not working in cm11 (s7262).
Entering su in Initial Command in Terminal Emulator Preferences get this result:
Code:
[email protected]:/ $ 8;53R
Entering manually su command get OK., but initial command is not working.
How can I fix this problem?
Thanks.

Related

[Q] ADB shell opens in superuser prompt #

I am trying to update a few things on my G2 and when I go in to adb shell, the prompt opens at the superuser level (the # prompt). Typing exit exits adb shell, it does not take me to the $ prompt. Any thoughts on how I can get to the $ prompt? It has worked fine in the past.
Thanks
Edit: disregard. It appears that I still have the regular adb shell and SU levels, but both have the # prompt. Still curious if anybody knows what causes that, but it seems to be working as it should.
Some custom roms open to a root shell... if you have a stock rom then idk what's going on
Sent from my Droid using Tapatalk
I actually first noticed it when on CM 6.1, but it was still showing the # prompt when I restored to my rooted stock. But, there still is the difference between $ and #, I just need to make sure I keep track of which one I am really using at the moment.
if you use 2nd-init or custom boot image you will get default #

Run a .sh on android.

Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
i think that if you do:
su (to get superuser privileges)
sh your_script.sh
might work....
alternative is to install gscript and put your script in the gscript folder on sdcard....
The console needs to be granted superuser access, then ran as sh script.sh or bash script.sh. afaik at least. Youll probably have to use su like the person above said.
I did the su command. But i still can't open it. All other commands work.
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
krutle said:
I did the su command. But i still can't open it. All other commands work.
Click to expand...
Click to collapse
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
ryocoon said:
Maybe stating the obvious, but did you CHMOD the file to be +X ? Use Root Explorer or chmod at a SU capable command line to change the file mods to allow execute.
Click to expand...
Click to collapse
This should be the solution. X is the execute bit. Basically without that bit set on the file permissions, the OS won't allow that file to be executed as a program.
chmod +x filename.sh
Try running that command in terminal emulator and it should clear things up.
Sent from my Inspire 4G using XDA App
I used that command and it said 'bad mode'.
It still doesn't work.
If you are running the script with this:
Code:
sh script.sh
then the executable bit doesn't need to be set in order to execute it, since you are specifying 'sh'. If you were trying to run it with this:
Code:
./script.sh
then it would require the executable bit to be set.
In an attempt to answer the question, where abouts is your script saved and which user owns it? Just as a quick test on mine, I made a script named test.sh (containing the same lines as yours) on the root of my sd card, cd'd to it and ran sh test.sh, and that seemed to work. That script ended up being owned by 'system'.
As a test to make sure sh is behaving, can you run the following from the terminal:
Code:
sh -c 'echo hello'
EDIT: note that all of the above was run as a regular user, not root.
Yeh it said hello when i did the command you said.
It must be a problem with the file in some way then. Can you run the following from the folder that your script is in and give the output?
Code:
ls -l | grep script.sh
Also, what did you use to make the script - terminal in Android, or adb'd it from your PC etc?
(Aside: just a thought, you probably can't do chmod's on sdcard files if it's formatted to FAT32 since FAT32 doesn't understand Linux permissions)
you can also try an app i found some time ago. SL4A
I made the file with silveredit. Just renamed .txt to .sh.
Btw i got it working with gscript, thanks for everyone's help
Run a reverse tethering shell script
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
nok2626 said:
I am trying to run a reverse tethering shell script using Android terminal Emulator(ATE). The script is saved as tether.unicode.sh under /sbin/. Its content is as follows:
Code:
ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
route add default gw 192.168.137.1 dev usb0
setprop net.dns1 8.8.8.8
setprop "net.grps.http-proxy" ""
I executed the following command in ATE and got error.
Code:
$su
#sh /sbin/tether.unicode.sh
ifconfig: not found
netmask: not found
255.255.0: not found
..
#
Excuse me posting in this very old thread. I hope its better to continue here instead of opening a new thread.
P.S: I am able to execute all this statements by copying and pasting line by line in ATE.
Click to expand...
Click to collapse
it's because android doesn't know about these command, this is a native linux command, try to install busybox, edit your script like this
Code:
busybox ifconfig usb0 192.168.137.2 netmask 255.255.255.0 up
busybox route add default gw 192.168.137.1 dev usb0
busybox setprop net.dns1 8.8.8.8
busybox setprop "net.grps.http-proxy" ""
I hope these helpfull
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
Even though your device is rooted, android environment won't allow applications to execute 'sh' commands.
As android security architecture says, applications run within a secured execution space inside Application Sandbox, sh execution can bypass this security.
If there are any exceptional cases where few devices allow 'sh' execution, well... OEM's needs to be reviewed again.
Answer
Maybe you can try the method that I have specified and check whether it works
http://forum.xda-developers.com/showthread.php?t=2620394
krutle said:
Ok so it sorta worked.
I used the cd command to get to the file.
I used su command.
Then i typed sh script.sh .
Nothing happened, no echo or anything, just a new line with # on it.
What's happening.
Btw thanks for the replies.
Click to expand...
Click to collapse
the script is already run and no need to type the command again, note: some script files can damage your system if run twice
krutle said:
Hi,
I have made a little .sh script as a test.
But when i use terminal emulator to run it i get the 'permission denied' error even though my phone is rooted. Please tell me what to do to run a .sh file on my phone.
Script:
#!/bin/sh
echo hi
Thanks in advance. Any help will be greatly appreciated.
Click to expand...
Click to collapse
You have to put the script somewhere that it has permission to execute from, copy it to /data/local/tmp first. Then in your terminal run each of these commands;
su
cd /data/local/tmp/
chmod 0755 MyScriptName.sh
./MyScriptName.sh

[Mod] Flash Fix For CM7 Via Terminal Emulator

I got this from the cyanogen thunderbolt forums and it worked for me all credit to ktech11 for this
I used the terminal emulator on the phone. If you have ever used Linux this is much easier. I can give you the list of commands:
Download Terminal Emulator Free App From The Market
Type su then enter to allow root
(grant terminal emulator root permissions when busybox comes up)
then type exactly this then hit enter
cd /data/data/com.android.browser/app_plugins/com.adobe.flashplayer/.macromedia/Flash_Player/
then type this
ls -a then hit enter
then type this
ls -l and hit enter & should come up as -rw-rw-rw-
then you type the following to remove the permissions
chmod 000 config.data
then reboot and you are done.
Remember the file paths are case sensitive, so type it exactly as shown. if it worked for you don't forget the thank button.
DJ Eddie One
www.facebook.com/djeddieone
www.twitter.com/djeddieone

[Q] ATT Avail root

I been looking for an ATT Avail root guide since january, I found this page today and I am wondering if anyone has done this successfully?
if you google "root att avail" it is the top search result link right now and it is at a site called android police.
here is a copy/paste of the article:
New root methods show up all the time, so it's not a huge deal that a rather unknown phone on AT&T is now rooted. So why are we posting about it? Because the root method used is, well... interesting.
It was uncovered by our own Justin Case from TeamAndIRC, and while a big part of the process will look very familiar to some of you, there is one step that induces a wait, what? moment.
Before you get started throwing commands at the little guy, though, you need to grab this file. After that, commence command throwing.
adb shell rm -r /data/local/logs (if this command gives you an error, do not worry, it is precautionary)
adb shell mkdir /data/local/logs
adb shell ln -s /data/local.prop /data/local/logs/loglast1.tar.gz
Dial *983*7668# on your phone. This does a few things, it mounts /system as writable on boot, and creates the loglast1.tar.gz.
Wait about 10 seconds, then continue.
adb shell echo 'ro.kernel.qemu=1' > /data/local.prop (Nod to Rosenberg here)
adb reboot
Once the phone reboots, continue
adb push su /system/xbin/su
adb shell chown 0.0 /system/xbin/su
adb shell chmod 06755 /system/xbin/su
adb shell rm -r /data/local/logs
adb shell rm /data/local.prop
adb shell rm /data/property/persist.sys.ztelog.enable
adb shell rm -r /data/local/rwsystag
Head into the Market and grab the Superuser app.
Done.
Catch that bold part? Looks like someone at ZTE dropped the ball and left seventy-nine developer codes in the retail version of the device. Oops.
Of course, their mistake is your gain. Hell, there's even a code to disable Carrier IQ: *983*24737#. Enter the code, ???, profit.
While this is definitely an unusual and unique find, it's also quite dangerous. This means that any app can mount the system as writable and, from there, basically control everything. As a result, JCase contacted ZTE to let them know of their oversight.
Click to expand...
Click to collapse
if someone could let me know if this is legit, that would be a fantasticism.
yes that is legit.
see my thread:
http://forum.xda-developers.com/showthread.php?t=1437032
Jcase broke it, the loon created a batch file to make it easier
http://forum.xda-developers.com/showpost.php?p=21627136&postcount=37
thats the last version of the batch file
Cool, thanks, for some reason I cannot connect to my avail via usb, I have it in developer mode and unknown sources checked, I ran adb devices command and it does not find my phone and when I try to run or debug in eclipse it does not find my phone there either.
I used it, and now have root. I wish all phones were this easy to root.

help with Acer a200 auto root batch file...

hello,
I am trying to set up a simple batch/ script to "automate" the root process.
I am using the mempodroid exploit to gain root access. The problem is this:
I am using this in my script,
adb shell /data/local/mempodroid 0xd9f0 0xaf47 sh
when I use this I get a return of [email protected]:/ # and the cmd window locks up and I can not enter anything.
however if I manually enter this,
adb shell
I get back [email protected]:/ $
and then I enter,
/data/local/mempodroid 0xd9f0 0xaf47 sh
I get back [email protected]:/ #
and that is what I want.
I don't know how to automate it in a working way. Any thoughts?
finished this up and have a working simpleRoot! check it out at acertabletforums.com
and now i have compiled ClockWorkMod for A200 as well! check it out at the same spot!

Categories

Resources