
一般來說,我想在透過分散式檔案系統(例如 samba、NFS 或您推薦的任何一個)提供給我的遠端檔案上運行本機程序,並且我想以類似於存取本機檔案的方式存取遠端檔案:類似於“位置透明”。
我對我的文件管理器 pcmanfm 感到驚訝,它可以像本地文件一樣呈現遠端文件,並允許我通過右鍵單擊在它們上運行一些本地程序,就像在本地文件上運行程序一樣。
我想在 CLI shell 中做同樣的事情。
例如,我試圖將檔案複製到sharesmb
透過遠端 samba 守護程序共享的遠端目錄。我可以在我的文件管理器中pcmanfm
使用地址來完成此操作smb://olive.local/sharesmb on olive.local
。我想在 shell 中執行相同的操作,但連結不起作用。你能告訴我如何在 shell 中做到這一點嗎?
$ cp 153-158.pdf smb://olive.local/sharesmb on olive.local
cp: target 'olive.local' is not a directory
$ cp 153-158.pdf smb://olive.local/'sharesmb on olive.local'
cp: cannot create regular file 'smb://olive.local/sharesmb on olive.local': No such file or directory
謝謝。
答案1
一般來說,您會將遠端檔案系統安裝到本機目錄並透過該安裝點處理檔案。在類別 Unix 環境中,這實際上意味著您可以像存取本機檔案一樣存取遠端檔案。
不過,根據您想要做什麼,有多種選擇。午夜指揮官(mc) 的行為與您描述的 pcmanfm 類似。如果您只想在電腦之間複製文件,您可能需要查看該scp
命令,前提是遠端主機執行 sshd(不久前也可用於 Windows Server 2019)。
答案2
使用 sshfs:
sshfs [email protected]:/path/to/remote/folder /path/to/mountpoint/