Linux bashrc和profile的用途和区别
| 导读 | 使用终端ssh登录Linux操作系统的控制台后,会出现一个提示符号(例如:#或~),在这个提示符号之后可以输入命令,Linux根据输入的命令会做回应,这一连串的动作是由一个所谓的Shell来做处理。Shell是一个程序,最常用的就是Bash,这也是登录系统默认会使用的Shell。 |
用户HOME(家)目录/.bashrc
head -1 ~/.bashrc # ~/.bashrc: executed by bash(1) for non-login shells.
用户HOME(家)目录/.profile
head -1 ~/.profile # ~/.profile: executed by Bourne-compatible login shells.
head -1 /etc/bash.bashrc # System-wide .bashrc file for interactive bash(1) shells. head -2 /etc/profile # /etc/profile: system-wide .profile file for the Bourne shell (sh(1) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
从上面的英文描述可以知道,bashrc和profile的差异在于: 1. bashrc是在系统启动后就会自动运行。 2. profile是在用户登录后才会运行。 3. 进行设置后,可运用source bashrc命令更新bashrc,也可运用source profile命令更新profile。 PS:通常我们修改bashrc,有些linux的发行版本不一定有profile这个文件,本文用的系统是Ubuntu 15.10 4. /etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。
另外,需要补充说明介绍bashrc相关的几个文件:
~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。
~/.bash_logout: 当每次退出系统(退出bash shell)时,执行该文件。
~/.bash_profile 是交互式、login方式进入bash运行的,~/.bashrc是交互式non-login方式进入bash运行的,通常二者设置大致相同,所以通常前者会调用后者。
本文转载自:http://www.linuxprobe.com/linux-bashrc-profile-different.html
更多Linux干货请访问:http://www.linuxprobe.com/
Linux bashrc和profile的用途和区别的更多相关文章
- Linux基础知识之bashrc和profile的用途和区别
使用终端ssh登录Linux操作系统的控制台后,会出现一个提示符号(例如:#或~),在这个提示符号之后可以输入命令,Linux根据输入的命令会做回应,这一连串的动作是由一个所谓的Shell来做处理. ...
- bashrc和profile的用途和区别
使用终端登录Linux操作系统的控制台后,会出现一个提示符号(例如:#或~),在这个提示符号之后可以输入命令,Linux根据输入的命令会做回应,这一连串的动作是由一个所谓的Shell来做处理. She ...
- 【转】Linux中/etc/profile,/etc/bashrc,~/.profile,~/.bashrcd的区别
//因为在原文章中博主说以下内容是网友说的,所以我就只加个转了,找不到原作者 /etc/profile,/etc/bashrc 是系统全局环境变量设定 ~/.profile,~/.bashrc用户家目 ...
- linux中/etc/profile 和 ~/.bash_profile 的区别
在 linux中设置环境变量一般使用bash_profile进行配置 其中/etc/bash_profile 表示系统整体设置 ,生效后系统内所有用户可用而 ~/.bash_profile 只表示当前 ...
- linux关于bashrc与profile的区别(转)
转载自:http://www.cnblogs.com/hongzg1982/articles/2101792.html bashrc与profile的区别 要搞清bashrc与profile的区别,首 ...
- linux中bashrc与profile的区别
bashrc与profile的区别 要搞清bashrc与profile的区别,首先要弄明白什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. ...
- [转] - bashrc与profile的区别
bashrc与profile的区别 要搞清bashrc与profile的区别,首先要弄明白什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. ...
- [转]bashrc与profile区别
作者:KornLee 2005-02-03 15:49:57 来自:Linux先生 /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/pro ...
- 《学渣Linux笔记》——关于.bashrc与profile(涉及交互式与非交互式、登录与非登录shell)
<学渣Linux笔记>--关于.bashrc与profile(涉及交互式与非交互式.登录与非登录shell) 1.基本概念(个人理解) 交互式shell:等待用户输入,并执行相应操作的sh ...
随机推荐
- 计算excel列的名字
#include <iostream> using namespace std; int main() { unsigned int column; cin>> ...
- poj题目必做
OJ上的一些水题(可用来练手和增加自信) (poj3299T,poj2159T,poj2739T,poj1083T,poj2262T,poj1503T,poj3006T,poj2255T,poj309 ...
- Exif的Orientation信息说明
EXIF Orientation 参数让你随便照像但都可以看到正确方向的照片而无需手动旋转(前提要图片浏览器支持,Windows 自带的不支持) 这个参数在佳能.尼康相机照的照片是自带的,但我的奥林巴 ...
- HDU 2255 二分图最佳匹配 模板题
题目大意: 给定每一个人能支付的房子价值,每个人最多且必须拥有一套房子,问最后分配房子可得到的最大收益 抄了个别人的KM模板,就这样了... #include <cstdio> #incl ...
- 获取Android系统的版本号
int currentVersion = android.os.Build.VERSION.SDK_INT;
- C# WebBrowser NativeMethods
using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using Syste ...
- HTML--4格式布局
一.position:fixed 锁定位置(相对于浏览器的位置),例如有些网站的右下角的弹出窗口. 示例: 二.position:absolute 1.外层没有position:absolute(或r ...
- 如何为Eclipse设置代理
看图,不解释:
- Ubuntu 开启ssh
sudo apt-get install openssh-server Ubuntu缺省安装了openssh-client,所以在这里就不安装了,如果你的系统没有安装的话,再用apt-get安装上即可 ...
- javascript的词法分析
-.arguments的解释: 1.是一个对象,是一个长的很像数组的对象 二.arguments内容是什么? 1.arguments是函数运行时的实参列表 2.arguments收集的“所有”的实参, ...