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

How to modify the Linux profile file

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to modify Linux profile file". In daily operation, I believe many people have doubts about how to modify Linux profile file. Xiaobian consulted all kinds of information and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how to modify Linux profile file"! Next, please follow the small series to learn together!

Linux is a multi-user operating system. After each user logs on to the system, there will be a dedicated operating environment. Usually the default environment is the same for every user, and this default environment is actually the definition of a set of environment variables. Users can customize their own operating environment by modifying the corresponding system environment variables.

Often modify environment variables in the/etc/profile file, where the modified content works for all users. The following main operations will be performed in this file.

How to add environment variables. For example, add "NAME=liheng". Add the following at the end of the profile file: export NAME=liheng

The variable value liheng can be quoted or not, the effect is the same.

4. Content added or modified in the profile file requires logging out of the system to take effect.

5. How to understand the repeated definition variables. A frequent occurrence is the definition of the PATH variable.

For example: in the peofile file default PATH variable has set PATH= ¥ ¥ ¥ ¥ ¥ ¥ ¥ (I can't remember), in the future may be set to PATH, generally added to the profile file PATH=····(for example). The PATH=······¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥, which means that environment variables with the same name, written later, take effect first (colloquially speaking). Everyone must pay attention.

6. Introduction to special characters. For example, in profile, there are the following contents, which explain the use of special symbols.

export A=/q/jing:aaa/cc/ldexport B=.:/ liheng/wang export A=/cd/cdr:$A

Note that the red symbol:: indicates the parallel meaning, for example, there are multiple A variable values, and the symbol: is used for separation. Indicates the current directory of your operation. For example, the pap command looks for the B environment variable.

Type the pap command at/home, and the system will first look for B in/home (i.e., the current path), if not in/liheng/wang. Indicates the value of the variable before this definition, for example A stands for/q/jing:aaa/cc/ld. That means A=/cd/cdr:/q/jing:aaa/cc/ld

Use env to display all environment variables. Just type env at the command prompt. The set command displays all locally defined Shell variables.

PATH, a common environment variable, determines which directories the shell will look for commands or programs.

HOME: Current user home directory

MAIL: refers to the mail storage directory of the current user.

SHELL: It refers to which Shell the current user is using.

HISTSIZE: refers to the number of historical command records saved.

LOGNAME: refers to the login name of the current user.

HOSTNAME: refers to the name of the host, many applications if you want to use the host name, usually from this environment variable.

LANG/LANGUGE: is a language-dependent environment variable that can be modified by multilingual users.

PS1: is the basic prompt,#for root and $for normal users.

PS2: is an adjunct prompt, default is ">." You can modify this environment variable to modify the current command character, such as the following command modifies the prompt to the string "Hello,My New Prompt???? "。

PS1=" Hello,My NewPrompt ???? "

9. Use the modify.bashrc file to edit environment variables, which is only useful for the current user. Editing environment variables using the modify/etc/profile file is useful for all users. Everyone must pay attention to the distinction.

The Linux profile file will be run at system startup. You can add other commands in it, but you must add them correctly, otherwise the system will not start.

At this point, the study of "how to modify Linux profile files" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

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