This brief tutorial explains how to modify and create files within SSH using the tool Nano. It is incredibly useful for editing existing files and offers a wide range of functionality.
Opening or creation of files:
Nano is a modeless editor. Once you have opened a file you can type to add text to it. There may be times when you need to turn off line wrap to ensure there are no formatting issues.
To disable wrapping on long text lines:
nano -w /filedirectory/filename
When you have a file open using nano, there are commands that will assist you in finding, editing, or saving content. Below is a list of commands you can use when editing a file with nano to perform common operations:
To save after modification, exit with the above command and enter “y” when prompted.
To cancel any modification, exit with the above command and enter “n” when prompted.
If creating a new file, upon running the above command you will also be prompted for a file name. Enter the desired file name to create the file.
To cut a single line:
To paste a line:
To search for items:
To save without exiting:
Justify current selected paragraph:
Insert a file into the currently selected one:
Move to previous screen:
Move to next screen:
CTRL + V
Invoke spell checker:
For further commands that can be used when utilizing the nano utility, use the following command to display a full list of features.
To pull up nano help page:
If you are interested in more command line articles like this, check out the HostDime Resources Page for more helpful tutorials!