Technical skill

Linux command: pico

Edit a text file in a terminal

A text editor lets you write or change words saved in a file. Pico is a small editor that runs inside a terminal, the text-based window where you can type commands. It can be useful for a quick note or a settings file when you do not need a graphical editor. To open a file named notes.txt, type pico notes.txt. Pico opens the existing file or gives you a new, unsaved page if the name is not there yet.

Pico shows its commands along the bottom edge. A caret in that menu is a way to write “Control”: ^O means press Ctrl+O. Try a temporary file first with pico /tmp/notes.txt. Use the arrow keys to move and type a short line. Press Ctrl+O, often labeled “Write Out,” to save; check the path Pico shows, then press Enter. Press Ctrl+X to leave. If you changed the text without saving, Pico asks whether to save it. Open the file with cat or less afterward to confirm that the text went where you expected.

Search, cut, and put text back

Ctrl+W searches from the cursor's current position. “Read File” and “Write Out” also offer a file browser. Ctrl+K cuts the current line or a marked block into Pico's cut buffer; Ctrl+U puts that text back at the cursor. The menu gives a reminder of keys, and Ctrl+G opens help on builds with the standard binding.

Pico began as the editor in the Alpine email composer and can also edit files on its own. If pico is missing, command -v pico checks whether the command is available. Package names differ by distribution; Debian, for example, provides alpine-pico. Nano has similar Pico-style commands, but it is a separate editor and some details differ. Control-key bindings can also vary by Pico build or terminal. If a key seems not to work, check the editor's help for an Escape-based alternative supported by that build.

Be careful when saving system settings

Pico saves the file when you choose Write Out; it does not check whether the text is a valid configuration. A saved service or network setting can affect a running system after the application reloads or restarts. Check the path and account permissions before editing, keep a recoverable copy according to local procedures, and run the application's configuration checker when one is available. Use elevated privileges only for files that require them. If you only need to inspect a broad system file, Pico's view-only option is -v. The installed manual explains the key bindings and options for the version on your system.

Interactive exercises

Materials

Skillsets
Skillset Devops preview
image descriptionDevops
by Dio
3 users
Skillset Linux administrator preview
image descriptionLinux administrator
by Infinite Education
3080 users
Skillset Devops preview
image descriptionDevops
by Ajay Kumar
2004 users
Skillset Linux for backend developer preview
image descriptionLinux for backend developer
by Artem Naumenko (fb)
16 users
Skillset Skyeng SRE preview
image descriptionSkyeng SRE
by Yuliya Marochkina
12 users
Skillset Skyeng Senior PlatOps preview
image descriptionSkyeng Senior PlatOps
by Artem Naumenko (slack2)
7 users
Skillset Skyeng Ops (for DevOps) preview
image descriptionSkyeng Ops (for DevOps)
by Roman Burnashev
2 users
Do you know that ...?
Any useful or interesting facts about the skill. Any peace of information would be useful