{"id":19755,"date":"2016-08-10T07:53:57","date_gmt":"2016-08-10T12:53:57","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=19755"},"modified":"2022-12-29T11:14:06","modified_gmt":"2022-12-29T17:14:06","slug":"how-to-create-and-edit-files-on-a-linux-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-create-and-edit-files-on-a-linux-vps\/","title":{"rendered":"How to create and edit files on a Linux VPS"},"content":{"rendered":"
<\/p>\n
Creating 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<\/a>. Before we start, connect to your server via SSH<\/a> and make sure that you are familiar with your environment. For that purpose, you can use the basic shell commands<\/a> which were explained in one of our earlier blog posts. For example, you can create a new directory using the 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 On a CentOS VPS<\/a>:<\/p>\n On an Ubuntu VPS<\/a>:<\/p>\n Now, to open and edit the file you have previously created you can use the following command:<\/p>\n Enter some random text:<\/p>\n To save and close the file you should press 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 Using the If you like to remove the file you created and used for testing purposes, you can use the Once you execute the command you will be prompted to confirm that you like to remove the file. You can confirm by pressing Of course, you don\u2019t have to do any of this if you use one of our Linux VPS hosting services<\/a>, 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\u00d77 and will take care of your request immediately.<\/p>\n 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.<\/p>\n","protected":false},"excerpt":{"rendered":" Creating or editing files is one of the most common tasks that system admins perform every day. In this tutorial … <\/p>\n
\n<\/p>\nmkdir<\/code> command and navigate to that directory. Once you are navigated to the newly created directory, create your first file using the
touch<\/code> command.<\/p>\n
touch new_file<\/pre>\n
nano<\/code> is very suitable for beginners. Our recommendation is to use
nano<\/code> as an text editor to modify your files until you become more familiar with the others. In case you do not have
nano<\/code> installed on your system, you can use the command below to install the program:<\/p>\n
sudo yum install nano<\/pre>\n
sudo apt-get install nano<\/pre>\n
nano new_file<\/pre>\n
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.<\/pre>\n
CTRL + X<\/code> and then
Y<\/code>. In case you do not like to save the changes you should press
N<\/code> after
CTRL + X<\/code>.<\/p>\n
cat<\/code> command.<\/p>\n
cat new_file<\/pre>\n
cat<\/code> command you can do many other things. For example, using the
cat<\/code> 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<\/code>.<\/p>\n
rm<\/code> command. The basic syntax is:<\/p>\n
rm new_file<\/pre>\n
Y<\/code>. If you changed your mind, press
N<\/code>.<\/p>\n