登录式shell:
通过终端登录
su - USERNAME
非登录式shell:
su USERNAME(用su切换用户,不带参数)
GUI下打开命令窗口
自动执行的shell脚本(使用at, crontab, anacron等)
bash的配置文件:
全局配置:/etc/profile,/etc/profile.d/*.sh,/etc/bashrc
个人配置:~/.bash_profile,~/.bashrc
profile类的文件:设定环境变量,运行命令或脚本
bashrc类的文件:设定本地变量,定义命令别名
登录式shell:
启动脚本加载顺序:/etc/profile --> /etc/profile.d/* --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc
注:/etc/profile 是登录式shell启动后运行的第一个启动脚本,非登录式shell不会使用该脚本
每个调用的脚本会依次撤销前一个调用脚本中的改变,
可以把某些任务如创建自动备份,清除临时文件 写入到 ~/.bash_logout 文件中来达到每次退出登录式shell自动执行相关任务的目的
非登录式shell
加载启动脚本顺序:~/.bashrc --> /etc/bashrc --> /etc/profile.d/*
^_^
转载于:https://blog.51cto.com/junight/1728748