On a FreeBSD machine that I've used, the up arrow key brings up the previous command BASED on the letters already typed. However on a CentOS machine that I'm using, the up arrow key simply bring up the immediate previous command.

Anyone knows if there is anyway to set it like FreeBSD's up arrow key for CentOS?

Thanks a lot.

  • What shell are you using? – Rob Jones Sep 1 '09 at 21:21
  • 2
    Needs to be moved to superuser. – Vineet Reynolds Sep 1 '09 at 21:37

The behavior you're describing is based on your shell.

The default shell in CentOS is bash: you can confirm this by typing the following:

$ echo $SHELL

If it is, then you can get similar functionality to your FreeBSD shell (most likely ksh) by hitting CTRL-r. You'll see something like this:


Simply start typing and you'll get the commands you've previously run based on what you've typed.

For example, in this terminal, when I type CTRL-r s I get this:

(reverse-i-search)`s': sudo port install ruby

You can then scroll up or down with the arrow key to go through all the commands that match your search criteria (in this case, 's').

  • 1
    Thanks! Hehe, I actually know about Ctrl+r. But, it searches for pattern right? So, if I type p, all the previous commands that CONTAINS "p" will show. What I really want is the command that STARTS with "p" (like the behavior in csh). The latter proves to be faster for me at least. – Dave Sep 1 '09 at 21:42
  • Honestly, I just use Bash Completion to cheat around that :). freshmeat.net/projects/bashcompletion – mando Sep 1 '09 at 21:51

You could also configure a private ~/.inputrc file for your bash like this:

"\e[5~": history-search-backward
"\e[6~": history-search-forward

Now the page-up key searches backward and page-down forward in the history. This is what I use. (You need to restart the shell for it to take effect.)

Press CTRL+V followed by KEY to determine the key sequence if you want to bind the shell commands to another KEY (instead of page-up/page-down).


The default shell under FreeBSD is CSH. There should be a package for it in CentOS (consult your package-manager for this).

HOWTO: Download and Install csh / tcsh shell on Linux


This is defined by your shell. You can determine which shell you are using by typing: echo $0

In FreeBSD, you are typically running csh (which was invented at Berkeley, the home of BSD). In Linux, you typically run bash. You can get the 'up-arrow' behavior by switching to the emacs history editing mode. Try typing: set -o emacs in your terminal.

If you like this behavior, you can edit your $HOME/.bashrc file, and add that line, and you will have in every shell

  1. Install tcsh as @flokra mentioned.
  2. Place a .cshrc file in your home directory. Inside of that file configure tcsh to show a list of matches to the partially typed command when you press the up or down arrow. Use http://svnweb.freebsd.org/base/stable/9/share/skel/dot.cshrc?revision=244007&view=co&pathrev=244007 as a guide, but what you are looking for is:

    bindkey -k up history-search-backward
    bindkey -k down history-search-forward

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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