How to Create, Read, Edit, and Delete Files in Ubuntu 22.04

In Ubuntu, we can create different types of files by running some simple commands because it is known that Ubuntu can be managed through the terminal. In this blog, some simple commands for creating, editing, reading, and deleting different types of files are going to be discovered.

How to Create, Read, Edit, and Delete Files in Ubuntu 22.04

The blog has been divided into different sections which explain:

How to Create Files in Ubuntu 22.04

Different types of files can be created by simply using the touch command and if the files are of some specified formats then use the extensions as well, for example, a text file with the name of myFile will be created using the command:

$ touch myFile.txt

When the command is executed successfully, list down the contents of the directory to confirm the creation of file:

$ ls

In the above output, it can be seen that the file is created, now open the file using the nano text editor:

$ nano myFile.txt

Type some text in the file:

Welcome to LinuxHint

Close the file with a shortcut key of CTRL+X after saving it with CTRL+S.

How to read Files on Ubuntu 22.04

For reading files on Ubuntu, the cat command utility can be used. For example, to read the file created in the above section, use the command:

$ cat myFile.txt

The message of the file is displayed on the screen.

How to Edit Files on Ubuntu 22.04

To edit the already created files, open them with some text editors like Vim and Nano here the files are being opened by the nano text editor:

$ nano myFile.txt

Type some more new lines in the file:

This is tutorial about creation, viewing, editing, and displaying the files on Ubuntu

Exit the nano text editor by saving the new change made with the shortcut key of CTRL+S and then use the cat command to view the file:

$ cat myFile.txt

The edited changes can be read in the above output.

How to Delete the Files in Ubuntu 22.04

To delete the files in Ubuntu, use the rm command with the “-f” flag, which is used to remove files. For example, to remove the myFile.txt, use the command:

$ rm -f myFile.txt

After deleting the file, list down the contents to confirm deletion:

$ ls

The file has been deleted successfully.


The touch command is used to create files, the cat command to read files, the nano text editor to edit files, and the rm command to delete files on Ubuntu 22.04. In this blog, an example is considered to explain the commands for the creation, reading, editing, and deleting of the files in Ubuntu 22.04.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.