- 主题:/etc/profile.d 下面的脚本不管用,为何?
安装Modules环境管理软件。
Ubuntu 20.04,以前用18.04没问题。
现在apt-get install environment-modules之后,运行module,系统显示找不到命令。
本以为是库问题,自己编译了一个,按照手册,在/etc/profile.d下面建立了两个连接:
ln -s /usr/local/Modules/init/profile.sh /etc/profile.d/modules.sh
ln -s /usr/local/Modules/init/profile.csh /etc/profile.d/modules.csh
但发现还是一样的问题,显示找不到module命令,看来是系统的问题。
系统默认的shell:
cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/etc/profile.d/modules.sh的内容如下:
# get current shell name by querying shell variables or looking at parent
# process name
if [ -n "${BASH:-}" ]; then
shell=${BASH##*/}
elif [ -n "${ZSH_NAME:-}" ]; then
shell=$ZSH_NAME
else
shell=$(/usr/bin/basename $(/usr/bin/ps -p $$ -ocomm=))
fi
if [ -f /usr/local/Modules/init/$shell ]; then
. /usr/local/Modules/init/$shell
else
. /usr/local/Modules/init/sh
fi
我如果直接source /usr/local/Modules/init/bash,就能找到module命令。
这是何故?
--
修改:VShaka FROM 111.201.210.*
FROM 111.201.210.*
你得看看你当前的shell是怎么建立启动文件的
一般的检查步骤:
1 首先区分login shell和non-login shell,然后找该shell在用户目录下的profile或者rc。一般情况下oracle DBA会分不清楚这个
2 然后看,用户级profile或者rc,有没有引用系统级profile
3 再看,系统级profile有没有引用profile.d
【 在 VShaka (昵称) 的大作中提到: 】
: 安装Modules环境管理软件。
: Ubuntu 20.04,以前用18.04没问题。
: 现在apt-get install environment-modules之后,运行module,系统显示找不到命令。
: ...................
--
FROM 119.123.204.*
看看/etc/profile呢
$ grep -A6 'profile.d' /etc/profile
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
--
FROM 171.221.52.*