When editing files in a GNU/Linux system, beginning users will want to utilize the program Pico as their text editor. For the most part, Pico (short for Pine composer), is a simple and straightforward program. This document will guide you through creating, editing, and saving a text file using Pico. For more advanced users, Vim and Emacs are also available on our systems.
Creating/Editing a File
Creating and editing a file is easy in Pico. Let's say that you want to create or edit a file called "important_information" in your current folder. All you need to do is run this command:
After you press enter, Pico will launch a document called "important_information." If this file already exists, you should see the current contents of the file. If it doesn't already exist, you are now editing a blank file called "important_information." Once you save the file, it will be created.
Saving a File
Pico contains a list of commands at the bottom of the terminal: that's a handy feature. To save screen space, Pico uses the character ^ to denote pressing the "ctrl" key. Assuming you already have the file "important_information" open from the previous step, here's how to save that file:
- Press ctrl+o to "write out" your file to disk. This is another way of saying "save the file."
- You should then get a confirmation that asks the file name to write. Unless you want to change the filename, press "enter."
- That's it! Your file is saved. You can now press ctrl+x to exit pico.
Useful Commands and Shortcuts
Pico has a number of useful commands that you can use to save time and use in special situations. Here are just a few of these features:
- Built in help: Pico features a built-in help system. By pressing ctrl+g, you will see a listing of commands.
- Turning off word wrap: You can turn off word wrap for Pico by opening a file using the -w flag, like this: pico -w file
- Searching for text: You can use ctrl+w to search for text in a document.
- Using Page Up/Page Down: Your Page Up and Page Down keys will scroll through a page of text. You can also use ctrl+y and ctrl+v to scroll up and down.
When you open a file in Pico that does not already exist, you will see something like the screenshot below. The command used was:
If you run the command pico without any file name, it will load a blank document that will look much like the screenshot below as well.
When you open a file in Pico that already exists, you will see something like the screenshot below. The command used was:
If you would like to learn more about Pico and working with UNIX files, the following sites are good places to start:
If you spend a lot of time using Pico and would like to use a more powerful editor, consider learning about Vim and/or Emacs. These editors are much more powerful than Pico and while they have a larger learning curve than Pico, are much more efficient once you get used to them. Both are installed on the UW's clusters.