Do 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:
/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
~/.profile, the settings of these three documents are basically the same, and reading has priority
3 Afterwards, read ~/.bashrc
according to the user accountAs 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Flatpak application permission management tool: Flatseal User Guide Flatpak is a tool designed to simplify Linux software distribution and use. It safely encapsulates applications in a virtual sandbox, allowing users to run applications without root permissions without affecting system security. Because Flatpak applications are located in this sandbox environment, they must request permissions to access other parts of the operating system, hardware devices (such as Bluetooth, network, etc.) and sockets (such as pulseaudio, ssh-auth, cups, etc.). This guide will guide you on how to easily configure Flatpak with Flatseal on Linux

Linux Kernel is the core component of a GNU/Linux operating system. Developed by Linus Torvalds in 1991, it is a free, open-source, monolithic, modular, and multitasking Unix-like kernel. In Linux, it is possible to install multiple kernels on a sing

This brief guide explains how to type Indian Rupee symbol in Linux operating systems. The other day, I wanted to type "Indian Rupee Symbol (₹)" in a word document. My keyboard has a rupee symbol on it, but I don't know how to type it. After

Linux is best used as server management, embedded systems and desktop environments. 1) In server management, Linux is used to host websites, databases, and applications, providing stability and reliability. 2) In embedded systems, Linux is widely used in smart home and automotive electronic systems because of its flexibility and stability. 3) In the desktop environment, Linux provides rich applications and efficient performance.

Experience the satisfying click of a vintage IBM Model M keyboard, even without owning one! This tutorial shows you how to enable the authentic sound of a bucklespring keyboard on your Linux system using the Bucklespring utility. Table of Contents -

Linus Torvalds has released Linux Kernel 6.14 Release Candidate 6 (RC6), reporting no significant issues and keeping the release on track. The most notable change in this update addresses an AMD microcode signing issue, while the rest of the updates

If you're familiar with AirDrop, you know it's a popular feature developed by Apple Inc. that enables seamless file transfer between supported Macintosh computers and iOS devices using Wi-Fi and Bluetooth. However, if you're using Linux and missing o

The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.
