linux中bashrc与profile有什么区别

发布时间:2022-02-18 14:17:23 作者:小新
来源:亿速云 阅读:104

小编给大家分享一下linux中bashrc与profile有什么区别,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

要搞清bashrc与profile的区别首先要弄明白什么是交互式shell和非交互式shell,什么是login shell 和non-login shell。

linux中bashrc与profile有什么区别

交互式模式就是shell等待你的输入,并且执行你提交的命令。这种模式被称作交互式是因为shell与用户进行交互。这种模式也是大多数用户非常熟悉的:登录、执行一些命令、签退。当你签退后,shell也终止了。 shell也可以运行在另外一种模式:非交互式模式。在这种模式下,shell不与你进行交互,而是读取存放在文件中的命令,并且执行它们。当它读到文件的结尾,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的差异

从上面的英文描述可以知道,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中的变量,他们是"父子"关系。

看完了这篇文章,相信你对“linux中bashrc与profile有什么区别”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. bashrc与profile的相关知识
  2. unix与linux有什么区别

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux bashrc profile

上一篇:Linux中无线网卡如何配置无线唤醒

下一篇:如何通过双主DRBD配置KVM双节点高可用群集

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》