使用 Wget / shell 從 Web 根目錄外部下載文件

使用 Wget / shell 從 Web 根目錄外部下載文件

我正在嘗試下載 httpd.conf 文件,以便可以編輯我的 Apache 配置。

我可以透過 shell 存取它所在的目錄(我有 root 存取權限),但是所有關於如何使用的範例獲取若要從 Web 伺服器下載文件,請使用 URL,且該文件不在 Web 根目錄 ( public_html) 中;在裡面root/etc/httpd/conf/httpd.conf

我在那個目錄中,我嘗試了

wget httpd.cong

但它抱怨。

正確的 Wget 語法是什麼?

答案1

從 Wget man 用法來看:

 wget [option]... [URL]...

在哪裡網址類似

 http://host[:port]/directory/file
 ftp://host[:port]/directory/file

所以就你而言,

 wget --user=user --password='pass' ftp://host[:port]/directory/relative/to/user

你可以使用scp

 scp [email protected]:/etc/httpd/conf/httpd.conf /some/local/directory

甚至FTP。推薦客戶有文件齊拉或者油灰。如果您只需要編輯文件,則無需下載。尋找文件編輯器,例如維姆或者

答案2

如果您的目標是編輯該httpd.conf文件,並可以透過​​ shell 存取它,您可以使用 shell 編輯器(例如)簡單地編輯它,nano而不是下載它。只需運行:

cd /directory/containing/the/file
nano httpd.conf

進行修改,然後按Ctrl+儲存x(如果您使用 )nano

相關內容