search
HomeSystem TutorialLINUXDo you know the difference between interactive shell and profile?

Reprinted from:/u010127245/article/details/51689636

The difference between bashrc and profile

The difference between bashrc and profile, we must first understand which are interactive shells and non-interactive shells, and which are login shells and non-login shells.

Interactive mode means that the shell waits for your input, but executes the commands you submit. These modes are called interactive because the shell interacts with the user. These modes are also familiar to most users: logging in, executing some commands, and logging out. When you sign back, the shell also terminates.

The shell can also run in another mode: non-interactive mode. In these modes, the shell does not interact with Android Linux, but reads commands stored in files, but executes them. When it reaches the end of the file, the shell terminates.

Bashrc and profile are both used to save the user's environment information, bashrc is used for interactive non-login shellLinux installation cross-compilation environment variables, and profile is used for interactive login shell. There are many bashrc and profile files in the system. They are introduced one by one below:

/etc/pro This file sets environment information for each user of the system. When the first user logs in, this file is executed.

And collect shell settings from the configuration file in the /etc/profile.d directory.

/etc/bashrc: Execute this file for each user running bashshell. When bashshell is opened, this file is read. There is no bashrc file in the /etc directory in some Linux versions.

~/.pro Each user can use this file to enter shell information specifically for their own use. When the user logs in, the

The file is only executed once! By default, it sets some environment variables and then executes the user's .bashrc file.

~/.bashrc: This file contains bash information specific to a user's bash shell. This file is read when the user logs in and every time a new shell is opened.

In addition, the variables (global) set in /etc/profile can affect any user, while the variables (local) set in ~/.bashrc, etc. can only inherit the variables in /etc/profile. They It's a "brother and sister" relationship.

Summarize:

交叉编译环境变量如何设置_交叉编译环境搭建步骤_linux安装交叉编译环境变量

/etc/profile, /etc/bashrc is the system global environment variable setting

~/.profile, ~/.bashrc private environment variable settings in the user’s home directory

When a shell process is obtained when logging into the system, there are three steps to read the environment configuration file

1 The first thing to read is the global environment variable configuration file /etc/profile, and then read additional setting documents according to its content, such as

/etc/profile.d and /etc/inputrc

2 Afterwards, according to different user accounts, go to their home directory to read ~/.bash_profile. If this cannot be read, read ~/.bash_login. If this cannot be read, then read it

linux安装交叉编译环境变量_交叉编译环境搭建步骤_交叉编译环境变量如何设置

~/.profile, the settings of these three documents are basically the same, and reading has priority

3 Afterwards, read ~/.bashrc

according to the user account

As for the difference between ~/.profile and ~/.bashrc

All have personalized customization functions

~/.profile can set the user's own path to install win7 on the Linux system, environment variables, etc. It can only be executed once when logging in

~/.bashrc is also a user-specific setting document. You can set the path and command alias. It will be used once every time shellscript is executed.

[Three ways to configure environment variables]

If you want to add a path to $PATH, you can do the following:

1. Console North does not agree with the use of these techniques. Because if you change the shellLinux installation cross-compilation environment variables, your settings will be invalid, so these methods are only for temporary use and will be used later. You have to reset it again, which is quite troublesome. This is only for a specific shell;

$PATH="$PATH:/my_new_path" (turn off the shell and PATH will be restored)

2.

Change the /etc/profile file. If your computer is only used for development, it is recommended to use these techniques. Since all user shells have the right to use this environment variable, it may bring security issues to the system. (JDK configuration recommended)

This is for all users and all shells;

$vi/etc/profile add:

exportPATH="$PATH:/my_new_path"

3.

Change the .bashrc file. These techniques are safer. It can control the permission to use this environment variable to the user level. This is for a specific user. If you need to give a user permission to use this environment Variables, you only need to change the .bashrc file in the home directory for personal use.

$vi/root/.bashrcAdd above:

exportPATH="$PATH:/my_new_path"

The latter two methods usually require logging out of the system again to take effect (you can directly use $source~/.profile refresh to prevent restarting). Finally, you can test it through the echo command:

$echo$PATH output is already the new path.

The above is the detailed content of Do you know the difference between interactive shell and profile?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:ITcool. If there is any infringement, please contact admin@php.cn delete
Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is Linux actually good for?What is Linux actually good for?Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Essential Tools and Frameworks for Mastering Ethical Hacking on LinuxEssential Tools and Frameworks for Mastering Ethical Hacking on LinuxApr 11, 2025 am 09:11 AM

Introduction: Securing the Digital Frontier with Linux-Based Ethical Hacking In our increasingly interconnected world, cybersecurity is paramount. Ethical hacking and penetration testing are vital for proactively identifying and mitigating vulnerabi

How to learn Linux basics?How to learn Linux basics?Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

What is the most use of Linux?What is the most use of Linux?Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

What are the disadvantages of Linux?What are the disadvantages of Linux?Apr 08, 2025 am 12:01 AM

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),