How to change default shell in FreeBSD?

24,740

For existing users, use the chsh command (“change shell”):

chsh -s SHELL USER
chsh -s /usr/local/bin/bash root

For future users:

  • Edit "/etc/pw.conf" defaultshell keywords
  • When use adduser(), choose necessary shell
Share:
24,740

Related videos on Youtube

sparcboy
Author by

sparcboy

Just a DevOps, who's passionate about scaling and automation. Who doesn't want to do less job anyway? DevOps practices brought a new way to decrease maintenance for the whole company, which is basically increase of profit up to 80% in some cases! My background is mostly Python with HA web services. Currently working with Kubernetes and Terraform.

Updated on September 17, 2022

Comments

  • sparcboy
    sparcboy over 1 year

    The default shell in FreeBSD is sh and I really can't stand it: autocomplete is very limited, and rehash commands kill me. I feel like a one armed and one legged man...

    How can I change the shell globally to zsh or bash - for root and for all current and future users?

    • commbot
      commbot about 11 years
      Just tried this to update an existing user in FreeBSD 9.1 and the system prompted me to use the following: chpass -s /usr/local/bin/bash USER
  • user2751502
    user2751502 over 13 years
    ...but be careful about changing the root shell to something from the ports tree (e.g., /usr/local/bin/bash), because if you screw something up during a port upgrade you may find yourself without root access.
  • Dennis Williamson
    Dennis Williamson over 13 years
    s/feature/future/?
  • sparcboy
    sparcboy over 13 years
    larsk: zsh can be build statically right..? [at least I saw parameter in "make config"] so as far as I understand, it's a binary with all dependencies build in? so can I put /usr/local/bin/zsh to /bin/zsh ? root user can use old version it's ok.. then it would be safe?
  • user2751502
    user2751502 over 13 years
    Building it statically and copying it into /bin is probably the safest thing you can do. I just leave root's shell set to /bin/sh and then exec bash on those rare occasions when I really need to log in as root (more often I just use sudo from my user account).
  • Sopalajo de Arrierez
    Sopalajo de Arrierez over 8 years
    Note this must be run as root (or with sudo).