Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between bashrc and profile in linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Xiaobian to share with you what is the difference between bashrc and profile in linux, I hope you have gained something after reading this article, let's discuss it together!

To understand the difference between a bashrc and a profile, first understand what an interactive shell is and what a non-interactive shell is, and what a login shell is and what a non-login shell is.

Interactive mode is when the shell waits for your input and executes the command you submit. This pattern is called interactive because the shell interacts with the user. This pattern is also familiar to most users: log in, execute some commands, and sign out. When you sign back, the shell terminates. The shell can also run in another mode: non-interactive mode. In this mode, the shell does not interact with you, but reads commands stored in files and executes them. When it reaches the end of the file, the shell terminates.

Startup profiles for individual users

User HOME Directory/.bashrc

head -1 ~/.bashrc# ~/.bashrc: executed by bash(1) for non-login shells.

User HOME Directory/.profile

head -1 ~/.profile# ~/.profile: executed by Bourne-compatible login shells.

Startup profile for all users

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), ...).

Differences between bashrc and profile

The difference between bashrc and profile is: 1. bashrc is automatically run after system startup. 2. Profile is not run until the user logs in. 3. After setting, you can update bashrc with the source bashrc command or update profile with the source profile command. PS: Usually we modify bashrc, some linux distributions do not necessarily have this file profile, the system used in this article is Ubuntu 15.104. The variables (global) set in/etc/profile can be applied to any user, while the variables (local) set in ~/.bashrc can only inherit the variables in/etc/profile, and they are "parent-child" relationships. After reading this article, I believe you have a certain understanding of "what is the difference between bashrc and profile in linux". If you want to know more about it, welcome to pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report