Open menu

Learn

SFTP mkdir

The Secure File Transfer Protocol (SFTP) has become an essential tool for secure and efficient data exchange between computers in the age of digital information. One of the most versatile aspects of SFTP is its ability to handle a variety of commands, one of which is mkdir

Understanding the command

mkdir is a command-line utility in Unix and Unix-like operating systems, such as Linux, that allows users to create new directories. When using an SFTP server, the command maintains the same purpose — create a directory in the current location or at a specified path on the remote server. The syntax of the command in SFTP is as follows:
sftp> mkdir directory_name
In the command above, "directory_name" is the name of the directory you want to create. If no path is specified, the directory will be created in the current working directory. If a path is specified, the directory will be created in the given path. The command to create a new directory on an SFTP server is quite simple and straightforward, but it can be combined with other commands for more complex operations. For example, you can use the cd command to change the current directory before using mkdir to create a new directory on the SFTP server:
sftp> cd /path/to/directory
sftp> mkdir new_directory
In this example, the cd command changes the current directory to /path/to/directory . Then, the second command will create a new remote directory named new_directory in this location. When you run mkdir on an SFTP server to create a directory, and that directory already exists, the command typically fails and returns an error message. This error generally indicates that the directory cannot be created because it already exists. The exact error message can vary depending on the SFTP server's software and configuration, but it commonly includes a phrase like "File exists" or "Directory already exists".