FreeBSD: Install zsh Shell

How do I install the Z shell ( zsh ) shell under FreeBSD 9 operating systems?

The Z shell (zsh) is a Unix shell and command interpreter for shell scripting. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.


Install zsh under FreeBSD

Type the following command as the root user to install binary zsh package. You can switch to the root user by typing su – and entering the root password, when prompted.
# pkg_add -r zsh
Sample outputs:

Fetching Done.
Updating /etc/shells

Alternatively, you can use the Freebsd ports:
# cd /usr/ports/shell/zsh
# make install clean

How do I install zsh?

Simply type zsh at the shell prompt:
$ zsh
You will get the following screen:

Unix / Linux zsh First Run Configuration

Fig.01: Configure zsh under FreeBSD

Just follow on-screen instruction to finish zsh configuration.

How do I set zsh as my default shell?

You need to use chsh command to change your default shell under Unix like operating system:
$ chsh -s zsh
$ chsh -s zsh vivek
Sample outputs:
Make sure zsh is set as a new shell for vivek user:
$ grep vivek /etc/passwd
Sample outputs:

vivek:*:1001:1001:Vivek Gite:/home/vivek:/usr/local/bin/zsh

How do I customize zsh shell?

You need to edit ~/.zshrc file. A sample ~/.zshrc file:
$ cat ~/.zshrc
Sample outputs:

setopt appendhistory autocd extendedglob
unsetopt beep
bindkey -e

Because zsh contains many features, I recommend that you go through the zsh manual page which has been split into a number of sections:
% man zsh

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

2 comments… add one
  • igariox Jul 4, 2012 @ 11:26

    Note: You have to log out and log back in, in order to start using Zsh as your default shell.

  • Mave Aug 9, 2015 @ 10:04


    where do I copy the global configuration files? In Linux it is found in “/etc/zsh/”.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.