Linux nano and pico command

Updated: 03/06/2020 by Computer Hope
pico command

On Unix-like operating systems, pico is a simple text editor in the style of the pine e-mail composer.


On modern Linux systems, nano (the GNU version of pico) is installed by default. It's identical to pico. In all the commands listed here, you can use "nano" instead of "pico" on Linux.


GNU nano

Pico (available on modern Linux systems as nano) is a simple, display-oriented text editor. Commands and their Control key shortcuts are displayed at the bottom of the screen. As characters are typed they are immediately inserted into the text.

Editing commands are entered using Control key shortcuts. As a workaround for communications programs that swallow certain control characters, you can emulate a control key by pressing Escape twice, followed by the desired control character. For example, "Esc Esc c" would be equivalent to entering a ctrl-c. The editor has five basic features: paragraph justification, searching, block cut/paste, a spelling checker, and a file browser.

Paragraph justification (or filling) takes place in the paragraph that contains the cursor, or, if the cursor is between lines, in the paragraph immediately below. Paragraphs are delimited by blank lines, or by lines beginning with a space or tab. Unjustification can be done immediately after justification using the control-U key combination.

String searches are not sensitive to case. A search begins at the current cursor position and wraps around the end of the text. The most recent search string is offered as the default in subsequent searches.

Blocks of text can be moved, copied or deleted with creative use of the command for mark (ctrl-^), delete (ctrl-k) and undelete (ctrl-u). The delete command will remove text between the "mark" and the current cursor position, and place it in the "cut" buffer. The undelete command effects a "paste" at the current cursor position.

The spell checker examines all words in the text. It then offers each misspelled word for correction while highlighting it in the text. Spell checking can be cancelled at any time. Alternatively, pico will substitute for the default spell checking routine a routine defined by the SPELL environment variable. The replacement routine should read standard input and write standard output.

The file browser is offered as an option in the "Read File" and "Write Out" command prompts. It is intended to help in searching for specific files and navigating directory hierarchies. File names with sizes and names of directories in the current working directory are presented for selection. The current working directory is displayed on the top line of the display while the list of available commands takes up the bottom two. Several basic file manipulation functions are supported: file renaming, copying, and deletion.


pico [ options ] [ file ]


+n Causes pico to be started with the cursor located n lines into the file. (Note: no space between "+" sign and number)
-a Display all files including those beginning with a period (.).
-b Enable the option to Replace text matches found using the "Where is" command.
-d Rebind the "delete" key so the character the cursor is on is rubbed out rather than the character to its left.
-e Enable file name completion.
-f Use function keys for commands. This option supported only in conjunction with UW Enhanced NCSA telnet.
-h List valid command line options.
-j Enable "Goto" command in the file browser. This enables the command to permit explicitly telling pilot which directory to visit.
-g Enable "Show Cursor" mode in file browser. Cause cursor to be positioned before the current selection rather than placed at the lower left of the display.
-k Causes "Cut Text" command to remove characters from the cursor position to the end of the line rather than remove the entire line.
-m Enable mouse functionality. This only works when pico is run from within an X Window System xterm window.
-nn The -nn option enables new mail notification. The n argument is optional, and specifies how often, in seconds, your mailbox is checked for new mail. For example, -n60 causes pico to check for new mail once every minute. The default interval is 180 seconds, while the minimum allowed is 30. (Note: no space between "n" and the number)
-o dir Sets operating directory. Only files within this directory are accessible. Likewise, the file browser is limited to the specified directory subtree.
-rn Sets column used to limit the "Justify" command's right margin.
-s speller Specify an alternate program spell to use when spell checking.
-t Enable "tool" mode. Intended for when pico is used as the editor within other tools. pico will not prompt for save on exit, and will not rename the buffer during the "Write Out" command.
-v View the file only, disallowing any editing.
-version Print pico version and exit.
-w Disable word wrap (thus allow editing of long lines).
-x Disable keymenu at the bottom of the screen.
-z Enable ^Z suspension of pico.
-p Preserve the "start" and "stop" characters, typically Ctrl-Q and Ctrl-S, which are sometimes used in communications paths to control data flow between devices that operate at different speeds.
-Q quotestr Set the quote string. Especially useful when composing email, setting this allows the quote string to be checked for when justifying paragraphs. A common quote string is "> ".
-q Termcap or terminfo definition for input escape sequences are used in preference to sequences defined by default. This option is only available if pico was compiled with the TERMCAP_WINS define turned on.
-setlocale_ctype Do setlocale(LC_CTYPE) if available. Default is to not do this.
-no_setlocale_collate Do not do setlocale(LC_COLLATE). Default is to do this.

When a running pico is disconnected (i.e., receives a SIGHUP signal), pico will save the current work if needed before exiting. Work is saved under the current file name with ".save" appended. If the current work is unnamed, it is saved under the file name "".


pico myfile.txt

Launches the pico editor, and opens the file myfile.txt for editing.

ed — A simple text editor.
emacs — A highly extensible text editor.
ex — Line-editor mode of the vi text editor.
pine — A client for using mail and newsgroups.
vi — Text editor based on the visual mode of ex.
vim — An advanced version of vi.