Linux Command Directory

Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.


lesskey [-o output-file | --output=output-file] [input-file]

Configure keybindings for the less command using a configuration file. The input file defaults to ~/.lesskey and the output file to ~/.less unless you specify otherwise.

Configuration file format

The configuration file for lesskey has one to three sections. These are marked by a line containing a # symbol and the name of the section: #command, #line-edit, and #env.

The #command section

The command section determines the keys used for actions within less. Each line should contain the key or key combination you wish to define, a space or tab, and the name of the action to perform. You may also add an extra string at the end, which will be performed at the end of the first action.

Keys you define should be entered as you plan to type them, with the following exceptions:

The actions that can be defined are:

invalid (creates error) noaction forw-line back-line forw-line-force forw-scroll back-scroll forw-screen back-screen forw-window back-window forw-screen-force forw-forever repaint-flush repaint undo-hilite goto-line percent left-scroll right-scroll forw-bracket back-bracket goto-end status forw-search back-search repeat-search repeat-search-all set-mark goto-mark examine next-file index-file prev-file toggle-option display-option pipe visual shell firstcmd help version (display version) digit (display number) quit
The #line-edit section

The line editing section lets you choose keys for the line-editing capabilities of less in a similar manner to the #command section, although without the "extra" string after the command. The line editing actions that can be defined are:

forw-complete back-complete expand literal right left word-left word-right insert delete word-delete word-backspace home end up down
The #env section

The third section, like the second, is optional, and you can use it to override environment variables that affect less. Each line consists of a variable, the equals sign (=), and the value to which you wish to set the variable. The most important ones are LESS, which allows you to select additional flags to pass to less when you run it, and LESSCHARSET, which lets you choose a character set. See the less manpage for a complete list of environment variables that affect the program.

More Linux resources from O'Reilly >>

Popular Topics

Browse Books & Videos

International Sites

O'Reilly China O'Reilly Germany O'Reilly Japan