• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Create and Edit Text Files with Terminal on Linux

November 28, 2023 by admin Category: How To

You are viewing the article How to Create and Edit Text Files with Terminal on Linux  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

Linux is known for its robust command line interface, and one of the most fundamental tasks in the Linux command line is creating and editing text files. With the Terminal, Linux users have a powerful tool at their disposal to effortlessly create, modify, and manipulate text files. Whether you’re a beginner exploring Linux or an advanced user looking to streamline your workflow, this guide will walk you through the process of creating and editing text files using the Terminal in Linux. We’ll cover the essential commands and techniques, empowering you to confidently handle text files with ease and efficiency. So, let’s dive into the world of text file manipulation in the Linux command line!

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 34,851 times.

In this article, wikiHow will show you how to use the Terminal software on Linux to create text files. After creating the file, you can use the pre-installed editing software on Linux to edit the text.

Table of Contents

  • Steps
    • Open Terminal
    • Create a Quick Text File
    • Using Vim
    • Using Emacs
  • Advice
  • Warning

Steps

Open Terminal

Image titled Create and Edit Text File in Linux by Using Terminal Step 1

Image titled Create and Edit Text File in Linux by Using Terminal Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/6b/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-1-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-1-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/6/6b/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-1-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-1-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Open Terminal. To open the software, click on the Menu (Menu) and then find the Terminal software, which looks almost like a blackboard with a white “>_” symbol and click on it. You usually find Terminal in the left sidebar of the Menu window.

  • You can click on the search bar at the top of the Menu window and type terminal to find Terminal.
Image titled Create and Edit Text File in Linux by Using Terminal Step 2

Image titled Create and Edit Text File in Linux by Using Terminal Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d2/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-2-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-2-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/d/d2/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-2-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-2-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type ls into Terminal, then press ↵ Enter . Terminal will open the main directory, but the ls command will display all directories in the current directory. To create a text file in one of those categories, you need to change the current category.
Image titled Create and Edit Text File in Linux by Using Terminal Step 3

Image titled Create and Edit Text File in Linux by Using Terminal Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/1b/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-3-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-3-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/1/1b/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-3-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-3-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Find the category you want to create a text file for. Any category name listed below the ls command (e.g. “Desktop”) is a navigable place.
Image titled Create and Edit Text File in Linux by Using Terminal Step 4

Image titled Create and Edit Text File in Linux by Using Terminal Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/75/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-4-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-4-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/7/75/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-4-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-4-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Enter cd directory . You replace “directory” with the name of the directory you want to create the file. This command will switch Terminal’s focus from the current directory to the one you name.

  • For example, you enter the command cd Desktop to switch the location of Terminal’s command execution to the Desktop directory.
  • If you want to create a text file in a separate folder under the selected category, simply add a “/” after the category name and then type the folder name. For example, for the “Misc” folder in the Documents directory, you would type cd Documents/Misc .
Image titled Create and Edit Text File in Linux by Using Terminal Step 5

Image titled Create and Edit Text File in Linux by Using Terminal Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a1/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-5-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-5-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/a/a1/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-5-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-5-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press ↵ Enter . This is a command execution that switches the Terminal’s target from the main category to the one you specify.
Image titled Create and Edit Text File in Linux by Using Terminal Step 6

READ More:   How to Prevent Soil Pollution

Image titled Create and Edit Text File in Linux by Using Terminal Step 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/65/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-6-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-6-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/6/65/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-6-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-6-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Decide on editing software. You can create simple text files quickly, or use Vim or Emacs for advanced file creation and editing. You have accessed the directory you want to create a text file, now proceed to create the file.

Create a Quick Text File

Image titled Create and Edit Text File in Linux by Using Terminal Step 7

Image titled Create and Edit Text File in Linux by Using Terminal Step 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/be/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-7-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-7-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/b/be/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-7-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-7-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type cat > tên tệp.txt into Terminal. You replace “filename” with the name you want to give the file (for example “report”).

  • For example, when creating the file “kitty”, you enter the command cat > kitty.txt .
Image titled Create and Edit Text File in Linux by Using Terminal Step 8

Image titled Create and Edit Text File in Linux by Using Terminal Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8c/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-8-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-8-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/8/8c/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-8-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-8-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press ↵ Enter . This is the operation to create a new text file with the name just given in the current directory. The cursor will appear on a blank line in Terminal.
Image titled Create and Edit Text File in Linux by Using Terminal Step 9

Image titled Create and Edit Text File in Linux by Using Terminal Step 9

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/77/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-9-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-9-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/7/77/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-9-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-9-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Enter text. You type text as you do with other documents. To save the line of text just typed and move to the next line, press ↵ Enter .

  • If the directory containing the text file is open, simply double-click the text file when it appears to perform this step.
Image titled Create and Edit Text File in Linux by Using Terminal Step 10

Image titled Create and Edit Text File in Linux by Using Terminal Step 10

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/42/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-10-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-10-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/4/42/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-10-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-10-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press Ctrl + Z . This is the command key to save the text and return to the command line in Terminal, allowing you to continue typing commands. [1] X Research Source
Image titled Create and Edit Text File in Linux by Using Terminal Step 11

Image titled Create and Edit Text File in Linux by Using Terminal Step 11

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/17/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-11-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-11-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/1/17/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-11-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-11-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type ls -l tên tệp.txt into Terminal. You replace “filename” with the name you intend to give the text file. This statement will locate the file to make sure it’s created in the category you choose. [2] X Research Source

  • For example, to open the file “textfile”, you enter the command ls -l textfile.txt .
  • The letter in this statement is a lowercase “L”, not a capital “i”.
Image titled Create and Edit Text File in Linux by Using Terminal Step 12

Image titled Create and Edit Text File in Linux by Using Terminal Step 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/60/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-12-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-12-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/6/60/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-12-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-12-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press ↵ Enter . This displays the time, date, and filename on the next line, indicating that the file was created and saved in the selected directory.

Using Vim

Image titled Create and Edit Text File in Linux by Using Terminal Step 13

Image titled Create and Edit Text File in Linux by Using Terminal Step 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/ba/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-13-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-13-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/b/ba/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-13-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-13-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Enter vi tên tệp.txt into Terminal. The “vi” part of this statement is for choosing to use the Vim text editing software. You’ll replace “filename” with the text file name you want to assign to the new file.

  • For example, with the file “tamins”, you enter the command vi tamins.txt .
  • If the current directory has a file with the same name, this command will open that file.
Image titled Create and Edit Text File in Linux by Using Terminal Step 14

Image titled Create and Edit Text File in Linux by Using Terminal Step 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/fd/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-14-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-14-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/f/fd/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-14-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-14-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press ↵ Enter . This is to create a new file and open it in Vim software. You should see an empty Terminal window, with a tilde (~) on each line, and a filename at the bottom of the window.
Image titled Create and Edit Text File in Linux by Using Terminal Step 15

Image titled Create and Edit Text File in Linux by Using Terminal Step 15

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d8/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-15-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-15-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/d/d8/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-15-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-15-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press the i key. This is to put the document into “Insert” mode so you can edit the text as needed.

  • You should see — INSERT — appear at the bottom of the window when you press the I key.
Image titled Create and Edit Text File in Linux by Using Terminal Step 16

Image titled Create and Edit Text File in Linux by Using Terminal Step 16

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/fe/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-16-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-16-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/f/fe/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-16-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-16-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Enter text. You type text as you do with other documents. To save the line of text just typed and move on to the next line, just press ↵ Enter .
Image titled Create and Edit Text File in Linux by Using Terminal Step 17

READ More:   How to Find the Cause of Tinnitus

Image titled Create and Edit Text File in Linux by Using Terminal Step 17

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f9/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-17-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-17-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/f/f9/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-17-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-17-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press the Esc key. This key is usually located in the upper left corner of the keyboard. This key will put Vim into “Command” mode.

  • You will see the mouse pointer appear at the bottom of the window.
Image titled Create and Edit Text File in Linux by Using Terminal Step 18

Image titled Create and Edit Text File in Linux by Using Terminal Step 18

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/95/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-18-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-18-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/9/95/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-18-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-18-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type :w into Terminal and press ↵ Enter . This is the command to save the current document.
Image titled Create and Edit Text File in Linux by Using Terminal Step 19

Image titled Create and Edit Text File in Linux by Using Terminal Step 19

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/21/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-19-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-19-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/2/21/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-19-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-19-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type :q into Terminal and press ↵ Enter . This is the command to exit Vim and return to the main Terminal interface. The text file is now in the specified category.

  • You can check a text file by typing the ls command into Terminal and pressing ↵ Enter , then looking for the filename.
  • You can enter the command :wq to save and exit in the same command.
Image titled Create and Edit Text File in Linux by Using Terminal Step 20

Image titled Create and Edit Text File in Linux by Using Terminal Step 20

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/10/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-20-Version- 3.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-20-Version-3.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/1/10/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-20-Version-3.jpg/v4-728px-Create-and- Edit-Text-File-in-Linux-by-Using-Terminal-Step-20-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Reopen the file in a Terminal window. Similar to creating a file, you enter the command vi filename.txt to open the file. Now when you open the file, you will see that any changes you save are implemented.

Using Emacs

Image titled Create and Edit Text File in Linux by Using Terminal Step 21

Image titled Create and Edit Text File in Linux by Using Terminal Step 21

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/13/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-21.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-21.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 1/13/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-21.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-21.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Type emacs tên tệp.txt into Terminal. You replace “filename” with the name you intend to give the text file.
Image titled Create and Edit Text File in Linux by Using Terminal Step 22

Image titled Create and Edit Text File in Linux by Using Terminal Step 22

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8f/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-22.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-22.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 8/8f/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-22.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-22.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Press ↵ Enter . As long as the filename doesn’t match an existing text file in the current directory, this command will open a new text file in the Emacs editing software.

  • For example, a file named “newfile” would have to enter the command emacs newfile.txt .
  • If you enter an already existing filename, this command will open the file.
Image titled Create and Edit Text File in Linux by Using Terminal Step 23

Image titled Create and Edit Text File in Linux by Using Terminal Step 23

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/4c/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-23.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-23.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 4/4c/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-23.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-23.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Learn Emacs commands. Emacs has tons of powerful commands that allow you to navigate documents, look up related or support information, manipulate text, and understand code. These commands are divided into 2 types: Control commands and Meta commands.

  • The Control Command has the form: C-<letter>. To execute a Control command, you hold down the Ctrl key and press the specified letter key (eg, Ctrl and A ).
  • The Meta command (or Exit ) has the form: M-<letter> or ESC <letter>. The “M” refers to the Alt key or the Esc key on computers, because not all computers have an Alt key.
  • The command is written like this Shift b (or Ma b ) requires you to hold down Ctrl (or Alt or Esc ) while pressing the first key (for example a ), release both keys and then immediately press the second key (eg key b ).
Image titled Create and Edit Text File in Linux by Using Terminal Step 24

Image titled Create and Edit Text File in Linux by Using Terminal Step 24

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/6d/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-24.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-24.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 6/6d/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-24.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-24.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Enter text. You can type text as you would with other documents. To save the line of text just typed and move to the next line, press ↵ Enter .
Image titled Create and Edit Text File in Linux by Using Terminal Step 25

Image titled Create and Edit Text File in Linux by Using Terminal Step 25

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/fc/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-25.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-25.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ f/fc/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-25.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-25.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Press Ctrl + X , then press S . This is a file save operation.
Image titled Create and Edit Text File in Linux by Using Terminal Step 26

Image titled Create and Edit Text File in Linux by Using Terminal Step 26

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a9/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-26.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-26.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ a/a9/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-26.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-26.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Press Ctrl + X , then press Ctrl + C . This is to exit the Emacs editing software and return to the directory in Terminal. The text file is saved under the name you just put in this folder.
  • Image titled Create and Edit Text File in Linux by Using Terminal Step 27

    READ More:   How to Flirt on Facebook

    Image titled Create and Edit Text File in Linux by Using Terminal Step 27

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d5/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-27.jpg/ v4-728px-Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-27.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ d/d5/Create-and-Edit-Text-File-in-Linux-by-Using-Terminal-Step-27.jpg/v4-728px-Create-and-Edit-Text-File-in-Linux-by- Using-Terminal-Step-27.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
    Reopen the text file. To open the file, type the emacs command file name.txt into Terminal. As long as you’re in the directory where the file is, this command can open the file in Emacs, so you can continue editing if you want.
  • Advice

    • You can access Vim on any version of Linux, while the more detailed Emacs software makes it easy for newcomers to use.
    • You can open the Emacs “Help” screen by simultaneously pressing Ctrl + H , then releasing both keys and then pressing the T key again. The Help menu will show many additional commands and other functions in the Emacs software, which may come in handy during text input.

    Warning

    • There may be no warning if you forget to save the document before closing, especially in Vim software. Always remember to save the document before closing.
    X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 34,851 times.

    In this article, wikiHow will show you how to use the Terminal software on Linux to create text files. After creating the file, you can use the pre-installed editing software on Linux to edit the text.

    In conclusion, creating and editing text files with Terminal on Linux is a powerful and efficient way to work with text-based content. By using commands such as touch, nano, vim, or emacs, users can easily generate new files, modify their content, and save changes. Additionally, the ability to navigate the directory structure and manage files through the command line interface provides greater control and flexibility. While there may be a learning curve initially, mastering these tools enables users to work more efficiently and effectively in the Linux environment. The Terminal remains an essential tool for programmers, system administrators, and any user who wishes to maximize their productivity on Linux.

    Thank you for reading this post How to Create and Edit Text Files with Terminal on Linux at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    1. Basic commands for creating and editing text files with Terminal on Linux
    2. Creating a new text file using Terminal on Linux
    3. Opening and editing an existing text file with Terminal on Linux
    4. How to save and exit text files in Terminal on Linux
    5. Using Nano text editor to create and edit text files on Linux Terminal
    6. Mastering Vim text editor for creating and editing text files with Terminal on Linux
    7. Tips and tricks for efficient text editing in Terminal on Linux
    8. Overview of advanced text editing tools available in Terminal on Linux
    9. Command line shortcuts for creating and editing text files on Linux Terminal
    10. Troubleshooting common issues while creating and editing text files with Terminal on Linux

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « Top 999+ mango tree images – Amazing Collection mango tree images Full 4K
    Next Post: Top 999+ Submit Wallpapers Full HD, 4K✅Free to Use »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge