Featured image of post Compile and Install zsh from Source without sudo Permission

Compile and Install zsh from Source without sudo Permission

Compile and install zsh from source without sudo permission

Motivation

The default shell on the school’s computing cluster is bash, and my commonly used zsh is not available. It feels very uncomfortable without auto-completion and syntax highlighting. Moreover, ordinary accounts do not have administrative privileges and cannot use sudo to install zsh directly through package management tools. Therefore, it is necessary to compile and install zsh from source.

Install Dependency ncurse

The ncurse library (new curse) is an interface library that supports text-based user interfaces, and zsh depends on this library at runtime. Therefore, it is necessary to install the ncurse library before installing zsh.

  1. Download ncurse version 6.1 (the latest version at the moment)

    1
    
    wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz --no-check-certificate
    
  2. Extract and enter the extracted directory

    1
    2
    
    tar xvfz ncurses-6.1.tar.gz
    cd ncurses-6.1
    
  3. Configure the build

    1
    
    ./configure --prefix="$HOME/software" CXXFLAGS="-fPIC" CFLAGS="-fPIC"
    

    Here, the installation directory is specified as the software folder under the user’s home directory.

  4. Compile and install

    1
    
    make && make install
    

Install zsh from Source

  1. Download the latest version of zsh

    1
    
    wget -O zsh.tar.xz https://sourceforge.net/projects/zsh/files/latest/download --no-check-certificate
    
  2. Extract and enter the extracted directory

    1
    2
    
    tar xvfz -C zsh zsh.tar.xz
    cd zsh
    
  3. Configure the build

    1
    
    ./configure --prefix="$HOME/software" CPPFLAGS="-I$HOME/software/include" LDFLAGS="-L$HOME/software/lib"
    

    Here, the installation directory is specified as the software folder under the user’s home directory.

  4. Compile and install

    1
    
    make && make install
    
  5. Finally, add the zsh binary folder to the system environment

    1
    
    export PATH=$HOME/software/bin:$PATH
    

    You can also add this line to the bash configuration file .bashrc.

Install and Configure oh-my-zsh

Please refer to “oh-my-zsh Configuration for Command Line Users”.

Licensed under CC BY-NC-SA 4.0
Last updated on Jul 17, 2025 00:00 UTC
comments powered by Disqus