Alias in /etc/rc.local and telnet

I've inserted the command alias ls1='ls --color=none' in /etc/rc.local but when I connect to the router via telnet and run ls1 I get not found error.
What am I doing wrong?

What version of OpenWrt are you running?

Telnet hasn't been included in years.

It's more a general Linux question.
rc.local is executed in a shell that dies imediately after it's done, so your alias is gone with it.

Maybe this might help: https://www.tecmint.com/understanding-shell-initialization-files-and-user-profiles-linux/

2 Likes

On a traditional Linux system, custom aliases are usually put in .bashrc or .bash_profile in the home directory. OpenWrt by default uses the ash shell instead of bash, so you might be able to put your aliases in /root/.profile or /etc/profile and they should execute after you login.

1 Like
mkdir -p /etc/profile.d
cat << "EOF" > /etc/profile.d/alias.sh
alias ls1='ls --color=none'
EOF

Thank you.

1 Like

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