How to `ls` a remote folder?

You can use the command smbclient, e.g.:

smbclient -N //192.168.5.4/wdtvlivehub/abc -c ls

Your current method of using ~/.gvfs/ is fine, but you don't need pcmanfm for that – you can use gvfs-mount to connect to the share. Additionally, tools such as gvfs-ls and gvfs-cp will accept your smb:// URI.

$ gvfs-mount smb://HOST/SHARE/

$ gvfs-ls smb://HOST/SHARE/

In recent gvfs versions the location is $XDG_RUNTIME_DIR/gvfs/ (aka /run/user/$UID/gvfs/), and the subdirectory names have become more machine-readable:

$ ls /run/user/$UID/gvfs/smb-share:server=HOST,share=SHARE/

In older versions:

$ ls ~/.gvfs/"SHARE on HOST"/

(Remember to quote spaces within path names.)


Specifically for Samba, you can use the smbclient program, or mount the share on the VFS layer by using mount -t cifs. (The latter is, unfortunately, limited to root.)

$ smbclient //host/share

# mount -t cifs //host/share /mnt

(For other kinds of filesystems, such as SFTP and FTP, sshfs and curlftpfs exist respectively.)

Tags:

Samba

Ls

Remote