Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the readline manual

# man readline

The following describes how to search backward and forward.

reverse-search-history (C-r)
Search backward starting at the current line and moving `up' through the history as necessary.  This is an incremental search.

forward-search-history (C-s)
Search forward starting at the current line and moving `down' through the  history  as  necessary.   This  is  an  incremental search.

When I hit ctrl+r and type "apt-get", I'm able to do a reverse-search-history by continually tapping ctrl+r. But then I tap ctrl+s and the terminal does not go forwards. Am I doing something incorrect?

Also what key does the Meta prefix "M-" represent?

share|improve this question
up vote 12 down vote accepted

The sequence C-s is taken from the terminal driver, as you can see from

stty -a | grep '\^S'

To free up the sequence for use by readline, set the stop terminal sequence to some other sequence, as for example

stty stop ^J

or remove it altogether with

stty stop undef

After that C-s would work in the given terminal.

Set it in ~/.bashrc to make it work in every terminal.

The M- sequence means the Alt key, as already noted.

share|improve this answer
^J is a good choice since for stop, it's not used for anything else – hobs Apr 2 '13 at 19:56

forward-search-history (C-s) doesn't work (though it is in the man page).

'M-' represents the Alt key modifier.

share|improve this answer
Not correct the C-s part, see my answer. – enzotib Sep 5 '11 at 12:45

Please do not use:

stty stop ^J


stty stop ^P

or anything else, as ^J makes big problems with ssh. (I do not know why anyway.) After I logged in Enter and backslash were not working. or I had to type:

stty sane 
export TERM=linux

before I wanted to type

ssh root@192...


stty stop ^P

solved both problems at the same time.

share|improve this answer

In addition to assigning a different TTY 'stop' char as suggested above, you can remove it entirely if you don't plan to use it (I tend not to), like this:

$ stty stop undef

Then readline can use control-s for forward search and you won't get any strange behavior due to a new stop char being added.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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