Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
719 views
in Technique[技术] by (71.8m points)

linux - CentOS error - sudo: effective uid is not 0, is sudo installed setuid root?

I found another question with the same headline, however, I suppose my case is a bit different.

In an attempt to setup the new project, I needed to install nodejs. I realised that it worked only when used with sudo. For eg. sudo npm

Furthermore, I visited the link https://docs.npmjs.com/getting-started/fixing-npm-permissions and performed

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

to change default directory permissions. Now because I had to sudo npm here as well, I ran

sudo chown -R $(whoami) $(sudo npm config get prefix)/{lib/node_modules,bin,share}

Post this, whenever I try to use sudo, I get this error -

sudo: effective uid is not 0, is sudo installed setuid root?

I understand that my setup for npm should have been better and off root, but I am a Linux novice.

Any help would be appreciated. :)

More information -

ls -l $(which sudo) gives => ---s--x--x. 1 dev root 123832 Aug 13 2015 /usr/bin/sudo

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem is that you probably changed permissions to the directory /usr/bin.

To resolve that :

1) First be sure that root is owner of this directory /usr/bin :

chown root:root /usr/bin

2) and change permission for this directory :

chmod u+s /usr/bin/sudo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...