Skip main navigation

Text Editing and Writing to Files

how to use a text editor in Linux
© Wellcome Genome Campus Advanced Courses and Scientific Conferences

Text editing for Linux environment

GNU nano is a text editor for Unix-like environments or other operating environments using a command line/ terminal interface. Nano can also be used with pointing devices, such as a mouse to activate toolbar functions and position a cursor. Other file editing tools are available such as Emacs, vi and pico, but for the purposes of this example we’ll use the easy to use nano text editor.

To demonstrate creating a new file in nano, open a terminal and type the following example. This example creates a new file called fruit.txt

nano fruit.txt

The nano editor will launch and it’s now possible to type freely within the window.

screenshot of the nano editor open

Now enter the following data and hit the enter key after each item.

Orange, Pear, Apple, Banana, Grape, Satsuma, Melon

screenshot of the editor with fruit names typed in

Select control-x to Exit the nano editor and type y

screenshot of how to exit nano

A prompt to save the file will appear. Press the enter key to save and this will write the file to disk.

screenshot of saving file and exiting nano

This will return you back to the terminal window. Typing ls will show you the new fruit.txt file you have created.

Type

ls 

This will display the fruit.txt file that you have created.

Nano has a wide range of editing capabilities, which are highlighted in the link below.

https://www.nano-editor.org/dist/v2.2/nano.html

© Wellcome Genome Campus Advanced Courses and Scientific Conferences
This article is from the free online

Bioinformatics for Biologists: An Introduction to Linux, Bash Scripting, and R

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education