how to create a text file from linux terminal

Sometimes you may want to avoid the use of graphical mode command, so you may want to jump inside your linux terminal, as it should be i think, to type some useful and fun commands.
This is the video on youtube

Let's start by open your linux terminal by typing:  Ctrl + Alt + T

So now suppose we want to enter the path of the folder where we want to create this new file, but the problem could be the existence of this folder itself, so let's find out how to do it:

As you see i typed this command with sudo, meaning "super user do", mkdir that stands for "make directory" and newFolder which is the folder's name. After do this i entered inside the folder i just created with the cd command that stands for "change directory".

Now, to create a text file use the touch command which allows you to create files, and after pressing enter, check with ls, that stand for "list", what is inside the folder.

How to open this text file?

To open the sample.txt file just follow these instructions.

As the name of the editor you can use any editor you want like geany,featherpad,sublime,visual studio code,notepad++, or many other text editors you may choose.

Finally, after you typed this command, a window will appear as your text editor that opens this file and now we can save this phrase i typed and close this window from the terminal.

But hey, there is a mistake...!?

If you want to save this file by typing Ctrl + S, a pop-up with an error message will appear:

This error message tells you that you have not permission to save this file, so to allow this behavior be possible, you have to enter the sudo permission command before others attributes:

Press OK on this pop-up, return inside your terminal and type Ctrl + C to close the editor window, then retype the previous commad (also by pressing button), but this time with sudo permissions, like this:

Now try to reopen your text editor and save it, you will see something like:

linux file terminal editor