How to create a text file in Linux

Jugo Mobile
By
Jugo Mobile
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore...
6 Min Read

If you are new to Linux, you may want to learn how to create a text file. Experienced Linux users know the importance of learning how to create text files, so this is a common request for beginners. Manipulating text in Linux is essential to mastering its full functionality. Fortunately, it’s relatively easy to learn.

This article will show you a few different ways to quickly create a text file in Linux. In most cases, you can use a text editor or the command line within Linux.

use nano

Nano is a popular text editor that usually comes preinstalled on Ubuntu-based Linux systems. It is a simple and easy-to-use editor. There are other text editors for Linux, but Nano is the most beginner-friendly. To create a text file using Nano, follow these steps:

  1. If you don’t have the Nano text editor, download it here.
    1715487881 999 How to create a text file in
  2. Open a new terminal window by holding down “Control + Alt + T”.
    1715487882 430 How to create a text file in
  3. Type “nanoexample.txt” and press Enter. Replace “example” with whatever name you want for your text file.
    1715487882 135 How to create a text file in
  4. At the bottom of the window, you will find the “Command List”. Press “Control + G” to see all commands. These will help you create the new text file.
    1715487882 279 How to create a text file in
  5. Write your text document using the keyboard and the commands in the command list.
    1715487882 331 How to create a text file in
  6. Press “Control + O” to save the file.
    1715487883 977 How to create a text file in
  7. To return to the command prompt and exit Nano, press and hold “Control + X.”
    1715487883 459 How to create a text file in

Use Vim

With the Vim text editor, you can also create a Linux text file. Most Ubuntu-based Linux systems come with Vim already installed. Vim is similar to Nano. The main difference is that it has more features and a steeper learning curve. To use this method to create a text file, do the following:

  1. If you still don’t have PushDownload and install it.
    1715487884 530 How to create a text file in
  2. Press “Control + Alt + T” to open a new terminal window.
    1715487882 430 How to create a text file in
  3. Type “vim example.txt” and press the Enter key. Replace “example” with the name you chose for the file.
    1715487884 624 How to create a text file in
  4. Tap the “I” key to open Vim in “Command Mode”. The word “Insert” appears at the bottom of the window.
    1715487885 493 How to create a text file in
  5. Now that you are in Vim’s “Insert Mode”, you can write your text document.
    1715487885 42 How to create a text file in
  6. Press the Esc key to return to “Command Mode.”
    1715487885 549 How to create a text file in
  7. To save your file, type “:w” and then press the Enter key.
    1715487885 962 How to create a text file in
  8. To return to the command prompt and exit Vim, type “:q” and press Enter.
    1715487886 557 How to create a text file in

Use the cat command

If you prefer not to use a text editor, you can create a text file in Linux using the Cat command. It is a useful way to quickly create and save a text file.

  1. Open a new terminal window by pressing “Control + Alt + T”.
    1715487882 430 How to create a text file in
  2. Type “$cat > example.txt” and press the Enter button,
    Replace the word “example” with the name you want to use for the file.
    1715487886 282 How to create a text file in
  3. Write the text you want to the file.
    1715487886 568 How to create a text file in
  4. Press the Return key and then press “Control + D.” This will tell Linux that you have added all the text. The usual command prompt will appear.
    1715487886 339 How to create a text file in
  5. To make sure your text file has been saved, type “$ls” and you will see the newly saved file.

Use touch command

Another way to quickly create a text file in Linux is to use the Touch command. However, by using this method, you will not be able to enter the text of the file when you create it. Using this method is most beneficial when you want to create multiple text files at the same time. For illustrative purposes, we will show you how to create multiple text files simultaneously. This is how you do it:

  1. Hold down “Control + Alt + T” to open a new command window.
    1715487882 430 How to create a text file in
  2. For example, if you want to create three new text files, type “$touch example1.txt example2.txt example3.txt” and replace the word “example” with the file names you want to use.
    1715487887 115 How to create a text file in
  3. Press the Enter key to save the files.
    1715487887 915 How to create a text file in
  4. You can check to make sure the files have been saved by typing “$ls”.
    1715487887 340 How to create a text file in

Now that you’ve created several text files with the Touch command, you’ll want to add text to them. This will need to be done using a text editor. We will use Nano for this example.

  1. Type “$nano example.txt” and replace the word “example” with the name of the file you created.
    1715487887 85 How to create a text file in
  2. Press the Enter button.
    1715487888 500 How to create a text file in
  3. From here, you can type the required text. Once you’re done, hold down “Control + X” and press the Enter key.

Creating text files in Linux solved

Creating a text file in Linux can be accomplished using several different methods. You can use the Touch or Cat commands within Linux from the terminal prompt. Alternative methods require text editors such as Vim or Nano, typically pre-built into most Ubuntu-based Linux systems.

Share This Article
Follow:
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore the latest trends and innovations in our vibrant community. Join us and experience the future today!
Grow your brand and reach a larger audience. Advertise with us today and get noticed by thousands.
© 2025 Jugo Mobile. All Rights Reserved.