Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1614107
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类: LINUX

2012-02-22 09:46:54

想做跳板机,故想到了这些,然后转载这个篇文章,让更多的朋友看到:

  1. 作者:KornLee 2005-02-03 15:49:57 来自:Linux先生
  2. 链接:
  3. /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
  4. 并从/etc/profile.d目录的配置文件中搜集shell的设置.
  5. /etc/bashrc:为每一个运行bash shell用户执行此文件.当bash shell被打开时,该文件被读取.
  6. ~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该
  7. 文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
  8. ~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该
  9. 该文件被读取.
  10. ~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.
  11. 另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系.
  12. ~/.bash_profile 是交互式、login 方式进入 bash 运行的
  13. ~/.bashrc 是交互式 non-login 方式进入 bash 运行的
  14. 通常二者设置大致相同,所以通常前者会调用后者。
  1. [yangkai@admin ~]$ cat .
  2. ./ .bash_history .bash_profile .mozilla/ .Xauthority 
  3. ../ .bash_logout .bashrc .viminfo .zshrc 
  4. [yangkai@admin ~]$ cat .bashrc 
  5. # .bashrc

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

  10. # User specific aliases and functions
  11. [yangkai@admin ~]$ cat .bash_profile 
  12. # .bash_profile

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

  17. # User specific environment and startup programs

  18. PATH=$PATH:$HOME/bin

  19. export PATH
  20. #echo "hello,kaige."
  21. echo 'hello,kaige!this is 132.'
  22. sleep 1
  23. [yangkai@admin ~]$ cat .bash_logout 
  24. # ~/.bash_logout

  25. /usr/bin/clear
  26. echo 'bye,kaige!'
  27. [yangkai@admin ~]$
  28. [yangkai@admin ~]$ cat /etc/bashrc 
  29. # /etc/bashrc

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

  32. # By default, we want this to get set.
  33. # Even for non-interactive, non-login shells.
  34. if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
  35. umask 002
  36. else
  37. umask 022
  38. fi

  39. # are we an interactive shell?
  40. if [ "$PS1" ]; then
  41.     case $TERM in
  42. xterm*)
  43. if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
  44. PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
  45. else
  46.     PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
  47. fi
  48. ;;
  49. screen)
  50. if [ -e /etc/sysconfig/bash-prompt-screen ]; then
  51. PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
  52. else
  53. PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
  54. fi
  55. ;;
  56. *)
  57. [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
  58.    ;;
  59.     esac
  60.     # Turn on checkwinsize
  61.     shopt -s checkwinsize
  62.     [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
  63. fi

  64. if ! shopt -q login_shell ; then # We're not a login shell
  65. # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
  66.     pathmunge () {
  67. if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
  68. if [ "$2" = "after" ] ; then
  69. PATH=$PATH:$1
  70. else
  71. PATH=$1:$PATH
  72. fi
  73. fi
  74. }

  75. # Only display echos from profile.d scripts if we are no login shell
  76.     # and interactive - otherwise just process them to set envvars
  77.     for i in /etc/profile.d/*.sh; do
  78.         if [ -r "$i" ]; then
  79.             if [ "$PS1" ]; then
  80.                 . $i
  81.             else
  82.                 . $i >/dev/null 2>&1
  83.             fi
  84.         fi
  85.     done

  86. unset i
  87. unset pathmunge
  88. fi
  89. # vim:ts=4:sw=4
  90. [yangkai@admin ~]$ 






阅读(2227) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~