重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1794|回复: 3
打印 上一主题 下一主题

[系统管理] LINUX本机登录和SSH远程登录的区别

[复制链接]
跳转到指定楼层
楼主
发表于 2022-9-7 10:25:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
今天一学员工作中遇到问题了,具体如下:

江*彦(260761247) 2022/9/7 8:31:02
有人碰见这种情况没?在原机上通过oracle用户登录,配置的环境变量不生效,但是远程ssh用oracle登录,环境变量配置又是生效的

江*彦(260761247) 2022/9/7 8:31:58
而且在原机上先用roor登录,再su - oracle,环境变量也是生效的

江*彦(260761247) 2022/9/7 8:32:21
centos7.0


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

沙发
 楼主| 发表于 2022-9-7 10:31:09 | 只看该作者
本帖最后由 郑全 于 2022-9-7 10:32 编辑

其实,这个问题,就是登录shell和非登录shell 的区别。


登录式 shell:    .
    正常通过某终端登录的 shell。比如SECURECRT
   
    su - username。
   
    su -l username。

非登录式 shell:
    su username。
   
    图形终端下打开的命令窗口。(站在机器前面,直接登录xx用户)
   
    自动执行的 shell 脚本。






回复 支持 反对

使用道具 举报

板凳
 楼主| 发表于 2022-9-7 10:40:47 | 只看该作者
郑全 发表于 2022-9-7 10:31
其实,这个问题,就是登录shell和非登录shell 的区别。

bash shell 的配置文件
/etc/bashrc
/etc/profile
/etc/profile.d/*.sh
~/.bash_profile
~/.bashrc

登录式 shell 读取配置 文件过程:
/etc/profile–>/etc/profile.d/*.sh–>~/.bash_profile –>~/.bashrc–>/etc/bashrc

非登录式 shell 读取配置 文件过程:
~/.bashrc–>/etc/bashrc–>/etc/prodile.d/*.sh

回复 支持 反对

使用道具 举报

地板
 楼主| 发表于 2022-9-7 10:59:35 | 只看该作者
郑全 发表于 2022-9-7 10:40
bash shell 的配置文件
/etc/bashrc
/etc/profile

做一个测试:

1.先在每个文件中加一个配置文件路径显示:

[root@dbserver ]# tail -2 /etc/profile.d/test.sh
echo "1:i am no.1 /etc/profiles.d in test.sh"


[root@dbserver ]# tail -2 /etc/bashrc

echo "2:i'm No.2 /etc/bashrc,touch me!"


[root@dbserver ]# tail -2 /etc/profile

echo "3:i'm No.3 My Env:/etc/profile"
[root@dbserver ]#

以ORACLE用户为例:
[root@dbserver ]# tail -2 /home/oracle/.bashrc

echo "4:i'm No.4 ,My Env : ~.bashrc "
[root@dbserver ]#



[root@dbserver ]# tail -2 /home/oracle/.bash_profile

echo "5:i'm No.5 ,My Env .bash_profile!"
[root@dbserver ]#

2.测试通过SSH登录到ORACLE用户

  [oracle@dbserver ~]$ ssh oracle@192.168.133.120

   
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-20 04:58 , Processed in 0.108331 second(s), 22 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表