You are viewing the article How to Create and Edit Text Files with Terminal on Linux at Lassho.edu.vn you can quickly access the necessary information in the table of contents of the article below.
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.
Steps
Open Terminal

- You can click on the search bar at the top of the Menu window and type terminal to find Terminal.



- 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 .


Create a Quick Text File

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 .


- If the directory containing the text file is open, simply double-click the text file when it appears to perform this step.


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”.

Using Vim

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.


- You should see — INSERT — appear at the bottom of the window when you press the I key.


- You will see the mouse pointer appear at the bottom of the window.

:w
into Terminal and press ↵ Enter . This is the command to save the current document. 
: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.

Using Emacs

emacs tên tệp.txt
into Terminal. You replace “filename” with the name you intend to give the text file. 
- 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.

- 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 ).




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.
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.
Thank you for reading this post How to Create and Edit Text Files with Terminal on Linux at Lassho.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: