Custom command in OpenWrt

Hi All

is there a way of setting up custom command in OpenWRT. I would like to link bash script to custom command.

Something like adding an alias in .bashrc file in Debian i am looking for...

Thank you.

Adding alias to /etc/.profile ?

note that by default there is no bash, but "ash" built into busybox.

Thank you for your reply.

Adding alias command="/mnt/usb/" to /etc/.profile does not work.

Any other ideas?

mkdir -p /etc/profile.d
cat << "EOF" > /etc/profile.d/
sys_info() {
    ubus call system board
alias ip="ip -color=auto"
. /etc/profile

looks like you can put an alias under:


works fine for me.

Old info and a typo :frowning:

I meant /etc/profile, but aliases have been moved to /etc/shinit lately (in master):

See this commit for explanations:;a=commitdiff;h=12020f8a95d21547bd7d7fd1fef9cdecf2892803

Current contents:

root@router1:~# cat /etc/shinit
[ -x /bin/more ] || alias more=less
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi

alias ll='ls -alF --color=auto'

[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc

[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }

service() {
        [ -f "/etc/init.d/$1" ] || {
                echo "service "'"'"$1"'"'" not found, the following services are available:"
                ls "/etc/init.d"
                return 1

[ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"
[ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc"

The only downside of putting an alias under ~/.profile is that the autocomplete (tab key) does not take aliases under consideration. Is there any way to fix that?

If you place it into ~/.bash_aliases and place the script on your path, then tab should work.
You could also just create a script without an extension, but with chmod 700, and it will execute.

OpenWrt is a linux system, so one can create aliases and scripts as they normally would in Linux environment. The only tricky bit is that OpenWrt uses ash by default instead of bash, but you can install bash or zsh and make it your default shell if you prefer.


Whatever i put into ~/.bash_aliases it does not work:

I have put test alias:

alias abc="echo 123"

It does not work and you cannot tab it also...

I would also like to avoid installing other shells...

Anyone else has an idea how to get to work aliases with tab?

Thank you.

Which shell are you using? The default shell is ash, so your bash-related config won't have any effect. You should either install bash and make it your default shell, or put your alias commands in /root/.profile. Also, make sure to log out and in again to reload a fresh instance of your shell environment with your new aliases.

Thank you for you reply.

I am using ash. I would like to stay with ash. When i put alias into /root/.profile it works but you cannot "tab" it writing few first letter and pressing tab.

My question is if there is any way for force ash to "tab" aliases?

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.