Home  >  Article  >  Operation and Maintenance  >  How to create files in Linux?

How to create files in Linux?

尚
Original
2020-03-11 13:59:0420199browse

How to create files in Linux?

How to create a file in Linux:

1. You can use cat to create a new file

Command: cat> ;>filename

When using cat to create a file, the system default file attributes are used as the attributes of the new file, and keyboard input is accepted as the content of the file. Press Ctrl d when finished typing to exit and save the file.

How to create files in Linux?

In addition, use the cat filename command to view the file content.

2. Use the touch command to create files

The initial function of the touch command is to modify the "access time" or "modification time" of the file. When the touch command When the specified file does not exist, the touch command will create a new file with the specified name.

The command usage method is as follows:

For a file that does not exist, the touch command will create the file

#使用touch命令创建文件
os@DESKTOP-2DHQBVS:~$ touch tedu.txt
#可见文件创建成功
os@DESKTOP-2DHQBVS:~$ ls -l
total 0
-rw-rw-rw- 1 os os 0 Sep 26 11:32 tedu.txt
#注意该文件的修改时间为11:32分

3. Use a text editor to create the file

In Linux distributions, most terminal environments have one or more text editors, such as vi, vim, nano and other text editors. The GUI desktop environment also has some text editors. , such as Ubuntu's Gedit and other editors.

Most files are actually text documents, so using a text editor to create files is a common way to create files.

Recommended learning: Linux video tutorial

The above is the detailed content of How to create files in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn