bash 配置文件
两类:
profile类:为交互式登录的shell进程提供配置
bashrc类:为非交互式登录的shell进程提供配置
登录类型:
交互式登录shell进程:
直接通过某终端输入账号和密码后登录打开的shell进程;
使用su命令:su - username, 或者 su -l username 执行的切换
非交互式登录shell进程:
su username 执行的用户登录切换;
图形 界面打开的终端;
profile类:
全局配置:对所有用户都生效;
/etc/profile
/etc/profile.d/*.sh
用户个人:仅对当前用户有效
~/.bash_profile
功用:
1. 用户定义环境变量;
2. 运行命令脚本;
bashrc类:
全局:
/etc/bashrc
用户个人:
~/.bashrc
功用:
1.定义本地变量;
2.定义命令别名;
notice:仅管理员可修改全局配置文件;
交互式登录shell进程:
/etc/profile --->> /etc/profile.d/* --->> ~/.bash_profile -->> ~/.bashrc -->> /etc/bashrc
非交互式登录shell进程:
~/.bashrc -->> /etc/bashrc -->> /etc/profile.d/*
命令行定义的特性,例如变量和别名作用域为当前shell进程的生命周期;
配置文件定义的特性,只对随后新启动的shell进程有效;
让通过配置文件定义的特性立即生效:
(1)通过命令行重复定义一次;
(2)让shell进程重读配置文件;
~] # source /PATH/FROM/CONF_FILE
~] # ./PATH/FROM/CONF_FILE
问题:
(1)怎么定义对所有用户生效的命令别名,例如 ‘lftps="lftp 192.168.157.157/pub"’
(2)让centos用户登录时,提供其已经登录,并显示当前系统时间?