Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Text Editing and Writing to Files

how to use a text editor in Linux
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

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now