当前位置: 首页 > news >正文

linux中profile.d和profile的区别

profile.d在profile中加载

profile文件

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/scripts:/soc/bin:/soc/scripts"
LD_LIBRARY_PATH="/usr/local/lib:/usr/lib:/opt/lib:/soc/lib"
export SSL_LDPATH=/usr/local/lib/
export ZLIB_LDPATH=/usr/local/lib/export PATH
export LD_LIBRARY_PATH
export TERM=vt102
export TERMINFO=/usr/share/terminfo
export TZ=CTS-8ulimit -s 2048if [ "$PS1" ]; thenif [ "`id -u`" -eq 0 ]; thenexport PS1='$PWD # 'elseexport PS1='$PWD $ 'fi
fiexport EDITOR='/bin/vi'#use script to control npu BW
export SELECT_SCRIPT_CTRL_BW=enabled# Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh ; doif [ -r "$i" ]; then. $ifi
done
unset i

在 /etc/profile 这个文件中有这么一段 shell, 会在每次启动时自动加载 profile.d 下的每个配置

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i

区别

  • 都用来设置环境变量文件
  • /etc/profile.d/ 高度解耦, 比 /etc/profile 好维护,不想要什么变量直接删除
  • /etc/profile.d/ 下对应的 shell 脚本即可
  • /etc/profile 和 /etc/profile.d 同样是登录(login)级别的变量,当用户重新登录 shell 时会触发
  • 设置登录级别的变量,重新登录 shell,或者 source /etc/profile

需要添加新的环境变量时

在 /etc/profile.d/ 目录下新建对应的 sh 文件即可,比如新建 oracle 的:

vim /etc/profile.d/oracle19c.sh
http://www.lryc.cn/news/124339.html

相关文章:

  • MobaXterm sftp 不能拖拽文件夹了?
  • 【ArcGIS Pro二次开发】(59):Editing(编辑)模块
  • WebSocket与消息推送
  • 5.1 web浏览安全
  • (六)Unity开发Vision Pro——词汇表
  • 算法随笔:图论问题之割点割边
  • 【虚幻引擎】UE5数字人的创建
  • 算法:深度优先遍历
  • Stable Diffusion + Deform制作指南
  • ssm+vue网上花店设计源码和论文
  • 【leetcode】第一章数组
  • 01|Java中常见错误或不清楚
  • 递归的用法和例子
  • 极狐GitLab 企业级 CI/CD 规模化落地实践指南(一)
  • springBoot 简单的demo
  • [国产MCU]-BL602开发实例-实时时钟(RTC)
  • 大数据Flink(六十三):SqlClient工具的使用
  • 哈威比例多路阀控制放大器
  • Java bean 是个什么概念?
  • 微服务系列文章之 Springboot+Vue实现登录注册
  • 【Docker】如何在设计 dockerfile 过程中,设置容器启动后的定时任务
  • 【leetcode】第三章 哈希表part01
  • Docker中Tomcat部署步骤
  • pycharm 安装库
  • 使用 Ploomber、Arima、Python 和 Slurm 进行时间序列预测
  • springboot第35集:微服务与flutter安卓App开发
  • java 把list转成json
  • R语言实现随机生存森林(2)
  • 泛型类接口方法学习
  • Docker自动化部署安装(十)之安装SonarQube