Open menu

Learn

SFTP lcd Command

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 the lcd command.

What is the LCD Command in SFTP?

The lcd command, short for 'local change directory', is a commonly used SFTP command that allows you to change the current directory on your local machine from within the SFTP environment. While the cd command changes the working directory on the remote server, the lcd command allows the user to modify the current directory in the local file system. This is especially handy when you want to transfer files between different local directories and a remote server, without exiting the SFTP interface.

How to Use the LCD Command in SFTP

The basic syntax for the lcd command is as follows:
sftp> lcd /path/to/directory
The /path/to/directory is the absolute path to the local directory that you want to change to. If the directory path is correct and the directory exists, the 'lcd' command will change the local working directory to the specified directory. For example, if you want to change the local working directory to /home/user/documents , you would enter:
sftp> lcd /home/user/documents
If the command executes successfully, your local working directory will be /home/user/documents and any subsequent file transfers will be relative to this new local working directory.