This page is currently under construction.

Why am I here?

You are here because you are either new to UNIX shells or you have a background of dealing with Linux BASH shell, however, you are totally unfamiliar with OpenBSD's default KSH shell account.

What are my options?

You can switch to BASH if you are very familiar with BASH, however it is recommended to stick with KSH as KSH is more POSIX compliant.

That said, you can also make KSH behave more like BASH, which is more preferable than switching over to BASH.

I don't like KSH at all

If you prefer to stick to BASH, the command chsh would bring up a text editor. From here, change where it shows Shell: from /bin/ksh to /usr/local/bin/bash. For example:

# Changing user database information for $user
Shell: /bin/ksh
Full Name: user
Office Location:
Office Phone:
Home Phone:


# Changing user database information for $user
Shell: /usr/local/bin/bash
Full Name: user
Office Location:
Office Phone:
Home Phone:

Afterwards, save the changes, log out and log back in, your default shell is now BASH.

Okay, so how can I make KSH more BASH-like?

I am glad to hear you want to stick with KSH. Now, currently it isn't possible to make KSH behave exactly like BASH, but, you can make it feel like you are using BASH, whilst it is actually KSH.

Editing PS1 to look more like BASH

First, you will need to edit your ~/.profile to declare the HOSTNAME variable, as the actual hostname is stored within /etc/myname. Then, you want to make sure that your ~/.profile reads its environment from your ~/.kshrc. So your ~/.profile should look something like this,

# $OpenBSD: dot.profile,v 1.5 2018/02/02 02:29:54 yasuoka Exp $
# sh/ksh initialization


HOSTNAME="$(cat /etc/myname)"
ENV="$HOME/.kshrc"; export ENV

Once you have that down, it is now time to edit your ~/.kshrc file.

function _cd {
  \cd "$@"
    print -n "$LOGNAME@$HOSTNAME:"
    if [[ "${PWD#$HOME}" != "$PWD" ]]; then
      print -n "~${PWD#$HOME}"
      print -n "$PWD"
    print "$ "

alias cd=_cd

cd "$PWD"

This piece of code came from How to custom display prompt in Korn shell to show hostname and current directory - Stack Overflow

Implement command history

This is from Stack Exchange, “For the arrow keys, you can put this into your the .kshrc file [(pdksh and mksh both use .mkshrc, not .kshrc)] in your home directory:

set -o emacs
alias __A=`echo "\020"`     # up arrow = ^p = back a command
alias __B=`echo "\016"`     # down arrow = ^n = down a command
alias __C=`echo "\006"`     # right arrow = ^f = forward a character
alias __D=`echo "\002"`     # left arrow = ^b = back a character
alias __H=`echo "\001"`     # home = ^a = start of line
alias __Y=`echo "\005"`     # end = ^e = end of line

How do I change my password?

Simply execute passwd at prompt:

$ passwd
Changing password for $user
Old password:
New password:
Retype new password:

Your chosen new password should be longer than eight (8) characters.