![無法在 Ubuntu 16.04 上使用 sudo 開啟 MATLAB](https://rvso.com/image/1157151/%E7%84%A1%E6%B3%95%E5%9C%A8%20Ubuntu%2016.04%20%E4%B8%8A%E4%BD%BF%E7%94%A8%20sudo%20%E9%96%8B%E5%95%9F%20MATLAB.png)
我在 Ubuntu 16.04 上安裝了 MATLAB R2017a。
從控制台,我能夠運行matlab
並成功啟動軟體。但是,如果我運行sudo matlab
,則會出現以下錯誤:
sudo: matlab: command not found
sudo su
我通過先運行然後再運行獲得了相同的響應matlab
。
我怎麼可能只能在沒有 的情況下運行它sudo
?是否有sudo
特定的路徑要更新?
答案1
是的,sudo
有自己的secure_path
。從man sudoers
:
secure_path Path used for every command run from sudo. If you don't trust the people running sudo to have a sane PATH environ‐ ment variable you may want to use this. Another use is if you want to have the “root path” be separate from the “user path”. Users in the group specified by the exempt_group option are not affected by secure_path. This option is not set by default.
(請注意,它是Ubuntu 預設值/etc/sudoers
)。
如果您決定修改它,請記住使用visudo
而不是常規編輯器,以避免在出現語法錯誤時將自己鎖定。
更好的選擇可能是從 Ubuntu 上已有的某個位置創建符號鏈接,sudo
secure_path
例如
$ ls -ld $(which matlab)
lrwxrwxrwx 1 root root 35 Apr 11 2017 /usr/local/bin/matlab -> /usr/local/MATLAB/R2017a/bin/matlab
最重要的是安排您的裝置權限,這樣就不需要matlab
以 root 身分執行。