How to Change Default Shell to ZSH/Bash on BusyBox Systems Without chsh Command


2 views

When working with embedded systems like Synology NAS devices running BusyBox, shell management becomes tricky due to the stripped-down nature of the environment. The standard chsh utility is typically missing, and package managers like ipkg won't automatically set the new shell as default during installation.

The most reliable approach is to manually edit the user configuration file:

# First, verify zsh installation path
which zsh
/opt/bin/zsh

# Edit the password file (requires root)
vim /etc/passwd

Locate your user entry (typically at the end of the file) and modify the shell path:

# Original entry (using ash):
username:x:1000:1000:User,,,:/home/username:/bin/ash

# Modified entry (using zsh):
username:x:1000:1000:User,,,:/home/username:/opt/bin/zsh

For temporary changes or testing purposes, you can force shell execution at login:

# Add to ~/.profile
if [ -x /opt/bin/zsh ]; then
    exec /opt/bin/zsh
fi

After making changes, verify with:

# Check current shell
echo $SHELL

# Confirm shell process
ps -p $$
  • Always make backups of /etc/passwd before editing
  • Ensure the shell path is absolute and executable
  • Some services may still use ash for system scripts
  • Changes may require a logout/login cycle to take effect

When working with resource-constrained systems like Synology NAS running BusyBox, shell management becomes non-trivial. The absence of standard utilities like chsh requires alternative approaches to modify the default shell.

The most reliable approach involves manual editing of the system's password file:

# First, verify zsh installation path
which zsh
# Output example: /opt/bin/zsh

# Backup the passwd file
cp /etc/passwd /etc/passwd.bak

# Edit the user entry (replace 'admin' with your username)
vi /etc/passwd
# Change: admin:x:1024:100:...:/var/services/homes/admin:/bin/ash
# To:    admin:x:1024:100:...:/var/services/homes/admin:/opt/bin/zsh

For systems where editing system files is restricted:

# Create symlink from default shell path to preferred shell
ln -sf /opt/bin/zsh /bin/sh

# Verify the change
ls -l /bin/sh
# Should show: /bin/sh -> /opt/bin/zsh

A temporary solution for testing purposes:

# Add to ~/.profile or ~/.bashrc
export SHELL=/opt/bin/zsh
exec /opt/bin/zsh

After making changes:

# Check current shell
echo $SHELL

# Verify shell process
ps -p $$

Common issues include:

  • Permission errors (use sudo or root account)
  • Invalid shell path (verify with which zsh)
  • Read-only filesystem (common in NAS devices)

On Synology systems, modifications might revert after reboots. Consider creating a startup script:

# /usr/local/etc/rc.d/set_zsh.sh
#!/bin/sh
ln -sf /opt/bin/zsh /bin/sh
chmod 0755 /bin/sh