Open menu

Learn

SFTP cd command

In the SFTP environment, "cd" stands for "change directory," and it's an SFTP command used to change the remote working directory. If you want the change the local working directory, check the lcd command (the equivalent of "cd" for the local system).

Navigating Directories with 'cd'

The SFTP cd command is similar to its counterpart in UNIX or Linux systems. It's used to change the current remote directory on the remote SFTP server. When you initialize an SFTP connection, you usually start in your home directory on the server. To navigate to different directories, you use the cd command. The general syntax is cd <directory> , where <directory> is the name or path of the directory you want to navigate to. For instance, if you have a directory named 'documents' in your home directory, you can navigate to it using the command cd documents . If you want to move to a directory at a different location, you need to provide the full path, like cd /var/www/html .

Relative and Absolute Paths

When using the cd command, you can use either relative or absolute paths. A relative path is one that starts from your current directory, while an absolute path starts from the root directory (denoted by "/"). For example, if you're in your home directory, and you have a folder named 'files' in it, you can switch to 'files' using a relative path: cd files . If you want to use an absolute path, you'd type something like cd /home/username/files , where 'username' is your username on the SFTP server.

Upload file

In case you want to upload files to a specific directory, you will need first to navigate to that directory and then use the put command (a crucial command for transferring files securely over the network) to upload the file. The same approach can also be used for an FTP server.

More SFTP commands

Depending on the SFTP client, the cd command is usually used combined with other SFTP commands (we have a guide showing what other SFTP commands you can use).