12

When I try to switch to root using sudo -i i get the error /var/tmp/sclDvf3Vx: line 8: -i: command not found... However, su - works which I will continue to use. I'm by no means a linux system administrator so the environment is still pretty foggy to me. I guess my questions are:

  1. Why is the error being thrown?
  2. What's the difference between the two commands?
  3. Why would you use one over the other?

Update:

I'm using CentOS version: CentOS release 6.6 (Final)

Here's the output from some commands I was asked to run, in the comments below.

  • type sudo : sudo is /opt/centos/devtoolset-1.1/root/usr/bin/sudo
  • sudo -V : /var/tmp/sclIU7gkA: line 8: -V: command not found
  • grep'^root:' /etc/passwd : root:x:0:0:root:/root:/bin/bash

Update:

This was added to my non-root user's ~/.bashrc a while back because i needed C++11 support. When I comment it out, re-ssh in, I can run sudo -i just fine without any errors.

if [ "$(gcc -dumpversion)" != "4.7.2" ]; then 
  scl enable devtoolset-1.1 bash
fi
  • Are you sure the - is really an (ASCII) -? – steeldriver Mar 27 '15 at 3:32
  • 1
    Has anyone created an alias for your sudo command? – garethTheRed Mar 27 '15 at 7:50
  • 2
    Ok, so you have a local command called sudo which is not the normal sudo command. Given that it doesn't understand sudo's options, it's clearly not some standard thing. Either use /usr/bin/sudo or ask your local administrators (who should really have told you about this when they gave you sudo powers). – Gilles 'SO- stop being evil' Mar 27 '15 at 23:08
  • 4
    I'm voting to close this question as off-topic because it concerns some unknown, probably home-grown program, which the internet cannot help with. – Gilles 'SO- stop being evil' Mar 27 '15 at 23:10
  • 4
    I don't think this is home-grown at all, it's CentOS's version of RH Developer Toolset: people.centos.org/tru/devtools-1.1 . Presumably someone on the internet does know about it. – Michael Homer Mar 28 '15 at 2:20
7

From the comments and your further investigations it looks like your devtoolset is modifying the PATH. Unfortunately that includes what appears to be an old or broken sudo command.

It would be worth trying to modify the devtoolset include in your .bashrc like this, and then logging back in again:

if [ "$(gcc -dumpversion)" != "4.7.2" ]; then 
  scl enable devtoolset-1.1 bash
  PATH=/usr/bin:$PATH    # We need a working sudo
fi
| improve this answer | |
2

Rather than work around the SCL's broken sudo wrapper, I just disabled it.

echo >> /opt/rh/devtoolset-2/root/usr/bin/sudo
chmod -x /opt/rh/devtoolset-2/root/usr/bin/sudo

Adding a newline to the end of the file ensures it won't get overwritten by subsequent Yum updates, and then I just make it non-executable.

I installed the dev toolset to get modern versions of gcc and c++ on RHEL 6, and have had no issues compiling code without the fake sudo in the mix.

| improve this answer | |
1

I had similar issues with sudo -E flag after using devtoolset-4. You should not add -E flag in that case, because it is added in /opt/rh/devtoolset-4/root/usr/bin/sudo wrapper script, here is the contents of it:

#! /bin/sh
# TODO: parse & pass-through sudo options from $@
sudo_options="-E"

for arg in "$@"
do
   case "$arg" in
    *\'*)
      arg= ;;
   esac
   cmd_options="$cmd_options '$arg'" 
done
exec /usr/bin/sudo $sudo_options LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH scl enable devtoolset-4 "$cmd_options"
| improve this answer | |
0

This was reported to RedHat in BZ1319936 and fixed in devtoolset devtoolset-9-9.0-3.el7 (RHEA-2019:4132).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.