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 are the important files in Linux system

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

Share

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

What are the important files in the Linux system? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

1. Profile file

1.1 the role of profile files

Profile (/ etc/profile), used to set system-level environment variables and startup programs, under which the configuration will take effect for all users.

When the user logs in (login), the file is executed and the shell settings are found in the configuration file in the / etc/profile.d directory.

1.2 add environment variables to profile

It is generally not recommended to add environment variables to the / etc/profile file, because the settings added in this file will work for all users.

When we have to add it, we can add it as follows:

For example, add an environment variable with a host value of magedu.com:

Export HOST=magedu.com

When you add, you can use the; sign at the end of the line, or you can not use it.

A variable name can correspond to multiple variable values, which need to be separated by:.

After adding an environment variable, you need to log in again to take effect, or you can use the source command to force it to take effect immediately:

Source / etc/profile

To see if it works, you can use the echo command:

$echo $HOST

Magedu.com

2. Bashrc file

The bashrc file is used to configure functions or aliases. There are two levels of bashrc files:

System-level at / etc/bashrc and user-level at ~ / .bashrc, both of which will take effect for all users and current users, respectively.

The bashrc file will only work on the specified shell type, and bashrc will only be called by bash shell.

3. Bash_profile file

Bash_profile is only valid for a single user, and the file storage is located in ~ / .bash_profile, which is a user-level setting that can be understood as a user's profile directory.

This file can also be used to configure environment variables and start the program, but it is only valid for a single user.

Like profile files, bash_profile takes effect when a user logs in (login), and can also be used to set environment modification.

But unlike profile, bash_profile only works for the current user.

4. Difference summary

The difference between these three file types can be expressed in one sentence:

/ etc/profile,/etc/bashrc is the system global environment variable setting; ~ / .profile, ~ / .bashrc user home directory under the private environment variable setting.

When you log in to the system and get a shell process, the read environment profile is as follows:

4.1 first read the global environment variable profile / etc/profile, and then read additional settings documents such as / etc/profile.d and / etc/inputrc based on its contents

4.2 read ~ / .bash_profile in their home directory according to different user accounts.

If it fails to read, it will read ~ / .bash_login

If you fail again, read ~ / .profile (there is basically no difference in the settings of these three documents, only there is priority on reading)

4.3 * *, read ~ / .bashrc according to the user account.

Both ~ / .profile and ~ / .bashrc can be customized, but ~ / .profile can set user-specific paths, environment variables, etc., which can only be executed once when logging in.

~ / .bashrc is also a user-specific configuration document, which can set paths and command aliases, and will be used once for each execution of shell script.

The answers to the questions about the important documents in the Linux system are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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

Servers

Wechat

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

12
Report