How to create and edit files on a Linux VPS

create and edit files in linuxCreating or editing files is one of the most common tasks that system admins perform every day. In this tutorial we are going to show you how to create and edit files on a Linux VPS.

Before we start, connect to your server via SSH and make sure that you are familiar with your environment. For that purpose, you can use the basic shell commands which were explained in one of our earlier blog posts. For example, you can create a new directory using the mkdir command and navigate to that directory. 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.

Of course you don't have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to help you with any aspect of using your server. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.


Download Now


Lihat Sumbernya → How to create and edit files on a Linux VPS
Download MP3 Terbaru → Chris Brown Mp3 Download