当我使用 sudo 命令时,它返回“无法打开 /etc/scl/prefixes/devtoolset-9!”

当我使用 sudo 命令时,它返回“无法打开 /etc/scl/prefixes/devtoolset-9!”

我的系统是 RHEL 6.7,输出为echo $PATH

[geoeast@hp2-12 ~]$ which rm
rm:      aliased to rm -i
[geoeast@hp2-12 ~]$ which cp
cp:      aliased to cp -i
[geoeast@hp2-12 ~]$ echo $PATH
/soft/geoeast4.0.3/opt/lightning/build/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/gstomo/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/diva/bin:/soft/geoeast4.0.3/opt/lightning/build/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/diva/bin:/soft/geoeast4.0.3/opt/gstomo/Linux.x86_64/bin:/soft/geoeast4.0.3/support/fontforge/bin:/soft/geoeast4.0.3/support/tools/bin:.:/soft/geoeast4.0.3/bin/cw:/soft/geoeast4.0.3/bin/GeoGME:/soft/geoeast4.0.3/bin/vsp:/soft/geoeast4.0.3/bin/sfp:/soft/geoeast4.0.3/bin/sdp/cshell:/soft/geoeast4.0.3/bin/sdppy:/soft/geoeast4.0.3/bin/statics:/soft/geoeast4.0.3/bin/sdp/bin:/soft/geoeast4.0.3/bin/sdp/int:/soft/geoeast4.0.3/bin/sdp:/soft/geoeast4.0.3/bin/mc:/soft/geoeast4.0.3/bin/cw:/soft/geoeast4.0.3/bin/ggi:/soft/ieco1.0.3/support/zookeeper/bin:/soft/ieco1.0.3/support/hadoop/hadoop-2.7.2/bin:/soft/ieco1.0.3/support/hadoop/hadoop-2.7.2/sbin:/soft/ieco1.0.3/install:/soft/ieco1.0.3/bin/batp:/soft/ieco1.0.3/bin/nap:/soft/ieco1.0.3/bin/ndp:/soft/ieco1.0.3/bin/ncp:/soft/ieco1.0.3/bin/ncld:/soft/ieco1.0.3/bin/common:/soft/ieco1.0.3/GeoSeisIO/bin:/soft/ieco1.0.3/ivtms/console:/soft/ieco1.0.3/licmng/bin:/soft/ieco1.0.3/support_2.6.32/tools/bin:/soft/ieco1.0.3/support_2.6.32/python/gbin:/soft/ieco1.0.3/support_2.6.32/cwp/bin:/soft/ieco1.0.3/support_2.6.32/mojoview/bin:/soft/ieco1.0.3/support_2.6.32/DDS.2011-07-15/bin:/soft/ieco1.0.3/support_2.6.32/PCG/bin:/soft/ieco1.0.3/support_2.6.32/gslib90/bin:/soft/ieco1.0.3/support_2.6.32/qcad:/soft/ieco1.0.3/support_2.6.32/qt3/bin:/soft/ieco1.0.3/support_2.6.32/ImageMagick/bin:/soft/ieco1.0.3/support_2.6.32/jdk/bin:/soft/ieco1.0.3/support_2.6.32/mysql/bin:/soft/ieco1.0.3/support_2.6.32/oiv/bin:/soft/ieco1.0.3/support_2.6.32/ora/bin:/soft/ieco1.0.3/support_2.6.32/postgresql/bin:/soft/ieco1.0.3/support_2.6.32/mvapich2.tcp/bin:/soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin:/usr/local/bin:/bin:/usr/bin:/usr/kerberos/sbin:/usr/kerberos/bin

这是示例:

[geoeast@hp2-12 /tmp]$ sudo rm test2
Unable to open /etc/scl/prefixes/devtoolset-9!

sudo cp -a返回相同的错误。

[geoeast@hp2-12 /tmp]$ sudo cp -a seismicview.log seismicview.log2
Unable to open /etc/scl/prefixes/devtoolset-9!

它与另一个用户一起工作:

[geoeast@hp2-12 /tmp]$ su geou1
Password: 
[geou1@hp2-12 /tmp]$ sudo cp -a seismicview.log seismicview.log2
[sudo] password for geou1: 
[geou1@hp2-12 /tmp]$ 

geou1 的输出echo $PATH

[geou1@hp2-12 /tmp]$ echo $PATH
.:/soft/geoeast3.0.5/support/fcitx/bin:/soft/geoeast3.0.5/support/fcitx/bin:/soft/geoeast3.0.5/bin/cw:/soft/geoeast3.0.5/GJSS/bin:/soft/geoeast3.0.5/support/ora/bin:/soft/geoeast3.0.5/bin/dp:/soft/geoeast3.0.5/GeoSeisIO/bin:/soft/geoeast3.0.5/bin/jsf:/soft/geoeast3.0.5/bin/vsp:/soft/geoeast3.0.5/bin/sfp:/soft/geoeast3.0.5/bin/sdp/int:/soft/geoeast3.0.5/bin/sdp/cshell:/soft/geoeast3.0.5/bin/sdp/bin:/soft/geoeast3.0.5/bin/systools:/soft/geoeast3.0.5/bin/mc:/soft/geoeast3.0.5/bin/cw:/soft/geoeast3.0.5/bin/gsm:/soft/geoeast3.0.5/bin/GJSS/gjssgui:/soft/geoeast3.0.5/bin/GJSS:/soft/geoeast3.0.5/bin/ggi:/soft/geoeast3.0.5/support/firefox:/soft/geoeast3.0.5/support/qcad:/soft/geoeast3.0.5/support/Adobe/Reader9/bin:/soft/geoeast3.0.5/support/Firefly/Client/bin:/soft/geoeast3.0.5/support/jdk/bin:/soft/geoeast3.0.5/support/qt3/bin:/soft/geoeast3.0.5/support/mysql/bin:/soft/geoeast3.0.5/support/oiv/bin:/soft/geoeast3.0.5/support/ora/bin:/soft/geoeast3.0.5/support/postgresql/bin:/soft/geoeast3.0.5/support/ImageMagick/bin:/soft/geoeast3.0.5/support/tools/bin:/soft/geoeast3.0.5/support/pyt/bin:/soft/geoeast3.0.5/support/mpi/bin:/soft/geoeast3.0.5/support/cwp/bin:/soft/geoeast3.0.5/support/cuda/bin:/soft/geoeast3.0.5/support/petsc/bin:/soft/geoeast3.0.5/support/mojoview/bin:/soft/geoeast3.0.5/support/paraview/bin:/usr/local/bin:/bin:/usr/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/sbin:/usr/GNQS/sbin:/usr/GNQS/bin

我应该怎么做才能使sudo命令起作用?

答案1

生成错误的用户帐户在其目录(搜索命令的目录列表)中Unable to open /etc/scl/prefixes/devtoolset-9!具有该目录。另一方面,成功运行的用户帐户不包含此目录。/soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin$PATHgeou1

因此,我猜测sudo您的第一个用户正在执行的实际上是在那个额外的目录中,而正是这个目录试图访问/etc/scl/prefixes/devtoolset-9. (您可以使用检查type sudo并确认它不在 中/usr/bin。)

这些目录看起来像是由某个机构添加的,因此最好的解决方案是将问题报告给 IT 服务台或系统管理员以供他们修复。

另一种方法可能是/soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin从您的目录中删除该目录$PATH,以便sudo根本不执行非官方版本。但是,我无法告诉您这可能会破坏什么。

PATH=$(echo "$PATH" | sed 's!:/soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin:!:!g')

当你在的时候,我会强烈地建议您.$PATH.

PATH=$(echo "$PATH" | sed 's!:\.:!:!g')

或者,重新排序目录列表​​,以便首先列出系统目录。在这里,我对它们进行了重新排序,删除了重复的条目,还取出了.

PATH=/usr/local/bin:/bin:/usr/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/soft/geoeast4.0.3/opt/lightning/build/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/gstomo/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/diva/bin:/soft/geoeast4.0.3/opt/lightning/build/Linux.x86_64/bin:/soft/geoeast4.0.3/opt/gstomo/Linux.x86_64/bin:/soft/geoeast4.0.3/support/fontforge/bin:/soft/geoeast4.0.3/support/tools/bin:/soft/geoeast4.0.3/bin/cw:/soft/geoeast4.0.3/bin/GeoGME:/soft/geoeast4.0.3/bin/vsp:/soft/geoeast4.0.3/bin/sfp:/soft/geoeast4.0.3/bin/sdp/cshell:/soft/geoeast4.0.3/bin/sdppy:/soft/geoeast4.0.3/bin/statics:/soft/geoeast4.0.3/bin/sdp/bin:/soft/geoeast4.0.3/bin/sdp/int:/soft/geoeast4.0.3/bin/sdp:/soft/geoeast4.0.3/bin/mc:/soft/geoeast4.0.3/bin/cw:/soft/geoeast4.0.3/bin/ggi:/soft/ieco1.0.3/support/zookeeper/bin:/soft/ieco1.0.3/support/hadoop/hadoop-2.7.2/bin:/soft/ieco1.0.3/support/hadoop/hadoop-2.7.2/sbin:/soft/ieco1.0.3/install:/soft/ieco1.0.3/bin/batp:/soft/ieco1.0.3/bin/nap:/soft/ieco1.0.3/bin/ndp:/soft/ieco1.0.3/bin/ncp:/soft/ieco1.0.3/bin/ncld:/soft/ieco1.0.3/bin/common:/soft/ieco1.0.3/GeoSeisIO/bin:/soft/ieco1.0.3/ivtms/console:/soft/ieco1.0.3/licmng/bin:/soft/ieco1.0.3/support_2.6.32/tools/bin:/soft/ieco1.0.3/support_2.6.32/python/gbin:/soft/ieco1.0.3/support_2.6.32/cwp/bin:/soft/ieco1.0.3/support_2.6.32/mojoview/bin:/soft/ieco1.0.3/support_2.6.32/DDS.2011-07-15/bin:/soft/ieco1.0.3/support_2.6.32/PCG/bin:/soft/ieco1.0.3/support_2.6.32/gslib90/bin:/soft/ieco1.0.3/support_2.6.32/qcad:/soft/ieco1.0.3/support_2.6.32/qt3/bin:/soft/ieco1.0.3/support_2.6.32/ImageMagick/bin:/soft/ieco1.0.3/support_2.6.32/jdk/bin:/soft/ieco1.0.3/support_2.6.32/mysql/bin:/soft/ieco1.0.3/support_2.6.32/oiv/bin:/soft/ieco1.0.3/support_2.6.32/ora/bin:/soft/ieco1.0.3/support_2.6.32/postgresql/bin:/soft/ieco1.0.3/support_2.6.32/mvapich2.tcp/bin:/soft/ieco1.0.3/support_2.6.32/devtoolset-9_as6/root/usr/bin

相关内容