SSH Tutorials
How to Create and Edit Files and Folders Using SSH

How to Create and Edit Files and Folders Using SSH

There are various ways you can create a new file using the SSH command line. The easiest and most common way is to use the command assigned for this task – touch. For example, if you would like to create a new file called .htaccess you would need to type the following command:

touch .htaccess

The command also accepts several arguments, which for example can instruct the OS to edit the modified date of already existing file. For more information you can check the manual page for the command by typing

man touch

To edit the newly created file, you should use a file editor. There are several editors available on all SiteGround servers. The most commonly used are vim and pico (aka nano).

To request the file to be opened in nano, type:

nano .htaccess

This will bring up the editor interface as shown below:

You can type text directly into the window. To save and exit the interface, you would need to press “ctrl + x“.

To create a new directory, you can use:

mkdir myDirectory

where you should replace the myDirectory string with the name of your folder.

Share This Article