How do I open, create, edit, and view a file in Linux?

There are different commands that can be used to open, create, edit, or view a file in Linux. Below is a listing of each of these commands. Click on the links for each of these commands to get additional information about them. Each of the commands have been listed in order they are most likely to be found and we suggest using. Keep in mind that some variants of Linux may also not include each of the below commands, for example, the pico command is often not included in many default installations.

View a file

cat
tail
head
pg

Note: The commands listed below are also all capable of viewing a file.

Open, create, and edit a file

pico
vi
ued
ed
vim

For users new to Linux or familiar with MS-DOS, we highly recommend using the pico command to create and edit text files. Below is an example of pico that could be used to create a file in Linux.

pico myfile.htm

In the above example, assuming the file "myfile.htm" does not exist, pico would open a blank edit page for myfile.htm. If this file did exist, pico would open any text that file contains.

Additional information

  • See the create, edit, and view definitions for other documents related links and information.