#!/system/bin/sh1
alias lsa='ls -Alh '
[...]
/system/bin/sh1
There is no such file. In fact, the default shell is sh, not bash.
However, there is a solution. Read my post in this thread: http://xdaforums.com/showthread.php?t=518959
There is no such file. In fact, the default shell is sh, not bash.
However, there is a solution. Read my post in this thread: http://xdaforums.com/showthread.php?t=518959
Android's default shell /system/bin/sh is a link to mksh in the same directory. It reads /system/etc/mkshrc & ~/.mkshrc
I think it also reads ~/.profile & /etc/profile but I'm not sure & I don't know what order.
See https://www.mirbsd.org/mksh.htm for the documentation.
Also worth noting is that most, if not all, shells read /etc/profile & ~/.profile so anything in there should be very general.
That is interesting. I'll have to try it. I assume it won't work with ADB?
mac $ alias ll
alias ll='\ls -albhFG'
mac $
mac $ adb shell
shell@htc_a11chl:/ $ ll
drwxr-xr-x root root 2016-10-03 13:10 acct
lrwxrwxrwx root root 2016-10-03 13:24 busybox -> /data/data/com.jrummy.app.managerfree/files/busybox
drwxrwx--- system cache 2016-10-03 14:37 cache
drwxrwx--x system carrier 2016-09-02 15:24 carrier
dr-x------ root root 2016-10-03 13:10 config
mac $ adb shell ll
/system/bin/sh: ll: not found
uname -a: Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux
root@debian:/# adb root #restart adb with root permissions
root@debian:/# adb remount #remount partitions on device read-write
remount succeeded
root@debian:/# adb shell #run remote, interactive shell
device:/ # test0 #execute command test0
/system/bin/sh: test0: not found
127|device:/ # alias test0='date'
device:/ # test0
Wed Oct 10 15:06:16 +00 2018 #SUCCESS
root@debian:/# adb root
adbd is already running as root
root@debian:/# adb remount
remount succeeded
root@debian:/# adb shell
klteusc:/ # test1
/system/bin/sh: test1: not found
127|klteusc:/ # echo "alias test1='date'">>/system/etc/mkshrc
klteusc:/ # test1
/system/bin/sh: test1: not found
127|klteusc:/ # exit
root@debian:/# adb shell
klteusc:/ # test1
Wed Oct 10 15:10:41 +00 2018
klteusc:/ # exit
root@debian:/# adb root
adbd is already running as root
root@debian:/# adb remount
remount succeeded
root@debian:/# adb shell
klteusc:/ # test2
/system/bin/sh: test2: not found
127|klteusc:/ # echo "alias test2='date'">>/system/etc/bash/bashrc
klteusc:/ # test2
/system/bin/sh: test2: not found
127|klteusc:/ # exit
root@debian:/# adb shell
klteusc:/ # test2
/system/bin/sh: test2: not found
Code:uname -a: Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux root@debian:/# adb root #restart adb with root permissions root@debian:/# adb remount #remount partitions on device read-write remount succeeded root@debian:/# adb shell #run remote, interactive shell device:/ # test0 #execute command test0 /system/bin/sh: test0: not found 127|device:/ # alias test0='date' device:/ # test0 Wed Oct 10 15:06:16 +00 2018 #SUCCESS root@debian:/# adb root adbd is already running as root root@debian:/# adb remount remount succeeded root@debian:/# adb shell klteusc:/ # test1 /system/bin/sh: test1: not found 127|klteusc:/ # echo "alias test1='date'">>/system/etc/mkshrc klteusc:/ # test1 /system/bin/sh: test1: not found 127|klteusc:/ # exit root@debian:/# adb shell klteusc:/ # test1 Wed Oct 10 15:10:41 +00 2018 klteusc:/ # exit root@debian:/# adb root adbd is already running as root root@debian:/# adb remount remount succeeded root@debian:/# adb shell klteusc:/ # test2 /system/bin/sh: test2: not found 127|klteusc:/ # echo "alias test2='date'">>/system/etc/bash/bashrc klteusc:/ # test2 /system/bin/sh: test2: not found 127|klteusc:/ # exit root@debian:/# adb shell klteusc:/ # test2 /system/bin/sh: test2: not found
alias test1='date'
## Adding the test0 alias via file editing:
taimen:/ # test0
Wed Aug 5 13:09:46 GMT 2020
## Adding test1 alias via command line:
taimen:/ # alias test1='date'
taimen:/ # test1
Wed Aug 5 13:10:06 GMT 2020
## Reboot Device
taimen:/ # reboot
## Check for persistant changes:
taimen:/ # test0
Wed Aug 5 13:04:24 GMT 2020
taimen:/ # test1
/system/bin/sh: test1: not found
# Copyright (c) 2010, 2012, 2013, 2014
# Thorsten Glaser <tg@mirbsd.org>
# This file is provided under the same terms as mksh.
#-
# Minimal /system/etc/mkshrc for Android
#
# Support: https://launchpad.net/mksh
: ${HOSTNAME:=$(getprop ro.product.device)}
: ${HOSTNAME:=android}
: ${TMPDIR:=/data/local/tmp}
export HOSTNAME TMPDIR
alias test0="date"
if (( USER_ID )); then PS1='$'; else PS1='#'; fi
PS4='[$EPOCHREALTIME] '; PS1='${|
local e=$?
(( e )) && REPLY+="$e|"
return $e
}$HOSTNAME:${PWD:-?} '"$PS1 "
There is no such file. In fact, the default shell is sh, not bash.
However, there is a solution. Read my post in this thread: http://xdaforums.com/showthread.php?t=518959
Android's default shell /system/bin/sh is a link to mksh in the same directory. It reads /system/etc/mkshrc & ~/.mkshrc
I think it also reads ~/.profile & /etc/profile but I'm not sure & I don't know what order.
See https://www.mirbsd.org/mksh.htm for the documentation.
Also worth noting is that most, if not all, shells read /etc/profile & ~/.profile so anything in there should be very general.