In NetBSD /bin/sh is a modified version of the Almquist shell. With the command fc -l it is possible to view the last 16 commands typed in the prompt in the current session and not the older ones.

The environment variable HISTSIZE is set at 1000 and in bash this means that the last 1000 commands (whether or not they were typed in the current session) are saved in a file named .bash_history in the home directory. But here it seems to mean just that the last 1000 commands in this session are keeped in the history, and the history does not seem to be saved in a file.

I am looking for a history which allows not only to read the last commands of the current session, but also the commands of the previous sessions (for example, the previous time I started the system, not the actual time). Does /bin/sh in NetBSD have by default such an history? If not, is it possible to create such an history in that shell?

  • So you need the file where ash(1) saves its history?
    – schaiba
    Jun 16, 2014 at 13:41
  • Yes, the NetBSD version of ash, if such a file exists!
    – BowPark
    Jun 16, 2014 at 14:07
  • It seems to be using libedit - so it might be for example ~/.history. In any case you can try to find out the file name by spawning a shell, issuing a couple of benign commands, exiting and looking for recently modified files. If history will have been written, you'll see it with something like find ~ -cmin -5.
    – peterph
    Jun 16, 2014 at 15:40
  • I tried to do this, but the find command does not identify any modified file. I tried also to put HISTFILE=~/.history, but after some commands the file had not even been created.
    – BowPark
    Jun 16, 2014 at 15:54
  • 1
    NetBSD offers /bin/ksh which is an enhanced shell which is otherwise more or less backward compatible with /bin/sh, and you'll find some clues in the fine manual for ksh(1) about how it supports storing and reloading command history to/from a file. Feb 10, 2016 at 20:51

1 Answer 1


I don't really understand your question, what's the actual question?

First you are stating that you can access the history via the fc builtin and then you are asking if the shell implements a history?

Furthermore, the man page states:

The number of previous commands that can be accessed are determined by the value of the HISTSIZE variable.


A login shell first reads commands from the files /etc/profile and .profile if they exist. If the environment variable ENV is set on entry to a shell, or is set in the .profile of a login shell, the shell next reads commands from the file named in ENV. Therefore, a user should place commands that are to be executed only at login time in the .profile file, and commands that are executed for every shell inside the ENV file. To set the ENV vari- able to some file, place the following line in your .profile of your home directory

      ENV=$HOME/.shinit; export ENV

substituting for .shinit any filename you wish.

If your question is whether history gets written to a file, it does not seem to be the case.

  • I modified my question to make it more clear. I was exactly asking if history gets written to a file and if it is possible to make history written to a file in this type of shell in NetBSD.
    – BowPark
    Jun 17, 2014 at 8:19
  • 1
    @BowPark It does not look like it, but since PS1 is subject to parameter expansion you could probably hack around this by doing e.g. PS1='$(fc -ln -1 2>/dev/null >>~/.history)'${your_actual_prompt}. But you should check the sh and libedit source code first if there really is no "native" way of writing to a file, despite the documentation not mentioning anything like it. Jun 17, 2014 at 8:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .