Linux - MobileThis forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Sailfish OS, Replicant, Ubuntu Touch, webOS, and other similar projects and products.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I installed an SSH server on my Android phone. I can ssh into it. Cool.
Then I wanted to get a list of files and directories and typed 'ls' of course.
It works, but I definitely prefer the output of 'ls -la'...
which also works, but I am used to having 'ls -la' aliased to 'ls' so I just have to type 'ls'. We're all lazy, aren't we?
So I tried this:
$ alias ls='ls -la'
It works, but only during that session. If I log out and log in again, the alias has been lost.
OK. The app's documentation says it supports a .profile file, but that is not working. I don't get the alias when I log in. Even explicitly running 'sh .profile' doesn't work.
But that doesn't matter so much anymore. Now I am more curious about other things.
First, what shell is my phone running?
$ echo $SHELL
/system/bin/sh
Not very informative. Any ideas about how I can make this shell identify itself?
Second, I can type letters, tab-tab and find some available commands. But not all of them are listed by tab-tab. For example, m tab-tab gives me no output (other letters do), but the mkdir command is available. I know, I tested it. So what other commands are available? How can I find out what they are? Looks like I am back to the first question, what shell is my phone running?
or something similar the "usual" way.
from the other hand 'sh .profile' cannot work because that will process that .profile in another shell (which will be immediately closed after reading .profile). You ought to use
Searching for "android shell" reveals that it used to be Almquist (ash) and is now MirBSD Korn Shell (mksh)
Quote:
Originally Posted by https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md
Since IceCreamSandwich Android has used mksh as its shell. Before then it used ash (which actually remained unused in the tree up to and including KitKat).
Initially Android had a very limited command-line provided by its own “toolbox” binary. Since Marshmallow almost everything is supplied by toybox instead.
Quote:
Originally Posted by rkelsen
If you can get a busybox binary for your phone, it might have bash built in.
If you can get a busybox binary for your phone, it might have bash built in.
There is a busybox package on Google Play, but I checked the list of busybox commands and I noticed that my phone already has some of them, and I am afraid of overwriting something. I guess busybox is just one executable, right? Still, I'm afraid the phone might try to execute one thing and execute another. I don't know, I'm not sure it's a good idea. I just wanted to be able to source my .profile file and have aliases, and then I got curious about what shell is running.
Quote:
Originally Posted by boughtonp
Searching for "android shell" reveals that it used to be Almquist (ash) and is now MirBSD Korn Shell (mksh)
I used to be familiar with mksh... a very long time ago. I even subscribed to the mailing list. I will catch up on some reading and see if I can find some interesting feature I'd like to try on the phone.
There is a busybox package on Google Play, but I checked the list of busybox commands and I noticed that my phone already has some of them, and I am afraid of overwriting something. I guess busybox is just one executable, right? Still, I'm afraid the phone might try to execute one thing and execute another. I don't know, I'm not sure it's a good idea.
As per the page I quoted, Android mostly uses Toybox, which is basically an inferior version of Busybox. (The page lists what commands come from where.)
Since Toybox claims to be "reasonably standards compliant", you'll probably be ok switching to Busybox once the software on the device sticks to POSIX and doesn't rely on any places where Toybox has bugs/quirks that aren't compliant, but depending on what features you want, you might be able to get away with just using Toybox.
Application shell (or app shell) architecture in an Android is a way to create a progressive web app that loads on your users' screens reliably and instantly as you would see in a native application
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818
Rep:
Quote:
Originally Posted by lucmove
Even explicitly running 'sh .profile' doesn't work.
Try "source .profile" and see if your alias is still defined. I would expect that "sh" command you tried to create a new process, execute the contents or .profile, and then exit. After that process disappears, so does anything set up by .profile.
On my Android phone, if I issue "sh -v", I get a bit of text telling me that the shell is based on mksh and that I have several aliases defined around 'ls':
Code:
l='ls'
la='l -a'
ll='l -l'
lo='l -a -l'
I haven't tried installing an SSH server on my phone but I have a couple of terminal emulators that I've used (rarely) in the past. Sadly, after either my switch to another carrier or the recent upgrade to Android 12 they don't seem to work as I remember. Most everything I try to "ls" simply gives me a "Permission denied" error. That's not what I used to see. YMMV, I guess.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.