linux - 用户登陆自加载脚本
来源:互联网 发布:淘宝客户资源管理分析 编辑:程序博客网 时间:2024/06/10 18:40
公共加载脚本
/etc/profile
此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置
/etc/bashrc | /etc/bash.bashrc (In Ubuntu)
为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
私人加载脚本
~/.bash_profile
每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
~/.bash_login
若bash是以login方式执行时,读取~/.bash_profile,若它不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。
~/.profile
if ~/.bash_profile or ~/.bash_login exists,~/.profile is not read by bash(1)
Ubuntu下的.profile
if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fifi# set PATH so it includes user's private bin if it existsif [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH"fi
~/.bashrc
该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.
大多数自登陆加载操作都放在这个文件中.比如:
- ls的一些别名设置:
# enable color support of ls and also add handy aliasesif [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' #alias dir='dir --color=auto' #alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto'fi# some more ls aliasesalias ll='ls -alF'alias la='ls -A'alias l='ls -CF'
- .bash_aliases自定义别名文件的加载
# Add an "alert" alias for long running commands. Use like so:# sleep 10; alertalias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'# Alias definitions.# You may want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# See /usr/share/doc/bash-doc/examples in the bash-doc package.if [ -f ~/.bash_aliases ]; then . ~/.bash_aliasesfi
~/.bash_logout
当每次退出系统(退出bash shell)时,执行该文件. 另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是”父子”关系.
参考:http://www.ahlinux.com/shell/20239.html
0 0
- linux - 用户登陆自加载脚本
- linux系统用户登陆时脚本执行顺序
- Linux---用户登陆查看
- linux 监控用户登陆
- linux 自启动脚本
- Linux自启动脚本
- Linux(7) 常用命令扩展 改变用户环境变量 (可以实现登陆就执行shell脚本)
- 域用户登陆脚本(网络收集)
- 关掉在线登陆用户 linux
- Linux查看用户登陆历史记录
- ubuntu登陆root用户-------linux
- Linux强制踢掉登陆用户
- Root用户Telnet登陆linux
- linux 用户管理脚本
- Linux用户管理 ----- 禁止用户登陆
- linux 开机自启脚本
- linux自解压安装脚本
- linux的自启动脚本
- OC-011.OC中的继承
- MapleSim在模型方程的妙用
- C++之数据库处理代理模块
- sed学习备忘录
- expdp/impdp逻辑数据迁移杂谈
- linux - 用户登陆自加载脚本
- org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilde
- jquery插件编写
- open vpn
- C++动态链接库测试实例
- .Net实用网页抓取
- 【CDH5】-002Cloudera Manager介绍和安装
- 第三讲:属性,点语法
- 百宝云语法变量与常量新手教程