Wednesday, May 9, 2018

3 Ways To Create A Text File Via Ubuntu Terminal or CLI

creating a new text file is a very easy thing when using GUI mode, as this can be done by right-clicking and selecting the Create Document menu in a directory. But, how do I make it, when entering the CLI (Command Line Interface) mode?

These are 3 easy ways to create document files using a terminal or in CLI mode:

1. Using the touch command
Touch command

To use the touch command, just type followed by the name of the file you want to create. for example, I want to create a text file named "". The .py file is an extension for the python language. so to make it, I typed this command in the terminal:


To check the file has been successfully created or not, can be seen using the command "ls". If successful, the data file will appear with named "" in the directory. If the file is opened, there is no data because this command is used to create an empty text file.
2. using > command
> command to make text file

The(>) symbol is also a command that can be used to create an empty text file. You just need to type> followed by the filename and possibly the file extension as well, to create a text file. Example:


3. Using the text editor that is already available in general in linux, for example nano
Nano text editor

Creating an empty file, can also calling one of the text editor applications thats available on your computer. In this case, I use nano to create a blank document. So, this is the command to make it in nano:


Unlike the touch or (>), when creating a file using a text editor. We will be directly open the file with file name that created. And if you don't save it, the file will not be saved in the directory. So, to create a document file, in this way, we must save the document after everything is finished. Although it only makes an empty file.

No comments:

Post a Comment