Bourne-Again Shell (bash)

This Sheet describes the procedure used to set up bash, a shell that is much more powerful than the default /bin/sh.

  1. Install Bash:

    # cd /usr/ports/shells/bash && make install && make clean

  2. Create /root/.bash_profile:

    # .bash_profile – Bourne Again SHell configuration file for login shells.

    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:
    /usr/local/sbin:/usr/X11R6/bin:$HOME/bin; export PATH (All one line)

    # file permissions: rwxr-xr-x
    umask 022

    BLOCKSIZE=K; export BLOCKSIZE
    EDITOR=ee; export EDITOR
    PAGER=/usr/bin/more; export PAGER

    # set ENV to a file invoked each time bash is started for interactive use.
    ENV=$HOME/.shrc; export ENV

    # some useful aliases
    alias h=’fc -l’
    alias j=jobs
    alias m=$PAGER
    alias ll=’ls -laFo’
    alias l=’ls -l’
    alias g=’egrep -i’

    # set prompt
    PS1=”===[\u] \w # ”
    PS2=”>”

    # search path for cd(1)
    # CDPATH=.:$HOME

  3. Create /root/.bashrc:

    # .bashrc – Bourne Again SHell configuration file for interactive shells.

    # file permissions: rwxr-xr-x
    umask 022

    BLOCKSIZE=K; export BLOCKSIZE
    EDITOR=ee; export EDITOR
    PAGER=/usr/bin/more; export PAGER

    # some useful aliases
    alias h=’fc -l’
    alias j=jobs
    alias m=$PAGER
    alias ll=’ls -laFo’
    alias l=’ls -l’
    alias g=’egrep -i’

    # set prompt
    PS1=”===[\u] \w # ”
    PS2=”>”

    # search path for cd(1)
    # CDPATH=.:$HOME

  4. Edit /root/.cshrc and /root/.login and add as last line in each:

    [ -x /usr/local/bin/bash ] && exec /usr/local/bin/bash

    This command allows you to use bash when logged in as root, but won’t lock you out when you drop to single-user mode and if /usr isn’t mounted.

Leave a Reply

Your email address will not be published. Required fields are marked *