免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3970 | 回复: 10
打印 上一主题 下一主题

紧急求救 有没有哪个脚本是在/etc/profile前执行的啊? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-14 18:38 |只看该作者 |倒序浏览
现在碰到个问题

SUSE linux  8.0 下面

有一个用户  abis
在 /etc/passwd中可以看到该用户abis的 home目录为 /home/abis

在/etc/profile的最前面添加  echo  $HOME
当用该用户abis 登陆之后 可以看到 echo $HOME输出的为 /root
也就是说在 /etc/profile之前还有程序修改了 HOME!

各位高手看看哈!

论坛徽章:
0
2 [报告]
发表于 2006-07-14 19:47 |只看该作者
看你使用的是什么shell了
用户主目录下的
.bash_profile
.bashrc
.cshrc
.tcshrc
都有可能

论坛徽章:
0
3 [报告]
发表于 2006-07-14 23:15 |只看该作者
source

论坛徽章:
0
4 [报告]
发表于 2006-07-15 01:12 |只看该作者
原帖由 4Aiur 于 2006-7-14 19:47 发表
看你使用的是什么shell了
用户主目录下的
.bash_profile
.bashrc
.cshrc
.tcshrc
都有可能



使用的是bash
这些都是在/etc/profile之后执行的嘛?

论坛徽章:
0
5 [报告]
发表于 2006-07-15 13:05 |只看该作者
看shell就知道顺序了
cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATHHOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH

LANG=en_US
export LANG


cat  ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi


cat  ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[root@UNI_BJ_1_565 root]# cat /etc/bashrc
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    if [ -x /usr/bin/tput ]; then
      if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
        stty erase `tput kbs`
      elif [ -x /usr/bin/wc ]; then
        if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
          stty erase `tput kbs`
        fi
      fi
    fi
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}{PWD/#$HOME/~}\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}{PWD/#$HOME/~}\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
   
    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
            if [ -r "$i" ]; then
                . $i
            fi
        done
    fi
fi
# vim:ts=4:sw=4

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
6 [报告]
发表于 2006-07-15 17:48 |只看该作者
原帖由 miaoer 于 2006-7-14 18:38 发表
现在碰到个问题

SUSE linux  8.0 下面

有一个用户  abis
在 /etc/passwd中可以看到该用户abis的 home目录为 /home/abis

在/etc/profile的最前面添加  echo  $HOME
当用该用户abis 登陆之后 可以看到 e ...

/etc/profile,/etc/bashrc等文件的作用是啥?!

论坛徽章:
0
7 [报告]
发表于 2006-07-15 20:46 |只看该作者
原帖由 4Aiur 于 2006-7-15 13:05 发表
看shell就知道顺序了
cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
...



这都是 /etc/profile 之后的事情了啊?????

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
8 [报告]
发表于 2006-07-17 08:43 |只看该作者
原帖由 miaoer 于 2006-7-15 01:12 发表



使用的是bash
这些都是在/etc/profile之后执行的嘛?

HOME是内置变量,不是脚本产生的

论坛徽章:
0
9 [报告]
发表于 2006-07-17 19:05 |只看该作者
原帖由 waker 于 2006-7-17 08:43 发表

HOME是内置变量,不是脚本产生的



是内置变量,但是也可以被更改啊

现在我的问题是 在/bin/login 从/etc/passwd读出该值并赋值给HOME, 到执行/etc/profile 之前
这个过程中有没有其他的 程序或者脚本会更改 HOME的值.

论坛徽章:
0
10 [报告]
发表于 2006-07-17 19:19 |只看该作者
跟偶的问题一样,期待中......
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP