Knowledgebase

How to create folders and files via SSH

You can create new directories and files through SSH with the commands mkdir and touch respectively.

To make a new folder type the command mkdir followed by a space and the name of the directory. For example:

mkdir example_folder

will create a folder called example_dir in the current working directory. You can also use the full path to the new directory, if you don't want to change the current working directory and you want the new folder to be created somewhere else (e.g. mkdir /home/username/public_html/example_folder). If you want to make a folder that has spaces in its name, put the name in quotation marks (e.g. mkdir "example folder"). As with other commands, you can create many directories by executing one command and listing the directories after the command (e.g. mkdir folder folder2 folder3).

To create new files use the touch command followed by a space and the file name including its extension type. For example:

touch example.txt

will create a text file example.txt in the current working directory. As with the mkdir command, you can use the full path to the new file; if there are spaces in the name, you should put the file name in quotations; you can create many files with one command.

Of course, the newly created files and directories will be empty.

Was this answer helpful?

 Print this Article

Also Read