Create/Edit files and folders using SSH cmd line

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 line:

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’.

In order 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 vi and pico (aka nano).

We will try using pico, since it is easier than vi. To request the file to be opened in pico, type:

pico .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 send <ctrl + x> key combination.

To create a new directory, please use:

mkdir myDirectory

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

SiteGround is not affiliated with or endorsed by the SSH Project or its trademark owners.