Once you are navigated to the newly created directory, create your first file using the touch
command.
touch new_file
The command above will create an empty file named new_file and you can use that file for testing purposes. To edit the file and add some content to it you can use a text editor. There are many text editors which you can use, but nano
is very suitable for beginners. Our recommendation is to use nano
as an text editor to modify your files until you become more familiar with the others. In case you do not have nano
installed on your system, you can use the command below to install the program:
On a CentOS VPS:
sudo yum install nano
On a an Ubuntu VPS:
sudo apt-get install nano
Now, to open and edit the file you have previously created you can use the following command:
nano new_file
Enter some random text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Illud dico, ea, quae dicat, praeclare inter se cohaerere. Nam aliquando posse recte fieri dicunt nulla expectata nec quaesita voluptate.
To save and close the file you should press CTRL + X
and then Y
. In case you do not like to save the changes you should press N
after CTRL + X
.
Now that you have a test file with content on your server, lets see the content. There are many methods to see the content of a file, but by far the easiest method is to use the cat
command.
cat new_file
Using the cat
command you can do many other things. For example, using the cat
command you can concatenate multiple files together or append text to an already existing file. For more information you can read the Linux man page for cat
.
If you like to remove the file you created and used for testing purposes, you can use the rm
command. The basic syntax is:
rm new_file
Once you execute the command you will be prompted to confirm that you like to remove the file. You can confirm by pressing Y
. If you changed your mind, press N
.