用一般使用者開 nginx.conf 這類設定檔:

存檔時就會被一句「沒有 Root Permission」擋下。
加上:
:w !sudo tee %

不過我這裡遇到另一個問題:權限根本沒配。
用 sudo 時若看到「xxx is not in the sudoers file. This incident will be reported.」(xxx 為你的使用者名稱),代表該帳號不得使用 sudo,改一下 /etc/sudoers 即可:
1)切換到超級使用者:su -,輸入 root 密碼(或直接以 root 登入)。
2)加上寫入權限:chmod u+w /etc/sudoers
3)編輯:vim /etc/sudoers,按 i 進入編輯模式,找到 root ALL=(ALL) ALL 這行,在它下面新增一行 xxx ALL=(ALL) ALL(xxx 換成你的使用者名稱),存檔退出(Esc 後輸入 :wq)。
4)撤銷寫入權限:chmod u-w /etc/sudoers

再次存檔後,用 grep 確認內容是否真的寫入:
$ grep sudo nginx.conf
#test :w !sudo tee %
把帳號設成 ALL=(ALL) ALL 等於給了完整 root 權限,正式環境建議改用最小必要的指令白名單,例如只允許執行 systemctl restart nginx,而非全開。另外 sudoers 是唯讀檔案,編輯完記得把寫入權限收回去。