What's new

How can I make zsh my (optional...) default shell?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

XIII

Very Senior Member
Since I prefer zsh above (b)ash, I would like to make it the default shell on my router (like it is on my Mac and Raspberry Pi).

However, since zsh is provided by Entware, it might not be available if the USB drive did not mount?

How can I make zsh my default shell, but only if zsh can be found at /opt/bin/zsh?
 
I suggest you put the relevant code in /opt/etc/profile rather than /etc/profile. Just seems a more logical place if you're concerned whether or not Entware is available.
 
I actually put it in ~/.profile:

Code:
if [[ -x /opt/bin/zsh ]]; then
  export SHELL=/opt/bin/zsh
  exec /opt/bin/zsh
fi

That should also be safe, right?
 
That should also be safe, right?
No. Unlike a normal Linux distribution the user's (admin) home directory (~) is in tempfs so it disappears when the router is rebooted. The same would be true for any changes made directly to /etc/profile, but in that case it can be modified with a /jffs/configs/profile.add file. Obviously any changes to /opt/etc/profile are persistent because it resides on the USB drive.
 
Last edited:
I painfully learned that just now...

After a reboot all my work of today was gone! (luckily I made a backup of the configuration files)

How can I make my zsh, Oh-My-Zsh, and Powerlevel10K installs (boot) persistent? (if at all?)
 
How can I make my zsh, Oh-My-Zsh, and Powerlevel10K installs (boot) persistent? (if at all?)

You can mount your home folder after the USB is mounted with something like this in /jffs/scripts/post-mount
Code:
[ -d "$1/entware/root" ] && mount -o bind $1/entware/root /home/root
Customize any paths if needed. Then when you ssh in all your home stuff is still there.

You may also need/want the following for convenience...
Code:
ln -nsf /home/root /home/$(nvram get http_username)
 
Code:
[ -d "$1/entware/root" ] && mount -o bind $1/entware/root /home/root
I tried this:
Code:
mount -o bind /tmp/mnt/usb/home/root /home/root

That seemed to work, but has the negative side effect that I can no longer SSH into the router using my private key...

I already checked that ~/.ssh/authorized_keys still is OK and restarted the SSH daemon, without any luck...

If I "umount /home/root", the SSH key works again...

Why would this happen? How can I fix it?
 
Last edited:
Oh, this might be related:
Code:
Feb 17 18:25:23 ac86u dropbear[8091]: /root must be owned by user or root, and not writable by others

EDIT: Yes; solved (by removing rwx attributes for group/others).
 
Oh, this might be related:
Code:
Feb 17 18:25:23 ac86u dropbear[8091]: /root must be owned by user or root, and not writable by others

EDIT: Yes; solved (by removing rwx attributes for group/others).
Hey!

Just found your post and I'm having the same permissions issues.

Bash:
total 172
d-w-------  5          700 root  4096 Apr 12 07:59 .
drwxr-xr-x  3 orpheustelos root    80 Apr 12 07:36 ..
d-w-------  3 orpheustelos root  4096 Apr 12 07:42 .config
--w-------  1 orpheustelos root    57 Mar 18  2021 .inputrc
-rw-rw-rw-  1 orpheustelos root  7754 Apr 12 07:57 install.sh
drwxr-xr-x 12 orpheustelos root  4096 Apr 12 07:57 .oh-my-zsh
--w-------  1 orpheustelos root   111 Apr 12 07:58 .profile
d-w-------  2          700 root  4096 Apr 12 07:38 .ssh
-rw-rw-rw-  1 orpheustelos root 39696 Apr 12 07:58 .zcompdump-OVERNET-5.9
-r--r--r--  1 orpheustelos root 92096 Apr 12 07:58 .zcompdump-OVERNET-5.9.zwc
-rw-------  1 orpheustelos root    49 Apr 12 07:59 .zsh_history
-rw-r--r--  1 orpheustelos root  3866 Apr 12 07:57 .zshrc
➜  ~

I think I set things correctly, but I'm still not able to get passkey authentication to work again, would you happen to remember which commands you used?
 
I think I set things correctly, but I'm still not able to get passkey authentication to work again, would you happen to remember which commands you used?

Bash:
chown -R admin /root/
chmod -R go-rwx /root/
Replace "admin" above by your actual username (if it's not admin).
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top