Modifying the SFTP Default Working Directory
While the default SFTP working directory is typically the user's home directory, there may be situations where you need to change the default directory. This can be useful when you want to access specific directories on the remote server or set a custom starting point for your file operations.
To modify the SFTP default working directory, you can use the cd
(change directory) command within the SFTP session. Here's an example:
$ sftp [email protected]
Connected to example.com.
sftp> cd /var/www/html
sftp> pwd
/var/www/html
In this example, the user changes the default working directory from the home directory (/home/user
) to the /var/www/html
directory on the remote server.
You can also set the default working directory for the SFTP session by specifying the directory when connecting to the server. Here's an example:
$ sftp [email protected]:/var/www/html
Connected to example.com.
sftp> pwd
/var/www/html
In this case, the user connects to the SFTP server and specifies the /var/www/html
directory as the starting point for the session.
By modifying the SFTP default working directory, you can streamline your file management tasks and access the specific directories you need on the remote server.