环境变量配置文件简介
来源:互联网 发布:傲剑双龙斩升级数据 编辑:程序博客网 时间:2024/06/01 15:39
Part 1:环境变量配置文件简介
前面的在介绍shell编程:变量中就介绍了环境变量的设置方法,但是那都是临时生效的,在系统重启之后就会失去作用,所以为了保证环境变量永久生效,就需要修改相对应的配置文件。
环境变量配置文件中主要是定义对系统操作环境生效的系统默认环境变量。
Extra: source 配置文件 或者 . 配置文件
介绍一下后面这个,.(空格)配置文件,的命令,这样的方式与直接使用source命令的作用是一致的,都能使配置文件在不重新登录的情况下起作用。
Part 2:环境变量配置文件作用
以上图片就是CentOX 6上开机时运行的配置文件顺序。我在Ubuntu 16.04 LTS上尝试一下。
2.1 /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).# 由于$PS1实在这个配置文件 ./etc/bash.bashrc 中定义的,所以开始不会运行 ./etc/bash.bashrc,但是$BASH这个变量是定义好的if [ "$PS1" ]; then if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then # The file bash.bashrc already sets the default PS1. # PS1='\h:\w\$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fifi# 所以接着该文件运行的就是 /etc/profile.d/ 中的所有以 .sh 结尾的shell脚本文件if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset ifi
2.2 /etc/profile.d/*.sh
该目录下的所有文件有:
- appmenu-qt5.sh
- apps-bin-path.sh
- bash_completion.sh
- cedilla-portuguese.sh
- vte-2.91.sh
按照原本图上的lang.sh就没有了,该文件是定义语系的,就是这里。下面就没法查看了。
2.3 /etc/sysc config/i18n
这个文件是什么鬼,我在Ubuntu上没有找到。
———————–到此为止,下面的顺序就运行完了,接下来就是上面部分了。——————–
2.4 ~/.bash_profile
“~”表示家目录,每个用户都有自己对应的家目录。该文件在Ubuntu中就是 ~/.profile,里面的内容是:
# ~/.profile: executed by Bourne-compatible login shells.# 这个参数前面哪个文件设置过得,所以下面就是执行 ~/.bashrcif [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fifimesg n || true
2.5 ~/.bashrc
这个文件里面有两个内容,是以前讲过的,还有这个之后运行的 /etc/bashrc 这个文件我在 /etc/ 目录下没有查到。
2.5.1 历史命令最大保留条数:HISTSIZE
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)HISTSIZE=1000HISTFILESIZE=2000
2.5.2 别名设置配置文件:alias 别名=”原始命令”
2.6 退出(logout)时执行的配置文件:~/.bash_logout
这个配置文件我在自己的版本下没有看到。
2.7 历史命令保存文件:~/bash_history
Part 3:shell登录信息
3.1 本地终端欢迎信息:/etc/issue
注意,是本地终端。
我的配置文件的内容是:
Ubuntu 16.04 LTS \n \l
在开机时,还没有切换到图形界面前,命令行中显示的就是这个信息。
3.2 远程终端欢迎信息:/etc/issue.net
3.3 登录后欢迎信息:/etc/motd
这个文件在我系统上没看到。
0 0
- Ubuntu环境变量配置文件简介
- 环境变量配置文件简介
- 环境变量配置文件简介
- Shell基础-环境变量配置文件-简介
- Ubuntu Linux系统环境变量配置文件简介
- 【Linux学习笔记】33:环境变量配置文件简介
- 环境变量配置文件
- 环境变量配置文件
- 环境变量配置文件
- 环境变量配置文件
- Linux环境变量配置文件
- Ubuntu 环境变量配置文件介绍
- Linux环境变量配置文件
- Linux 配置文件/配置环境变量
- Ubuntu系统环境变量配置文件
- linux 环境变量配置文件相关
- Ubuntu 环境变量各配置文件
- linux 环境变量配置文件
- 算法训练 删除数组零元素
- 过滤敏感词汇
- JavaScript运算符的优化
- 卫语句
- [HDU1812]Count the Tetris(置换群)
- 环境变量配置文件简介
- Java Script 小笔记
- hihocoder1044
- cmd命令行中javac报错:类HelloWorld是公有的,应在名为HelloWorld.java的文件中声明,public class HelloWorld
- 【Error】: rpm: arguments to --root (-r) must begin with a /
- Bootstarp实现一列固定 另外一列随元素增高 但不影响其他列的方式
- HDU4864_Task_贪心
- Bzoj 2683: 简单题(CDQ分治)
- Android不同APP之间三种共享数据的方式