[PROGRAM] nano editor for android - G1 Android Development

For the vi haters!!!
Attached you will find a static compiled version of the nano editor (http://www.nano-editor.org/).
To install:
Code:
adb remount
adb push nano /system/bin/
adb shell
chmod 755 /system/bin/nano
chown root.shell /system/bin/nano
That's it.
Works fine in androids terminal (tested in CM-mod 4.0.4).
Seems not to work in adb shell due to the Ctrl key not working correctly.
Should work over SSH or telnet (untested).
Enjoy.

Thanks for this, I never liked vi much.

awesome
This is awesome ... Ima gonna test ...
maybe throw it in my ROM's.
Sweet. Thanks a ton!
~enom~

I am not that familiar with linux and other unix operating systems and have ran into vi on different shells and whatnot and don't like it. I posted in the apps section about a decent text editor but never found one.
Basically, I have used vi and don't like it. I am just not familiar enough with linux to have used nano, how do I go about using this?
I assume I would be safe to google it and they way it is normally ran via linux would work, if not though, what is different?

It's a lot like Dos edit but better, just look at the GUI.

Well to me anything is better then vi, I will surely give it a try.
Thanks for your time and effort.

bash-3.2# vi /www/forum/post/dream/dream-android-devel/post4482405/reply7.txt
i Finally, a decent, usable commandline text editor for the android.
I really was getting tired of the old shell, now we have BASH. I was getting tired of vi, now we have nano. :wq!
bash-3.2# cat ~/.signature

Doesn't work on Milestone; it needs a terminfo file, fails to find it in /etc, bails out.
Elsewhere people suggested setting TERMINFO and TERM environmental vars before running nano, but that won't help, as "find / -name terminfo" shows there's no such file in Milestone userland.
Hm. A little thinking helps:
Code:
adb push /etc/terminfo/l/linux /data/local/etc/terminfo/l/linux
and then, nano happily starts after
Code:
export TERMINFO=/data/local/etc/terminfo
export TERM=linux
(I recommend installing busybox first, if you haven't done that yet.)

Cant use it.
Keeps saying:
Error opening terminal: unknown

I tried this program a while back ago (hefty for android, but still) since I like it better than vi (I'm not THAT spartan). However, if I remember right, I couldn't figure out how to (^X) or (^anything), and that is pretty important, right?
Do we have a sort of list of commands that were modified for the Dream's keyboard?

jubeh said:
I tried this program a while back ago (hefty for android, but still) since I like it better than vi (I'm not THAT spartan). However, if I remember right, I couldn't figure out how to (^X) or (^anything), and that is pretty important, right?
Do we have a sort of list of commands that were modified for the Dream's keyboard?
Click to expand...
Click to collapse
Depends on your terminal emulator. In ConnectBot, press the trackball once for CTRL (twice for ESC). The key is sticky, so you don't have to hold it down.

Guess it doesnt work for wg kernel.
tried to make it work but doesnt =/

Macrophage001 said:
Cant use it.
Keeps saying:
Error opening terminal: unknown
Click to expand...
Click to collapse
Use the export commands in the post above yours. Update the terminfo one to wherever you have terminfo files. On SuperD they are already in /etc/terminfo. I think Cyanogen has them there as well. If you don't have them, you might have to put some in /system/sd from a Linux system.
As I use bash 99% of the time, I just put the commands in my bash_profile so they are already setup when I start the shell. Thanks to the OP. I was thinking I wanted nano just the other day. vi is powerful, but cryptic as hell and sometimes I just don't need the extra power.

If you are a termux user and want to install a nano or vi or any other binaries of termux in Andriod su mode. Here is the link to Termux superuser.
Give it a star if it was helpful !!!

Related

Terminal commands

Is there a list somewhere for the commands because i tired to do the "dir" to get a list of files in the folder but it work. (on terminal or adb shell).
* Also what is the best file manager? Is there anything that has a password so that other people cant get into it?
'ls' is the unix command to list contents in a folder
Ok thanks. just been a long time since i messed with Linux shells i guess i should get my books out and start reading again
Android's Linux commands
although he got the wrong command for list files, he raises a good point, the android linux is far from having all commands other linux system have - does anyone have these documented somewhere? what it has and what it doesn't have?
eladkatz said:
although he got the wrong command for list files, he raises a good point, the android linux is far from having all commands other linux system have - does anyone have these documented somewhere? what it has and what it doesn't have?
Click to expand...
Click to collapse
if you are running jf 1.31 then you have busybox installed.. google busybox and you will find out all the terminal commands you can run from your phone terminal or over adb shell.....
eladkatz said:
although he got the wrong command for list files, he raises a good point, the android linux is far from having all commands other linux system have - does anyone have these documented somewhere? what it has and what it doesn't have?
Click to expand...
Click to collapse
ls /system/bin
ls /system/xbin
ls /system/xbin/bb
that should give you a fairly complete listing of the commands available.
korndub said:
if you are running jf 1.31 then you have busybox installed.. google busybox and you will find out all the terminal commands you can run from your phone terminal or over adb shell.....
Click to expand...
Click to collapse
I just noticed this myself. I need to remove a symbolic link and recreate it by "unlink" and "rm" dont' seem to work. Is there a busybox command that will do it?
A quick google search brought up this annotated list for those new to these commands:
http://www.busybox.net/downloads/BusyBox.html
JF Thanks for that, I was looking for that folder earlier and could not find it for the life of me. Blame it on drowsiness ...or just plain not wanting to be at work.
That list is only valid for modified Android. Stock Android runs toolbox, which has a much neutered list. Aside from JF's method, you can also look at the tpolbox links in update-script of an official update.zip
Hmmm.. does this mean overclocking is possible? Not that we "REALLY" need it right now but.....
adjtimex [-q] [-o offset] [-f frequency] [-p timeconstant] [-t tick] Read and optionally set system timebase parameters. See adjtimex(2).
Options:
-q Quiet
-o offset Time offset, microseconds
-f frequency Frequency adjust, integer kernel units (65536 is 1ppm)
(positive values make clock run faster)
-t tick Microseconds per tick, usually 10000
-p timeconstant
If you read any manpages on the command you would see that it's for correcting system clock drift.
If you type in "busybox" (without quotes) it will give you the list of commands. Enter "<enter command here> -d" for a description of the command you entered. Hope this helps...
"busybox --help" anybody? i thought the bb we had on our androids was not supposed to be the full busybox?
File manager
The Best file manager i found
https://play.google.com/store/apps/...lt#?t=W251bGwsMSwxLDEsImNvbS5yaG1zb2Z0LmZtIl0.
ha root explorer as well...
ca use app lock to protect it!

[HOWTO] Guide to running ADB under Fedora 11 (and equivalent distros)

Ok, I have fedora 11 installed on most of my computers, since i love this distro to death. My big thing was trying to get adb to work. This is my guide to get it to work, for now.
First things first. Navigate to /etc/udev/rules.d as root. Create a rules file called 50-android.rules (touch 50-android.rules). NOTE: You are better off looking at the contents and picking a rules number set other than what is listed. Sometimes udev is picky. For the newbies, so if any rules start with '50', then change the number by one or two, like 51 or 52. Paste this into the file:
Code:
SUBSYSTEM=="usb",ATTRS{idVendor}=="0bb4",SYMLINK+="android_adb",MODE="0666"
Make sure you use ATTRS, not ATTR or SYSFS, since this is a newer updated udev system.
After that, run udevadm control --reload-rules to reload your rules files. Now just run ./adb devices as root to make sure it recognized your HTC dream. I am working on this fix right now so you don't need to be root, keep patient. Now you can adb shell into your device either as root OR normal user, just as long as you start the server as root. This is a permissions problem, and hopefully I can fix this and/or find a fix soon.
I wrote this because i searched high and low through google, and only found a few good parts as far as a fix. Hopefully this helps a few people out there.
Just wondering if this has helped anyone. If not, delete this thread or do whatever with it....
I have adb on my eeepc 900 with f11 I believe this method works too as well. although it says it has been tested with ubuntu, it works pretty well with f11.
http://www.talkandroid.com/android-sdk-install-guide/
Installing The Android SDK
First you will need to download the Android SDK pack .zip archive, once downloaded find a suitable installation location on your machine and extract the zipped files.
Please note: This installation location will be referred to as $SDK_ROOT from now on through this tutorial
Alternatively you can add /tools to your root path which will prevent the need to specify the full path to the tools directory along with enabling you to run Android Debug Bridge (adb) along with other command line tools.
To add /tools:
Linux
1. Edit the ~/.bash_profile or ~/.bashrc files looking for a line that sets the PATH variable.
2. Add the full path location to your $SDK_ROOT/tools location for the PATH variable.
3. If no PATH line exists you can add the line by typing the following:
4. export PATH=${PATH}:<path to your $SDK_ROOT/tools>
Click to expand...
Click to collapse
It helped me, since the creation of the file my OpenSuSE 11.0 recognizes the phone perfectly
Thanks a lot for your hint.
thanks it helped me. ill be looking forward to getting it to work without root
just use sudo instead
Just a heads up for user's using Ubuntu 9.10, this isn't needed. I connected my G1 to it and ran ADB with no adjustments to udev or anything else.
Pretty much it works out of the box.
Here is my version
download the .tgz file from googlecode
http://developer.android.com/sdk/index.html
sudo tar -xzvf android-sdk_r3-linux.tgz
Click to expand...
Click to collapse
Code:
sudo gedit ~/.bash_profile
heres my bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH=$PATH:/android-sdk-linux/tools
Click to expand...
Click to collapse
logout
login
connect android g1 device via usb to pc
open a terminal
Code:
adb devices
if you cant get a device try it with superuser.
Don't you think that this is all just a little bit excessive?
To make it work in F11, just do this;
Download SDK, extract.
To use, type:
/path/to/sdk/tools/adb
Another option is to edit the /etc/profile and add
PATH=$PATH:/<Path to android-sdk>/tools
This option will allow any user to use the adb tools when logged in or if you
su -
into another user
I wrote a short guide as well for Windows and Ubuntu. Might help others.
Unfortunately, as anyone with a passing acquaintence with ADB knows, the scrolling issue can be a killer. I swear the other day I pressed "up" twice and it composed "rm /sdcard/rootfs.img /sdcard/system.ext2" and executed it. We run Android on our SD's btw.. Was not cool. Instead, I use ADB via telnet and it works beautifully. Here's how:
Code:
adb shell telnetd &
adb forward tcp:9999 tcp:23
Now type this: "telnet localhost 9999"
Enter "root" and hit enter
Finally update PATH: "export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin"
Okay, so 4 lines to enter and you have a "regular, sane" shell connection to the phone and you can actually scroll through history and text without it jumbling the text and executing random code. Enjoy.
lbcoder said:
Don't you think that this is all just a little bit excessive?
To make it work in F11, just do this;
Download SDK, extract.
To use, type:
/path/to/sdk/tools/adb
Click to expand...
Click to collapse
that works too as well but i would rather open up a terminal and type
sudo adb devices
sensimila said:
that works too as well but i would rather open up a terminal and type
sudo adb devices
Click to expand...
Click to collapse
WHY would you want to make it *MORE COMPLICATED*??
There is NO NEED for root.
/path/to/adb ...
THATS ALL.
This is kind of funny... i wrote this because i had trouble with it, so i am just sharing my fix...
In case this is interesting to someone:
The fix mentioned in the first post has to be applied to open SuSE x86 and x64 edition to make the G1 work. The external device works without it, but not the adb device.
Thanks again!
Just wanted to come and post that this does work with OpenSUSE 11.2 x86. Did this hoping to get adb to work with my LG Ally and it does. Thanks!
(Still) works for me on 64bit SUSE 11.4.
Before adding this file, I could not access my device with adb, received permissions errors.
Added this file, and I can shell into my device.
Permissions on adb itself was not the problem, it was access to the device when udev found it.
[edit]Actually used the lines from http://developer.android.com/guide/developing/device.html[/edit]

[GUIDE] Full bash shell with nano, tab completion, and color over ssh and adb

Posting this here because I think it will be of more interest to the tinkerers/devs than general users, if not, feel free to move it. I cobbled all of this together from various places on the web, but I think the credit for the binaries goes to Paul @ MoDaCo.
Nandroid before going any further!
Files you'll need:
For WiFi and CDMA SSH access - QuickSSHD (Download this from the Market. $1.50). I'm just going to assume if you're still reading, you know what this is for and how to use it. It's braindead simple. I think dropbear can be installed and configured manually, but for the $1.50...meh.
adb for tethered access.
The rest are zipped up here: terminfo, nano, bash, profile**
Unzip bashnano.zip onto your SDCard.
adb remount
From adb shell:
Install Terminfo:
cp -r /sdcard/terminfo /system/etc
Setup Bash:
cp /sdcard/bash /system/bin/bash_new
mv /system/bin/sh /system/bin/sh.old
ln -s /system/bin/bash_new /system/bin/sh
mv /sdcard/profile /sdcard/bash_profile (Thanks to jjvcuyler for finding adb bash profile location.)
Setup Nano:
cp /sdcard/nano /system/bin
I'm not sure if this setup will have any impact on sh scripts being used in the various ROMs, so use this at your own risk. I think it would kick ass to see this type of bash functionality baked into the custom ROMs.
If anybody would like to make this a flashable.zip, please do. I don't know how to do that yet.
Anyway, hope y'all find it useful.
**profile reflects a few personal choices for aliases and colors, but you can edit to your personal taste.
So I just did this. Is there any way to get this functionality into a local terminal?
Also I was able to do everything from a local terminal without adb. Just do the following first:
su
remount rw
Click to expand...
Click to collapse
adb shell fires off bash, but it doesn't read profile from /etc. It's going to be a simple matter of figuring out where bash is looking for it. I just haven't found that out yet.
How do you like having full bash capabilities on EVO? Arrows/tab completion/color prompts, etc...
J
jmxp69 said:
adb shell fires off bash, but it doesn't read profile from /etc. It's going to be a simple matter of figuring out where bash is looking for it. I just haven't found that out yet.
How do you like having full bash capabilities on EVO? Arrows/tab completion/color prompts, etc...
J
Click to expand...
Click to collapse
Copy profile to /sdcard/bash_profile
jjvcuyler said:
Copy profile to /sdcard/bash_profile
Click to expand...
Click to collapse
WooT! There it is. I'll update the OP. Thanks jjvcuyler.
Edit: /sdcard/bash_profile works for ssh and adb. OP updated to reflect the change.
jmxp69 said:
Posting this here because I think it will be of more interest to the tinkerers/devs than general users, if not, feel free to move it. I cobbled all of this together from various places on the web, but I think the credit for the binaries goes to Paul @ MoDaCo.
Nandroid before going any further!
Files you'll need:
For WiFi and CDMA SSH access - QuickSSHD (Download this from the Market. $1.50). I'm just going to assume if you're still reading, you know what this is for and how to use it. It's braindead simple. I think dropbear can be installed and configured manually, but for the $1.50...meh.
adb for tethered access.
The rest are zipped up here[/URL]: terminfo.zip, nano, bash, profile**
Unzip bashnano.zip onto your SDCard.
Unzip terminfo.zip (from inside bashnano.zip) onto your SDCard.
adb remount
From adb shell:
Install Terminfo:
cp -r /sdcard/terminfo /system/etc
Setup Bash:
cp /sdcard/bash /system/bin/bash_new
mv /system/bin/sh /system/bin/sh.old
ln -s /system/bin/bash_new /system/bin/sh
mv /sdcard/profile /sdcard/bash_profile (Thanks to jjvcuyler for finding adb bash profile location.)
Setup Nano:
cp /sdcard/nano /system/bin
I'm not sure if this setup will have any impact on sh scripts being used in the various ROMs, so use this at your own risk. I think it would kick ass to see this type of bash functionality baked into the custom ROMs.
If anybody would like to make this a flashable.zip, please do. I don't know how to do that yet.
Anyway, hope y'all find it useful.
**profile reflects a few personal choices for aliases and colors, but you can edit to your personal taste.
Click to expand...
Click to collapse
there is no terminfo.zip and there is nothing in terminfo directory from within the original zip... help?
Sorry, I missed the recurse flag zipping the terminfo directory. It's fixed now. Go ahead and re-download.
Here's a link for just terminfo.zip
J
I modified the bash_profile to get rid of the colors since the window's cmd.exe doesnt support ansi colors. probably a better way to do this but it works for me.
also found this useful for setting PS1 to my liking http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
jmxp69 said:
adb shell fires off bash, but it doesn't read profile from /etc. It's going to be a simple matter of figuring out where bash is looking for it. I just haven't found that out yet.
How do you like having full bash capabilities on EVO? Arrows/tab completion/color prompts, etc...
J
Click to expand...
Click to collapse
is there a way to get tab completion through adb shell?
Yes. This works with adb shell. Just follow the directions in the OP.
jmxp69 said:
Yes. This works with adb shell. Just follow the directions in the OP.
Click to expand...
Click to collapse
i have and i do have everything done as stated in the OP, when i try tab completion via adb shell (phone tethered with usb) from my pc, it just puts in a tab, it doesn't complete.
Hmm....could be a dos thing with cmd.exe. I haven't tried on a PC, I'm on a Mac. adb shell via OSX works fine with tab completion. Try ssh'ing in instead with something like putty? Once you get ssh going, you don't need a cable.
Edit: Confirmed...tab completion doesn't work over Win cmd.exe and adb shell.
jmxp69 said:
Hmm....could be a dos thing with cmd.exe. I haven't tried on a PC, I'm on a Mac. adb shell via OSX works fine with tab completion. Try ssh'ing in instead with something like putty? Once you get ssh going, you don't need a cable.
Edit: Confirmed...tab completion doesn't work over Win cmd.exe and adb shell.
Click to expand...
Click to collapse
Thanks for looking into it... I'll try getting it to work via linux instead. I guess ssh would be a solution, but i never turn wifi on.
Is anyone able to do a NAND backup/restore after doing this? With Amon Ra's recovery I was unable to NAND backup.
EDIT:
I think this is a big negatory. I was just able to do a NAND backup, so maybe the error I got was a coincidence after applying these changes.
Anyone else noticing that the time is always displayed as GMT in the prompt? The date command gives the correct time for my timezone but the bash prompt always shows GMT
Vinny75 said:
Anyone else noticing that the time is always displayed as GMT in the prompt? The date command gives the correct time for my timezone but the bash prompt always shows GMT
Click to expand...
Click to collapse
Change PS1 line: \A to `date +%H:%M`
jmxp69 said:
Posting this here because I think it will be of more interest to the tinkerers/devs than general users, if not, feel free to move it. I cobbled all of this together from various places on the web, but I think the credit for the binaries goes to Paul @ MoDaCo.
Nandroid before going any further!
Files you'll need:
For WiFi and CDMA SSH access - QuickSSHD (Download this from the Market. $1.50). I'm just going to assume if you're still reading, you know what this is for and how to use it. It's braindead simple. I think dropbear can be installed and configured manually, but for the $1.50...meh.
adb for tethered access.
The rest are zipped up here: terminfo, nano, bash, profile**
Unzip bashnano.zip onto your SDCard.
adb remount
From adb shell:
Install Terminfo:
cp -r /sdcard/terminfo /system/etc
Setup Bash:
cp /sdcard/bash /system/bin/bash_new
mv /system/bin/sh /system/bin/sh.old
ln -s /system/bin/bash_new /system/bin/sh
mv /sdcard/profile /sdcard/bash_profile (Thanks to jjvcuyler for finding adb bash profile location.)
Setup Nano:
cp /sdcard/nano /system/bin
I'm not sure if this setup will have any impact on sh scripts being used in the various ROMs, so use this at your own risk. I think it would kick ass to see this type of bash functionality baked into the custom ROMs.
If anybody would like to make this a flashable.zip, please do. I don't know how to do that yet.
Anyway, hope y'all find it useful.
**profile reflects a few personal choices for aliases and colors, but you can edit to your personal taste.
Click to expand...
Click to collapse
I followed the steps exactly, but end up with "- exec '/system/bin/sh' failed: Permission denied (13) -" while typing "adb shell" in a windows or linux terminal. I cannot recover the original sh because the root is lost, and I cant root my phone anymore probably because something wrong with the new sh. Any idea how to fix this?
EDIT: Acutally nevermind. adb shell works in recovery mode. but still, not sure why the modified sh doest work for me
The Downloadlink is dead!
So the thread is useless.
francwalter said:
The Downloadlink is dead!
So the thread is useless.
Click to expand...
Click to collapse
Yeah.....no.
A simple google search would have shown you that the files are here: http://66.197.42.222/bashnano.zip
or here http://androidforums.com/attachment...ide-installing-bash-nano-android-bashnano.zip.
EDIT: I've also attached it in case the links above ever die, there will still be one which does not.
ya this is great and all but any decent busybox installer will setup bash for you.

Linux Working on Android

(I'm reposting this under a different title so web searches will bring it up)
I can get Ubuntu 11.04, 11.10 & Debian 6 to mount repeatedly in all sorts of ui updatable configurations using this information:
http://www.nerd65536.com/2011/07/ins...version-2.html
It's a friggin Christmas Miracle! Can't tell you how much time I've wasted working this out, and it all boils down to the sh and run scripts.
So, without further ado, here goes.
!!Make sure you're rooted!!
!!The quotes just tell you what to type. Don't type them!!
1.
Download one of the three builds on the website listed above (or build your own, it should work fine). Extract it from tar.bz2, they should all extract to a linux file, this includes the necessary scripts. Put it on the sd-card on your phone.
2.
Download the new scripts that (Nerd) listed found here: http://ohm.nerd65536.com/android-lin...latest.tar.bz2
And extract them. You'll have another file that says linux. Open it, take the three files inside (install.sh, root-scripts & scripts) and paste them in the linux folder you moved to your sd-card. They will overwrite the ones currently there. These scripts work for sgs4g, the originals did not.
3.
Install the latest BusyBox in both xbin and .bin if it's not already installed (must be rooted), Latest is 1.19.3. Make sure Outside Sources and USB debugging are both enabled in your settings menu. Open your Superuser App and update binaries.
4.
Download a terminal client, like Better Terminal Emulator or Android Terminal Emulator. I use the first. The terminal needs to run the commands as root, especially the linux vnc command as it didn't want to work for me no matter if I started by typing su. Better Terminal Emulator has a check box to always start in root.
5.
Open up your terminal emulator and type su if you are not rooted there. Then change directory to the linux file on the sd-card. run the sh file there.
Like this:
"su"
"cd /sdcard/linux"
"sh install.sh"
If it works, the resulting dialog in terminal won't throw up any problems.
6.
Get back to / on sd by typing in terminal:
"cd /"
You should then have a: / # prompt, which means you are still rooted.
Enter:
"linux"
Which should result in a: [email protected]:/#
This means Linux is running. Congratulations. It should continue to run unless you shut down your phone.
7.
Download a VNC client, like Android VNC Viewer (free) or Remote VNC Pro, which I use. Add a new entry in it, with the following settings:
Host: localhost
Port: 5901
Password: cheesecake
Color: 24-bit
Name: Linux
When that's done save if you can or back out if you can't, and go back to your terminal emulator.
8.
It should still say: [email protected]:/#
If it doesn't, fine, if it does, just go back to root prompt by typing:
"exit"
Which should get you: / #. Then type:
"linux vnc"
Which should run itself and mount the chroot environment. It should tell you your new 'X' desktop is localhost:1, and have a: / # prompt again.
It might also ask you for a password, if so then put whatever password you'll remember in that's longer than 6 characters and verify it. This only happens once.
9.
Go back to your VNC client and if you entered a password in step 8. then edit your listing to your password instead of cheesecake, if not then don't.
Click on the Linux link and BAM! (shameless Emerilism), you're at your Linux desktop which should be running a iceWM desktop interface, which is fast. The LXDE desktop is nicer and if you want that then go into you're terminal and get into the linux shell by typing:
"linux"
And then switch to LXDE by typing:
"apt-get autoremove icewm- lxde+"
Which will run through the removal/ installation, and verify you want to download the <400mb files. Type:
"y"
And give it time to finish. When finished, just go back to your VNC client and hit Linux again, and you will have a nice looking functional desktop, with a cpu load graph on the bottom. I tried using Gnome desktop and Unity 2d, but both of these would install and not fully run with all options. They are heavier and slower, but cool non-the-less. Let me know if anyone has luck with these on Android.
Notes-
You only have to type "linux vnc" once in terminal to start linux every time you boot your phone. Otherwise, just open your VNC client and click on Linux to use it. Easy!
You will want to update and upgrade your linux after install, do so by typing in terminal:
"apt-get update"
"apt-get upgrade"
Also, you might run across a problem if you try to add-apt-repository, that's because that python command is not present. To use it, enable by typing:
"apt-get install python-software-properties"
Also of note, the downloadable linux builds are sized to about 2.15gig on your sd, which is big enough for most. There is a way to resize them which I tried but it gave me trouble in loading. I will try again and see if I can get it to work.
Here's the link from Dangermouse:
http://www.androidfanatic.com/commun...atid=9&id=1610
Thanks to Nerd65536 for the info, write-up and files. He fixed my problem.
You might want to put quote or code tags around all the commands to make them easier to see and read, but good guide! I'll try it out soon since I haven't gotten any linux build to run on my phone in a good while.
Thanks for the post!
I wrote the post noob-style to make it easy for beginners to follow, as I've had to search and test forever to find information that works.
Let me know if you have any problems, I'd be happy to assist. Don't expect you'll have any issues with your knowledge of the os. It works pretty well on the Android system, fun to use.
wasn't this posted ages ago?
No, it's a bleed over from a question post I made under Q&A a week or so ago. I threaded this because I had such a hard time finding a thread with working steps for the Galaxy S under google search. There's not that much new from this post http://www.nerd65536.com/2011/07/in...showComment=1323566336074#c553594301247543088 by Nerd65536 (which took me forever to find and was the only one that worked). Other than that, just a few of my own thoughts and hints on the process.
krylon360 said:
wasn't this posted ages ago?
Click to expand...
Click to collapse
meant to quote not thanks, but anyways, to answer.
There has been a few times this has been posted, but its been many months and this seems like the first the issues have been sorted.
Sent from my SGH-T959V using Tapatalk
Ok, a little more use of Linux builds on my phone and I'm starting to understand why it does or does not work.
Certain kernel builds seem to work well, others not at all. Most of the kernel's I've tried have been problematic, and trying to install the .sh file will fail.
When you install your new kernel (or on your existing one) you need to open your Superuser app which should be there if your phone is rooted. There is a button to update binaries, and they need to be updated. Some builds don't seem to let this work easily and give failure notifications.
Make sure Outside Sources is enabled and USB debugging is too, both are in the settings menu.
Use BusyBox installer to install in both the .bin and .xbin directories, this will not cause any conflicts (or hasn't yet . If this gives you an error, and it will if Superuser did, then either usb debugging has not been selected or the kernel is not playing nice.
Ok, so this kernel by RaverX3X will work for linux, I'm on it now:
http://forum.xda-developers.com/showthread.php?t=1305145
(Thanks for this)
Oh yeah, and Back|Track5 Linux is working too
Fixing the packet injection for the Broadcom now.
sconsylman said:
Oh yeah, and Back|Track5 Linux is working too
Fixing the packet injection for the Broadcom now.
Click to expand...
Click to collapse
. Keep us posted on that. Should be pretty handy.
Wait. why do we need LInux to run on our phone?
Can someone explain?
Android doesn't come with most of what this has:
http://www.backtrack-linux.org/
I know, but why do we need it?
Enlighten me
airfluip1 said:
Wait. why do we need LInux to run on our phone?
Can someone explain?
Click to expand...
Click to collapse
I've seen this comment on every single thread online regarding Linux on Android. It's a joke right?

[Shell][mksh][Scripting]::mksh-R50e-static-FULL+mkshrc_mods:::

:::BRIEF DESCRIPTION:::
mksh is the official, currently-developed shell used for Android. It is not an app nor a virus (lol) like some people seem to think, looking at a quick xda search. And as the core shell for android, it is used to shell superuser, so if you're rooted and get a message saying "mksh requests root", that basically just means that superuser is being run correctly and is using the default Android shell that is in every Android device. (GOOD)
If you get a message saying bash(or any other shell) requested root, and you're NOT in the terminal interactively. That most likely is NOT GOOD! Almost all bash scripts I've seen will run shelled with mksh, so be safe and shebang with mksh. You'll have better performance and features, and when you see bash requesting root, you'll know when your security is likely compromised.
::: mksh Resources/links/info :::
mksh author: mirabilos (on xda forums)
mirbsd mksh main page: https://www.mirbsd.org/mksh.htm
mksh man page: https://www.mirbsd.org/htman/i386/man1/mksh.htm
edited 15Aug2014
Now that that's out of the way, I've attached a few zips in the 2nd post. The first contains my personalized mkshrc (startup mksh script), the full original mkshrc it's based on, and a diff for anyone who's interested. **This file belongs at /system/etc/mkshrc.** The rest of this first post details what I've cooked up in my mkshrc (and fpath functions). The other zips' contents are described in the 2nd post.
Features scripted into mkshrc:
--sudo: basic su executor
e.g.:
Code:
sudo mount -o rw,remount -t f2fs /system /system
sudo cat <<< $'\n' >> /system/build.prop
sudo 'sysrw; for i in /system/*; do chown 0 "$i" ; done; sysro'
--suid: (set user id) Uses chpst to run a prog setsuid, this is broken in most busyboxes so I included one with a working chpst. Usage:::
e.g.:
Code:
suid 1000 sh
--Rebind tab completion: unjams clustered words:
e.g.: <[cursor]> is cursor position
Code:
bind -m -- '^I= ^B^[=^D'
<<EXAMPLE USAGE>>
ec<[cursor]>12345 + tab ---> echo 12345
--Rebinded "control + u" to "cut-to-beginning of line" like bash. (As mirabilos points out, this is ksh incompatible behaviour since "control + u" is "kill-line" in *ksh shells. This can be removed from the (/system)/etc/mkshrc shell startup file if it presents any problems in editing.) The exact binds are:
Code:
bind -- '^[W=kill-region'
bind -m -- '^U=^[ ^A^[W'
<<EXAMPLE USAGE>>
ec<[cursor]>12345 + ctrl + u ---> <[cursor]>12345
--TMPDIR: mounts a tmpdir at /tmp for all users and random generates subdirs for individual secured tmpdirs. This fixes here-docs, here-strings, and here-executions.
e.g.:
Code:
su << 'eof'
sysrw; chgrp 2000 /system/bin; sysro
! (( $? )) && print -- -changed them bin group-
eof
--Basic "help" command: Android lacks this and the doc is still under development I believe. I added all the basic info/command-forms for mksh bultins to a command help(aliased to h):
e.g.:
Code:
help mkn
> mknod [-m mode] name b|c major minor
> mknod [-m mode] name p
or
Code:
help
(all help is printed, grep from here if you want)
--Complicated-programmed and colorful PS1 prompt, it looks good and I thought it through. Programming shows mksh potential for rich shell programming. It auto-turns off xtrace within itself (to 3 lines) so that 50 lines don't get printed each return with set -x. mksh small (R43 mksh) will be autodetected and give a different white and black classic ksh prompt.
--ton of ultra lazy aliases, got my android scripting speed up to ~70% my normal pc speed.
--dot.mkshrc functions from official mkshrc like pushd, popd, dirs, more, hd, Lb64encode, Lb64decode, hash optimizations
The scripting in this gets pretty complex, especially the inherent mkshrc functions. It would make a good scripting learning tool to say the least. I know I've learned twice what I knew from bash scripting back 3 months ago.
I've been working on modding the mkshrc a while, so I appreciate any error reports if you give mine a try. Shouldn't be any problems though.
Modifying the mkshrc file / mksh shell has system-wide effects, so PLEASE nandroid backup as usual!!! This should be COMPATIBLE with all androids, but has only been tested on my Galaxy Nexus thus far. **The binary is compatible with androids using an ARM cpu, but the steps in the 3rd post will generate a binary for whatever ARCH you're running.**
EDIT: reprogrammed sudo with pexec, so it can do parallel executions. pexec, grep, and a full busybox are included in a zip with some other bins.
For Jack Palevich's terminal emulator or connectbot, telnet, etc, I use this as my su'd "shell" command under >>Options>>Shell:
Code:
/system/xbin/su --shell /system/bin/mksh --command exec /system/bin/pexec -z -15 --shell /system/bin/mksh -m '/system/bin/mksh'
What's safer though is to just use a non-su shell command:
Code:
/system/bin/mksh -
...and then use sudo for your su commands. This is more linux'y.
EDIT2 (big update): Got static mksh R50 compiled. Ended up booting ubuntu in Android to compile instead of cross-compiling. mksh's Build.sh compiler script works great. I just had to "sudo apt-get install gcc" and bam it built with "LDSTATIC=-static ./Build.sh".
EDIT3 - Changed main.c source mkshrc file to /system/etc/mkshrc, perfect static mksh R50 now.
EDIT4 - Changed compiler to klcc to get size way down, now at 196KB with -O2 LTO speed optimizations.
EDIT5 - Binary is updated to R50d, compiled with CFLAGS=-Os, and stripped to get size down to ~140KB. (This is even smaller than the R43 dynamic mksh binary that is currently used in roms.)
EDIT6 - Added a mksh trunk (latest and greatest) binary with the printf builtin compiled in. Use with caution. Btw, if you read all the way down here, then yes, these binaries work in lollipop since they're statically compiled.
:ownloads:: (#7 or #8 is the static binary by itself)
(1) mksh R50 source, binary, manual
(2) Highly compressed pack of extra bins/libs that are mentioned in my mkshrc (zsh, lz4c, grep, busybox, bash, nano, vim, curl, etc) and some other cool ones like macchanger and ed. Download #3 to extract on Android.
(3) 7za in case you need it to extract (2) on Android.
Code:
7za x name_of_archive.7z
(4) Classic unix text editor "ed" which mksh uses for edit functionality. (Copy to /system/bin along with mksh.)
(5) Official mkshrc (unzip and copy to /system/etc, set permissions to 0444)
(6)
My personalized mkshrc startup mksh shell script based on the official full mkshrc 2014/01/11 release. Described in first post. If you try this, make sure to symlink /system/xbin/busybox to /system/bin/busybox.ndk.
Official mkshrc 2014/01/11 release
"diff -ur /system/etc/dot.mkshrc--official.mkshrc mkshrc" (diff patch set from official mkshrc to my personalized mkshrc)
(7) mksh static binary! (Just unzip, "chmod +rx" it, and copy to /system/bin or run from anywhere, no libs required )
(8) mksh R50e with printf builtin (I know some people were looking for this)
::: Building mksh Static On Android (really Ubuntu though..):::
This is just for anyone who wants to try, and especially those without access to a PC.
Things we'll need besides your phone:
-"Android Terminal Emulator" app {get it from (http://jackpal.github.com/Android-Terminal-Emulator/downloads/Term.apk) or fdroid or gplay}
-"Complete Linux Installer" app {get it from (http://sourceforge.net/projects/linuxonandroid/?source=typ_redirect) or gplay or maybe fdroid}
-internet/wifi
-mksh source {download from (https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R50.tgz) or link in first post or DL in second post}
1) We need to get Ubuntu or Debian booted for a sufficient build environment. I've used both on Android but I like the better stocked terminal in the Ubuntu images. I used the app Complete Linux Installer which is free and works beautifully, very simple and easy too. In the app you want to follow the short instructions to download an Ubuntu image, rename it to ubuntu.img, and place it in a folder named ubuntu in /sdcard. Then hit menu in the app and click the terminal screen icon that says "Launch". An Ubuntu terminal will now open in Android Terminal Emulator. Super quick and easy.
2) Let's download GCC and ed so we can build and test with zero errors.
Code:
apt-get install -y gcc ed
3) Now the cool thing about this chroot Ubuntu environment is that we still have access to the sdcard to transfer files between Android environment and the chroot jail. Extract your downloaded mksh source to your Ubuntu home with something like:
Code:
cd
tar -xf /sdcard/Download/mksh*.tgz
cd mksh
4) Since we're building this for Android, the mkshrc file is at /system/etc/mkshrc instead of ~/.mkshrc, so we can change this with:
Code:
sed -i 's|~/.mkshrc|/system/etc/mkshrc|' ./main.c
Now we can build mksh statically:
Code:
chmod +x Build.sh
MKSHRC_PATH=/system/etc/mkshrc LDSTATIC=-static ./Build.sh -r -c lto && ./test.sh
Let the build script crank out the binary for a couple minutes and run the test suite. There should only be an error on a "mkshrc" test since we changed it for android. The "-r -c lto" flags/opt aren't needed but recommended.
Edit: (size optimization): Strip the compiled mksh binary to make it super small (~150KB with a CC="klcc" or CC="diet gcc" compile).
Code:
strip --strip-unneeded ./mksh
5) Now let's copy it to /system/bin to replace your old one.
Code:
cp ./mksh /sdcard
(Open a new terminal tab to get into Android Environment)
sysrw
cp -f /sdcard/mksh /system/bin
chmod 0555 /system/bin/mksh
sysro
.. and done. Run some scripts and enjoy your static mksh!
*** OPTIONAL EXTRA STEPS TO USE klcc or other compiler ***
In step (1), also do
Code:
apt-get install -y libklibc-dev
to get the klibc development tools, and then...
In step (4), this is how you specify to use klcc (aka build against klibc using the klcc wrapper):
Code:
CC="$(which klcc)" MKSHRC_PATH=/system/etc/mkshrc LDSTATIC=-static ./Build.sh -r -c lto && ./test.sh
:::Compile mksh in Android (for ARM):::
1) Download the attached cross-compiler and mksh source (https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R50.tgz). Copy them to /data/media. If you don't have 7za, download that as well from the previous post but place it in /system/bin and "chmod +x" it
2) Extract contents:
Code:
cd /data/media
7za x -so 2014-10-01__simple-cross-compiler-armv4tl.stripped.tar.7z | tar -xf -
tar -xf mksh*.tgz
3) Compile the source with:
Code:
cd mksh
chmod +x Build.sh
LDFLAGS=-static CC=../simple-cross-compiler-armv4tl.stripped/bin/*gcc ./Build.sh -r -c lto
../simple-cross-compiler-armv4tl.stripped/bin/*strip -s mksh
4) Replace old mksh and mkshrc
Code:
mount -o rw,remount /system
cp mksh /system/bin
cp dot.mkshrc /system/etc/mkshrc
chmod 0555 /system/bin/mksh
chmod 0444 /system/etc/mkshrc
mount -o ro,remount /system
@7175 : Hello! Look like a bunch of hard work there. Very nice.
1. Would you have any clue to what's going on HERE?
2. Would you know if I can just install over my old mksh binary to get this working, or do I need "everything"?
3. And since I've heard that /system/bin/mksh will soon be permanently only /system/bin/sh perhaps this need to be changed?
Hey E.VA. thanks for checking out the thread. If you want to just test out R48 mksh, just copy(from zip root directory) the lib*.so from /data/media/shell to /system/lib and then copy /data/media/shell/mksh to /system/bin (and chmod 0555 /system/bin/mksh; chmod 0444 /system/lib/*.so). Then you'll have your whole system running full mksh R48.
As far as the ssh problem with android, this definitely becomes grey-zone material to my knowledge, which is limited in this area. I'm pretty sure android has udev amputated so it lacks a fully working /dev/tty. This could probably be patched over though with some terminal work, mknod action. I've gotten ssh working under "terminal ide", but haven't used the stock ssh stuff in /system/bin. Now that you mention this though, I will try and get stock ssh going as well as openssh which had a similar problem last time I tried (thx for mentioning your support thread, I'll be checking that out).
Here's what I searched to shed a little light on that ssh /dev/tty issue: duckduckgo.com/html5/?q=ssh+%27dev%2Ftty%27+error.
It looks like you've done a ton of searching though.
For su commands, I would try using, e.g.,
Code:
su exec [i]command[/i]
...opposed to "su -c", or better e.g.,
Code:
su -c exec /system/bin/sh -c '[i]command[/i]'
...and see if that gives any different results.
I just know from experience "su -c" hasn't always cut it.
*edit: Couple other things worth trying:
1) preappend command with environment variable: global TTY=/dev/pts/0 ...
2) use the -T option when calling mksh, i,e. ssh ... -e mksh -T /dev/pts/0 ...
@7175 : Hey thanks for looking into this. I will definitely try your suggestions.
However, I've already tried the -T flag to ssh, but never by specifying the pts to use, as it should be dynamically allocated by the ptmx. (As it could be already in use, by something else, like ATE.) Also, what does "global" do?
You also mentioned "stock ssh" in /system/bin. I've never seen that. Perhaps that could be a better solution, unless its' even more crippled. Does it also support sshd (i.e. ssh -D)?
In the mean time, is there any particular reason why you decided to dynamically link mksh? (I assumed it would have been more portable with static linking?)
I see that you did a huge amount of work on that mkshrc script. Looks crazy (in a good way)!
Finally, and aside, I also noticed that when I start mksh from ssh session, there are some aliases in there, that is not specified in the mkshrc, nor the .profile of my SSH server, so where the heck do they come from?
Code:
[SIZE=2][email protected]:home # alias
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
type='whence -v'[/SIZE]
Perhaps they're hardcoded or sourced from somewhere? Have you seen this?
E:V:A said:
@7175 : Hey thanks for looking into this. I will definitely try your suggestions.
However, I've already tried the -T flag to ssh, but never by specifying the pts to use, as it should be dynamically allocated by the ptmx. (As it could be already in use, by something else, like ATE.) Also, what does "global" do?
You also mentioned "stock ssh" in /system/bin. I've never seen that. Perhaps that could be a better solution, unless its' even more crippled. Does it also support sshd (i.e. ssh -D)?
In the mean time, is there any particular reason why you decided to dynamically link mksh? (I assumed it would have been more portable with static linking?)
I see that you did a huge amount of work on that mkshrc script. Looks crazy (in a good way)!
Finally, and aside, I also noticed that when I start mksh from ssh session, there are some aliases in there, that is not specified in the mkshrc, nor the .profile of my SSH server, so where the heck do they come from?
Code:
[SIZE=2][email protected]:home # alias
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
type='whence -v'[/SIZE]
Perhaps they're hardcoded or sourced from somewhere? Have you seen this?
Click to expand...
Click to collapse
Thanks man lol it's a big rc. It was 50KB before I converted a bunch of the functions to fpath functions in /etc/fpath and stripped most of the comments. It should give a pretty quick shell in terminal though with the ulimit and renicing tweaks. The PS1 prompt is pretty awesome, probably the best thing in the mkshrc I included.
"global" is a function just like "typeset" or "declare" in bash. The difference is that global prevents an accessed variable from being localized/ different than the global value in a function. This is a mksh function, bash will use "declare -g". There are a couple of example usage in the mkshrc, like with the set -x spam fix for the command prompt.
I checked and stock ssh in /system/bin has the "-D" flag. I would also check rolo's zshaolin zsh project which comes with some afterstock ssh stuff, ssh keygen, ssh keysearch, different ssh etc.
Yeah I just symlinked sh to save space really and for portability to try out other shells like bash and zsh(this works!) to run the system. Recently I switched to using a copy of mksh as sh since "chattr +i" wasn't protecting the symlink from being over-linked.
The aliases you posted are in fact hard-coded. If you do "strings /system/bin/mksh | grep -C7 autoload" or something similar, you'll see them in the binary. I always wondered where those came from too until I read through the mksh manual over a couple months, that's some pretty dense reading lol. mksh is a superb shell though, so it's definitely well worth it.
Sorry I can't be of more help with the ssh /dev/tty problem. I will keep my eyes open though, and try not to be so lazy using telnet for all my remote connections. I mean that's basically using the internet without a condom lol.
(*Also, just something I should mention about the install zip contents: not all the /etc/fpath functions are finished yet. I still gotta tweak the ssh ports from /etc/ssh and finish my xargs. Most should work though and are safe and won't interfer with shell usage, even if autoloaded.)
@mirabilos :
Hi, why did you choose to hardcode the aliases (shown in post#6) into the mksh binary?
Also, do you have a later version than the R48 Android binary above?
The "r" alias is particularly disturbing as it is masking the native toolbox use of "r" to read a memory location.
7175 said:
with the ulimit and renicing tweaks.
Click to expand...
Click to collapse
Why do they need to be tweaked?
I checked and stock ssh in /system/bin has the "-D" flag. I would also check rolo's zshaolin zsh project which comes with some afterstock ssh stuff, ssh keygen, ssh keysearch, different ssh etc.
Click to expand...
Click to collapse
Sorry my bad, I was sleepy and mistakenly understood "-D" as running SSH in daemon mode, when in fact it does the opposite and prevents it. Seem like his links are dead or I'm just looking in the wrong place.
Recently I switched to using a copy of mksh as sh since "chattr +i" wasn't protecting the symlink from being over-linked.
Click to expand...
Click to collapse
Not sure what you're saying here...
Sorry I can't be of more help with the ssh /dev/tty problem. I will keep my eyes open though, and try not to be so lazy using telnet for all my remote connections. .
Click to expand...
Click to collapse
Thanks, but if telnet works with tty/pts jobcontrol and vi etc, then I'm fine with that for now. I tried your command variations above and got this:
Code:
[SIZE=2]#ssh -2 [email protected] -p 2222 -T su -c exec /system/bin/sh -i # This worked!
#ssh -2 [email protected] -p 2222 -T su -c exec /tmp-mksh/tmp-mksh -T /dev/pts/0
/tmp-mksh/tmp-mksh: chvt: can't find tty /dev/pts/0
#ssh -2 [email protected] -p 2222 -T su -c exec /tmp-mksh/tmp-mksh -T /dev/ptmx
/tmp-mksh/tmp-mksh: chvt: new shell is potentially insecure, can't revoke /dev/ptmx
[/SIZE]
The fist one is good to get direct root prompt, the second fails, since pts/0 has not been created yet, and if it has, it fails with permission issue, since another process is trying to steal the pts. The reason why the third one fails, is very cryptic and I don't understand the error message and neither the code generating it.
Do you think one could use the ATE app to get a working root shell by the use of a more complex ssh command? Any suggestions how that would look?
Finally, I'm a bit worried about replacing the libc.so dependency, since the whole system depend upon it, and would probably not boot if an incompatible libc.so is used. This is why I asked about a static binary. I'd much rather have a bloated mksh than having to add library files. (We have plenty of memory and space these days.)
Regarding compiling, I would recommend using Linaro a build, rather than the crappy and often broken/outdated Code Sourcery junk.
Check this thread:
[LINARO GCC] Cross Compiler Toolchains [Linaro GCC 4.9 2014.07, 4.8 and 4.7 2014.04][19/07/2014]
Cheers!
7175 said:
--Better tab completion: unjams clustered words:
--Added "control + u" to "cut-to-beginning of line" like bash.
Click to expand...
Click to collapse
Hi! As the author of mksh, I am hereby explicitly requesting you to add a suffix to the shell version, similar to what the PLD Linux guys do here, because this changes the behaviour of the shell in an incompatible way. (Just add your own string there after a space, the @distro@ is just a placeholder that gets replaced with the PLD Linux package version.)
Do note that ^U in Korn Shell (and others) is “delete entire line”.
7175 said:
--Very complicated-programmed and colorful PS1 prompt, it looks good and I thought it through. Programming shows mksh potential for rich shell programming. It auto-turns off xtrace within itself so that 50 lines don't get printed each return with set -x. mksh small will be autodetected and give a different white and black classic ksh prompt.
Click to expand...
Click to collapse
Interesting idea, I think I will pick up the “set +x” thing.
Do you mind sharing a patchset of all your changes, so I can incorporate those I feel would be good to have in general?
7175 said:
EDIT: It appears the libc required for full mksh isnt always friendly
Click to expand...
Click to collapse
Just link the shell statically, then.
E:V:A said:
1. Would you have any clue to what's going on HERE?
Click to expand...
Click to collapse
You are annoying me. I've told you times and times again to disable SEAndroid, or to fix its SELinux policies.
E:V:A said:
2. Would you know if I can just install over my old mksh binary to get this working, or do I need "everything"?
Click to expand...
Click to collapse
Define “everything”. mksh in AOSP is /system/bin/mksh plus mkshrc.
E:V:A said:
3. And since I've heard that /system/bin/mksh will soon be permanently only /system/bin/sh perhaps this need to be changed?
Click to expand...
Click to collapse
I'm working with enh of Google on that. I would like for mksh to be installed as /system/bin/mksh and /system/bin/sh to be a link/copy of it, always. He said he'd agree I could change that back.
E:V:A said:
Hi, why did you choose to hardcode the aliases (shown in post#6) into the mksh binary?
Click to expand...
Click to collapse
These are part of the shell, and have always been, even in pdksh times.
E:V:A said:
Also, do you have a later version than the R48 Android binary above?
Click to expand...
Click to collapse
I do not deal in binaries normally. I'm somewhat working on updating AOSP to mksh CVS HEAD, in tandem with enh from Google, but when I had the time for that, it appears they changed the build system requirements. But it will be there.
It's not as if a newer mksh version would fix your SELinux problem, though…
E:V:A said:
The "r" alias is particularly disturbing as it is masking the native toolbox use of "r" to read a memory location.
Click to expand...
Click to collapse
The “r” alias is especially required for the Emacs command line editing mode. Interesting that toolbox uses it too. Thanks for bringing this to my attention, I will ask enh to change “r” in toolbox.
@E:V:A : Glad the first execution you mentioned worked. I would try messing with quotes/double quotes around the shell command, i.e. ssh ... -T su -c 'exec ...' or try ssh ... -T su -c exec "...", as something to test out further. This can make a lot of difference.
The ulimit shell function can control all sorts of performance related stuff, priority, max niceness, etc. You can see all values with "ulimit -a".
I understand your hesitance about the libc.so replacement. I would keep a copy of the old one and twrp backup before trying out a new one. I get what you're saying about statically linked binaries. I just fixed my i7 desktop that had a blown power supply, so I'll be looking into this. Thanks for the linaro link!
@mirabilos : Thanks for taking a look at this and providing us with mksh! I updated my OP with the specifics about the rebinds for "control I" and "control U" that you mentioned, and I added a suffix to the beginning comments of the file. Something like:
Code:
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.88 2014/01/11 18:09:39 tg Exp $Android_mod by [email protected] 2014/08/04$
Not sure if that's what you wanted me to add in. I included an extra zip to download in the 2nd post that contains the official mkshrc 2014/01/11, my personal mkshrc, and a "diff -ur" patch (also attached to this post).
I will look into getting a statically linked mksh compiled, that sounds like something really handy to keep around.
edit: Here's basically what I added to the beginning and end of PS1 to trim down its "set -x" verbosity to 3 lines. I'd like to get it down more but haven't figured it out.
Code:
PS1=$'\001\r'; PS1+='${|
local e=$?
[[ -o -x ]] && set +x && global -x XTR_DBG=1 || global -x XTR_DBG=0
...
...
...
(( XTR_DBG )) && set -x
return ${e}
} '
7175 said:
@mirabilos : Thanks for taking a look at this and providing us with mksh!
Click to expand...
Click to collapse
You’re welcome!
7175 said:
Not sure if that's what you wanted me to add in.
Click to expand...
Click to collapse
Ah, so you did not patch the mksh binary, only the mkshrc file?
But then, that’s okay as you wrote, sure.
7175 said:
I included an extra zip to download in the 2nd post that contains the official mkshrc 2014/01/11, my personal mkshrc, and a "diff -ur" patch (also attached to this post).
Click to expand...
Click to collapse
OK, thanks. Will have a look at it within the next weeks (August is going to be a busy month for me).
I’m assuming you are okay with me adding some of your changes back to main mksh?
7175 said:
I will look into getting a statically linked mksh compiled, that sounds like something really handy to keep around.
Click to expand...
Click to collapse
Indeed, it is.
The first mksh run on Android actually was statically compiled against µClibc, though that’s cheating. (Also, dietlibc and klibc are better than µClibc). I think it should work against Bionic, too.
7175 said:
edit: Here's basically what I added to the beginning and end of PS1 to trim down its "set -x" verbosity to 3 lines. I'd like to get it down more but haven't figured it out.
Click to expand...
Click to collapse
I don’t think it works in less, considering you have to save the previous $?. There are a few handy tricks around. I tried these four:
#1 is:
Code:
local e=$?
[[ -o -x ]]; local x=$?; set +x
(( e )) && REPLY+="$e|"
[…]
(( x )) || set -x
return $e
This is about what you did. #2 is:
Code:
local e=$? x=$([[ -o -x ]]; echo $?); set +x
(( e )) && REPLY+="$e|"
[…]
(( x )) || set -x
return $e
This only looks different (I’d prefer #1 over this.) #3 is:
Code:
set +x $? $([[ -o -x ]]; echo $?)
(( $1 )) && REPLY+="$1|"
[…]
(( $2 )) || set -x
return $1
This reduces visual clutter. #4 is:
Code:
set +x $? $([[ -o -x ]]; echo $?)
(( $1 )) && REPLY+="$1|"
[…]
(( $2 )) && return $1
(( $1 )) && set -x && return $1
set -x
This reduces visual clutter even more, in that, when $? is 0, one line less is shown. But it makes the number of lines shown be not always the same. YMMV on whether to use this, #3 or #1.
This could be made even nicer *iff* mksh had the EXIT trap when leaving a function. The manpage says it’s TODO. This part of the manpage is from 1999 or older. (I started mksh in late 2002, early 2003.) Go figure… But now I have a reason to add it ☺
Another thing you could do is “set +o inherit-xtrace”, which makes functions not run with “set -x” when the main body runs with it. But wait, I see now that it does not affect ${|…;} blocks. This is a bug, which I’ll fix ☻
@mirabilos:
You Wrote:
1. Would you have any clue to what's going on HERE?
Click to expand...
Click to collapse
You are annoying me. I've told you times and times again to disable SEAndroid, or to fix its SELinux policies.
Click to expand...
Click to collapse
Well, you can be as annoyed as you like. First of all, that question was not aimed at you, and second, as I have also said repeatedly, I have already tried using SELinux in Permissive mode and it doesn't work either. In addition, your suggestion to "fix its SELinux policies" is rather ridiculous as there are no tools available to do so. At least nothing out of the box and no available binaries anywhere, and surely no instructions how to do so. So if you know how to do it, why don't you just explain for us how to do so. (My policies are updated to latest according Androids policy update tools.)
In addition there is no such thing as "disable SEAndroid". It's either in Permissive or Enforced mode. That is, unless you flash a new custom FW, which is out of the question. In addition, ATE works just fine, in Enforcing mode.
So believe me, I am far more annoyed by Googles lack of SELinux/SEAndroid developer support, than you will ever be from me asking these questions.
Thanks for explaining and helping with everything else above.
@7175:
The ulimit shell function can control all sorts of performance related stuff, priority, max niceness, etc. You can see all values with "ulimit -a".
Click to expand...
Click to collapse
Yes, I know about all those things, but I was asking why you think they need to be tweaked? The defaults, seem to work just fine.
@mirabilos : Thank you for your detailed replies, and I would be more than happy to contribute if you see anything from the content I posted.
It is interesting to see the other possibilities for turning off xtrace within the PS1. I didn't even realize you could set positional parameters after the set -x... I think I like that one the most. It just seems more array-like and streamlined, although I guess the same number of variables is still used. I look forward to seeing what updates you'll have on the exit trap and localization. This is something I'd like to toy around with.
I took your advice and set out to get a mksh static built. I ended up compiling with GCC, running "LDSTATIC=-static ./Build.sh" in the mksh source directory. I'm pretty new to cross compiling, so I didn't really get that far or try that hard before chrooting to a fresh Ubuntu terminal on my Nexus, installing GCC, and compiling there. The only thing I changed in the source code was ${ENV:-~/.mkshrc} to ${ENV:-/system/etc/mkshrc} in the "main.c" source file. I can include this in the OP though as you mentioned before. (edit: just saw this as a compiler option with Build.sh)
Edit: I see the option now in the Build.sh for changing the mkshrc path. Also, got R50 rebuilt static with klibc. Damn that got the size way down from using glibc, 684K to 204K.
R50e is released
R50e is released -- see https://www.mirbsd.org/mksh.htm#clog
Hi @7175, good stuffs here man :good:
I've been using your modded mkshrc, and I can see a hell of a lot of work you put into it. Looks really cool. Plus it's really a good place to learn for someone like me, I definitely had learnt a lot for the past few days. Tons of aliases too, and I'm getting used to using it now. I really appreciate your stuffs here, hope to see more of it
alanthehat said:
R50e is released -- see https://www.mirbsd.org/mksh.htm#clog
Click to expand...
Click to collapse
Thanks for the heads up. Updated the binaries posted in the 2nd OP to mksh R50e.
Reinkaos said:
Hi @7175, good stuffs here man :good:
I've been using your modded mkshrc, and I can see a hell of a lot of work you put into it. Looks really cool. Plus it's really a good place to learn for someone like me, I definitely had learnt a lot for the past few days. Tons of aliases too, and I'm getting used to using it now. I really appreciate your stuffs here, hope to see more of it
Click to expand...
Click to collapse
Thanks for the feedback man! Glad it's been a good learning experience like it has been for me.
7175 said:
Thanks for the feedback man! Glad it's been a good learning experience like it has been for me.
Click to expand...
Click to collapse
Well, thanks for the updated binary! Anyway, anything you can recommend me to read other than the man page in OP? And I have one more question, what's the difference between the busybox (I got one from your other thread) and yours busybox.ndk?
While I’m the upstream developer of mksh, hacking it has also been a good learning experience for me.
So it is for a friend of mine, who has taken some fundamental script frameworks I wrote, and extended it to an impressive management system, learning to code good shell while doing so.
I’m always happy when my stuff helps other people, and they share their joy! ☺
By the way: new mksh release announcements are sent over the miros-mksh mailing list (send an eMail to postmaster at mirbsd dot either org or de to subscribe).
---------- Post added at 08:40 PM ---------- Previous post was at 08:34 PM ----------
Well, we have https://www.mirbsd.org/ksh-chan.htm which collects lots of Korn Shell-related resources, although most of it is for AT&T ksh93 (the “original” Korn Shell), much also applies to mksh, though the Android OS has some special handling (especially caused by the different user-space tooling) obviously.
The shell itself behaves exactly the same across *all* supported platforms though, so (once you have set $TMPDIR to something writable for your current user) you can write Pure mksh code exactly like on Unix or Cygwin or the Macintosh or even Haiku.
mirabilos said:
While I’m the upstream developer of mksh, hacking it has also been a good learning experience for me.
So it is for a friend of mine, who has taken some fundamental script frameworks I wrote, and extended it to an impressive management system, learning to code good shell while doing so.
I’m always happy when my stuff helps other people, and they share their joy!
By the way: new mksh release announcements are sent over the miros-mksh mailing list (send an eMail to postmaster at mirbsd dot either org or de to subscribe).
---------- Post added at 08:40 PM ---------- Previous post was at 08:34 PM ----------
Well, we have https://www.mirbsd.org/ksh-chan.htm which collects lots of Korn Shell-related resources, although most of it is for AT&T ksh93 (the “original” Korn Shell), much also applies to mksh, though the Android OS has some special handling (especially caused by the different user-space tooling) obviously.
The shell itself behaves exactly the same across *all* supported platforms though, so (once you have set $TMPDIR to something writable for your current user) you can write Pure mksh code exactly like on Unix or Cygwin or the Macintosh or even Haiku.
Click to expand...
Click to collapse
Thanks for the link, and for your works on mksh too! I'm really new to shell, I'm not even that familiar with unix/linux either. But I always have been interested in shell scripting, so I'm glad that I stumbled upon this thread
Whew, that's a lot of stuff in that link you gave, definitely gonna make use of it, thanks again!

Categories

Resources