ubuntu bash环境设置
来源:互联网 发布:为什么淘宝上苏宁易购 编辑:程序博客网 时间:2024/05/22 15:04
第一步 系统级设置
读取/etc/profile文件,再根据/etc/profile文件的内容去读取其他附件的设置文件,例如/etc/profile.d/*.sh等
第二步 个人设置
根据不同的用户,到家目录去读取~/.bash_profile或~/.bash_login或~/.profile设置文件
其中:
这三个文件通常只要一个即可,不过存在顺序上的差异:bash启动时,会先去读取~/.bash_profile,找不到时就去读取~/.bash_login,再找不到时则读取~/.profile
根据不同的用户,到家目录去读取~/.bashrc文件
所以登陆bash后,最终读取的设置文件是~/.bashrc,通常可以将个人的一些常用的alias或者PATH等环境变量或者自定义变量都写到这个文件。
ps: 可能需要注意区分login shell 与 non-login shell
A login shell is one whose first character of argument zero is a -, or one started with the --login option.
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to the terminal , or one started with the -i option.
Login Shell: 登录的时候,你输入帐号和密码进入了,出现了shell提示符,这个过程就是登录外壳;
Interactive Shell:接下来你得到了一个像root@host />这样的提示符,你输入什么,它就解释出什么,这就是交互式外壳;
Non Interactive Shell:你可能需要学习写一个bash script,用外部shell执行:bash script.sh,它(bash)从第一条命令执行到最后一条然后退出,不与你进行任何交互,它就是非交互式外壳
详见:
man 1 bash 之 INVOCATION
" a non-login shell, which does not read /etc/profile or ~/.bash_profile files, but rather reads the ~/.bashrc instead."
例子:
新建用户 lfs
useradd -s /bin/bash - lfs -m -k /dev/null lfs
在用户lfs的根目录中新建.bashrc文件,输入:
LFS=/mnt/lfs
以root身份使用命令su lfs(非登录shell)
echo $LFS
/mnt/lfs
以root身份使用命令su - lfs (登录shell)
echo $LFS
- ubuntu bash环境设置
- ubuntu shell环境 dash bash
- 配置UBUNTU下bash、 python环境
- UBUNTU中文手册摘要 - BASH设置
- ubuntu自定义命令设置一(bash)
- Ubuntu 网络环境设置
- ubuntu初装环境设置
- Ubuntu-C++环境设置
- ubuntu设置java环境
- Ubuntu语言环境设置
- ubuntu设置中文环境
- bash环境
- bash 环境
- BASH环境
- Ubuntu 多媒体应用环境设置
- ubuntu 10.04编程环境设置
- Ubuntu 安装设置 LAMP 环境
- ubuntu android 编译环境设置
- SQL Server 2008下轻松调试T-SQL语句和存储过程
- 给openfire写一个HellowWorld插件的简明教程
- Java中关于HashMap的使用和遍历
- Java数据结构分析
- cxf基本入门
- ubuntu bash环境设置
- 使用lazy-init,加速单元测试速度
- System.Globalization.NumberFormatInfo 的 30个属性、1个构造函数和10个方法
- IEEE 754 double 编码为二进制
- 《Windows via C/C++》学习笔记 —— “线程同步”之“检测死锁”
- linux 调试
- weblogic node maanger 远程命令执行漏洞
- 状态模式(python)
- iperf的相关介绍