When I start bash or any other shell, it has no history. Do you have any idea what I can do about it? I'm trying to use the upwards arrow and it has no effect if I start a new shell with OpenBSD or Ubuntu xenial.

I tried every configuration that was mentioned, I set $HISTFILE in my .profile , I logged out and logged in again and I use two different operating systems.

This is exactly my configuration and how I log in and have no history per deafult:

developer@1604:~$ ssh -l root -p 2223
root@'s password: 
Last login: Sat Aug 19 01:34:14 2017
OpenBSD 6.1 (GENERIC) #19: Sat Apr  1 13:42:46 MDT 2017

Welcome to OpenBSD: The proactively secure Unix-like operating system.

Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code.  With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.

# history                                                               
ksh: fc: no history (yet)
# more .profile                                                                
# $OpenBSD: dot.profile,v 1.9 2010/12/13 12:54:31 millert Exp $
# sh/ksh initialization

export PATH
: ${HOME='/root'}
export HOME
umask 022

case "$-" in
*i*)    # interactive shell
        if [ -x /usr/bin/tset ]; then
                if [ X"$XTERM_VERSION" = X"" ]; then
                        eval `/usr/bin/tset -sQ '-munknown:?vt220' $TERM`
                        eval `/usr/bin/tset -IsQ '-munknown:?vt220' $TERM`
  • 2
    If you are still having problems getting command line history to work for the OpenBSD ksh shell, you should add your shell config files to the question.
    – Kusalananda
    Aug 25 '17 at 20:58
  • 1
    – Jeff Schaller
    Aug 25 '17 at 21:03
  • Does up-arrow do nothing or does it give ^[[A?
    – Jeff Schaller
    Aug 25 '17 at 21:04
  • 2
    I'm not convinced it's not readline/ terminal interaction vs lack of history. Dj, can you run "history" and see previous commands?
    – Jeff Schaller
    Aug 25 '17 at 21:11
  • 2
    Is you home directory writable by you? What gives ls -ld ~; id -un ?
    – xhienne
    Aug 25 '17 at 21:24

Your ~./profile does not enable saving the history at the moment (there is no setting of HISTFILE anywhere in there).

For the OpenBSD ksh shell in the base system:

Edit your ~/.profile file and add the following line:

export ENV="$HOME/.kshrc"

Then edit ~/.kshrc and add the following lines:

set -o emacs

This should be enough. The set -o emacs is to make the arrow keys work as you expect them to (you had issues with this I believe).

It is also enough to just set HISTFILE="$HOME/.ksh_history" directly in .profile if you wish to avoid using a separate file for interactive shells.

You may also specify the number of history entries that you'd like to save with, e.g.,


The default value of HISTSIZE is 500.

This is more or less what I wrote in my previous answer too.

There is currently (late Aug 2017) a flurry of CVS commits to the OpenBSD ksh implementation, to implement various history-related features such as HISTCONTROL, ignoredups and ignorespace (as available in e.g. bash).

  • 1
    This was the solution. I'm going to doublecheck it, but now history works :-)
    – Niklas R.
    Aug 31 '17 at 3:32

Append these lines to your ~/.bashrc

set -o history
shopt -s histappend

Then enter the command source .bashrc, and then enter a few random commands. See if now you have a history (enter history at the command line, or use the up-arrow).

  • The OP has tagged this Question amongst other things with ubuntu and openbsd. So I have ubuntu and a working bash history, but I don't have in my ~/.bashrc the 1st line and the 2nd line differs from my. So is this really related to ubuntu?
    – John Goofy
    Aug 26 '17 at 13:46
  • 1
    @JohnGoofy The first two lines shouldn't be necessary (regardless of OS) as the history option is turned on by default in interactive shells, and the HISTFILE variable is likewise set by default. The reason he has them there is to make sure they actually are active in case some system configuration file (e.g. /etc/profile) disables them.
    – Kusalananda
    Aug 26 '17 at 16:20
  • @Kusalananda Yes, exactly. Also, I was hoping OP would follow instructions, "See now if you have a history", for if it didn't work, there are other things to try. But so far, OP is silent.
    – gracious1
    Aug 26 '17 at 16:55
  • I don't get a history no matter what I do. I don't understand why.
    – Niklas R.
    Aug 27 '17 at 13:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.