Creating and editing files and folders in SSH Print

  • 0

SSH access to a Linux server makes life a lot easier. You have a command for anything and eveyrthing in there. There are many ways in which youc an create a file via SSH. The easiest and most common method is use the command - touch - for the task. If you wish to create a file named config.php at your current location, you simply type in

 

touch config.php


If you want it created at /etc/application/config.php, the command would be

 
touch /etc/application/config.php
 

Each shell command has a lot of options and switches that lets you manipulate the command. You can learn about all your options and switches for any command, by typing in

 

man command


Replace command with the actual command that you want to learn about. So, to learn more about 'touch', all you need to do is type in the following on your SSH prompt.

 

man touch


Editing or modifying this newly created file can be done using any of the available editors on your Linux server. There are quite a few of them available on our servers, but the most commonly used ones are nano (which is also known as pico) and vi.

vi is every Linux admins' best friend, but pico is easier for someone who is using a Linux text editor for the first time.

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

 

pico .htaccess


You then start typing into the file in this window. To save and exit the editor, you simply hit the  key combination. This will prompt to save or ignore the entries you made in the file, where you can decide how you want to proceed.

Directory/Folder Creation

To create a new folder/directory, simply type in the following in your SSH console.

mkdir Directory_Name



Please replace Directory_Name with the name of the directory that you want to be created


Was this answer helpful?

« Back