15

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
15
  • 1
    Has anyone created an alias for your sudo command? Commented Mar 27, 2015 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). Commented Mar 27, 2015 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. Commented Mar 27, 2015 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. Commented Mar 28, 2015 at 2:20
  • 1
    centos7 - can't believe this is still an issue
    – Spongman
    Commented Nov 17, 2020 at 20:41

4 Answers 4

8

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
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.

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"
0

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

1
  • It's broken again in devtoolset-11 and 12
    – Pascal
    Commented Mar 16, 2023 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .