How to Navigate Remote Directories in SFTP on Ubuntu

This article explains the fundamental commands required to navigate remote file systems during an SFTP (Secure File Transfer Protocol) session on Ubuntu Linux. By mastering these basic commands, you can easily view your current directory path, list files, and move between folders on a remote server.

Checking Your Current Directory (pwd)

To find out exactly which directory you are currently working in on the remote server, use the print working directory command:

pwd

Running this command returns the absolute path of your current remote location (for example, /var/www/html or /home/username).

Listing Directory Contents (ls)

To see the files and folders inside your current remote directory, use the list command:

ls

You can also use flags with this command to view more detailed information: * ls -l: Displays the contents in a long list format, showing file permissions, owners, sizes, and modification dates. * ls -a: Reveals hidden files (those starting with a dot .). * ls -la: Combines both flags to show all files in a detailed list format.

Changing Directories (cd)

To move from your current remote directory to a different one, use the change directory command followed by the path:

cd directory_name

Here are the common ways to use the cd command: * Move to a subdirectory: cd folder_name * Move up one level (to the parent directory): cd .. * Move to an absolute path: cd /var/log * Return to the remote user’s home directory: cd (or cd ~)