
curl
在用於獲取腳本然後執行它的shell 腳本中,這兩種方法有本質上的不同嗎?
curl http://address-to-some-script/dosomething.sh | sudo tee /usr/bin/dosomething.sh
....對...
sudo curl http://address-to-some-script/dosomething.sh >> /usr/bin/dosomething.sh
sudo
第二個命令中的右邊有一些東西curl
讓我停頓,但我無法清楚地表達它是否或如何與第一個命令不同(風險更大?)。
答案1
存在許多實質差異。
curl http://address-to-some-script/dosomething.sh | sudo tee /usr/bin/dosomething.sh
curl
以當前使用者和tee
root 身份運行;它也會/usr/bin/dosomething.sh
在寫入之前清除 的內容。
sudo curl http://address-to-some-script/dosomething.sh >> /usr/bin/dosomething.sh
以 root 身分執行curl
,並嘗試附加/usr/bin/dosomething.sh
目前使用者的權限(目前 shell 設定重定向)。