sudo 與 apt-get問題 - Linux

Table of Contents

我的系統是ubuntu server 12.04
因為公司網路關係有使用proxy (設在/etc/environment)

現在問題是,如果我不是root,我打sudo apt-get update
會發生下列事情:

Err http://security.ubuntu.com precise-security InRelease

Err http://free.nchc.org.tw precise InRelease

Err http://free.nchc.org.tw precise-updates InRelease

Err http://security.ubuntu.com precise-security Release.gpg
Temporary failure resolving 'security.ubuntu.com'
Err http://free.nchc.org.tw precise-backports InRelease

Err http://free.nchc.org.tw precise Release.gpg
Temporary failure resolving 'free.nchc.org.tw'
Err http://free.nchc.org.tw precise-updates Release.gpg
Temporary failure resolving 'free.nchc.org.tw'
Err http://free.nchc.org.tw precise-backports Release.gpg
Temporary failure resolving 'free.nchc.org.tw'
Reading package lists... Done
W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise/InRelease

W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise-updates/InRelease

W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise-backports/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'free.nchc.org.tw'

W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'free.nchc.org.tw'

W: Failed to fetch http://free.nchc.org.tw/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'free.nchc.org.tw'

W: Some index files failed to download. They have been ignored, or old ones used instead.

但是如果我用root,我直接打apt-get update
就會正常的get,get,get,get......

但是如果我用root,指令是打sudo apt-get update
又會出現上述的error

請問這是什麼情況??
看起來像dns解析的問題,要怎麼改??

--

All Comments

Candice avatarCandice2014-08-16
自問自答,用root帳號執行apt-get install sudo
Kama avatarKama2014-08-18
應該是你的 proxy 環境變數沒被 sudo 繼承下去
Susan avatarSusan2014-08-22
請打 sudo visudo 後,鍵入一行:
Lily avatarLily2014-08-25
Defaultsenv_keep+="http_proxy https_proxy ftp_proxy"
Defaults env_keep+="http_proxy https_proxy ftp_proxy"
Jacky avatarJacky2014-08-27
Sorry, 第一個少一個空白,請忽略。
Jacob avatarJacob2014-08-30
引號內請換成你真正新增的proxy變數,空白格開。