Configuration files for Linux system and user environment variables

Source: Internet
Author: User

There are many system variables in the Linux system, so where do these variables exist? Why do users automatically have these variables when they log on to the shell? Several configuration files are described below.

1,/etc/profile: This file presets a few important variables, such as path, USER, LOGNAME, MAIL, INPUTRC, HOSTNAME, Histsize, Umask, and so on. You can edit the file to add variables to this file, but this is not recommended. If you need to change a variable or add a variable we can create a new script in the/etc/profile.d/directory, such as changing the variable path, adding a/tmp/: First vim/etc/profile.d/path.sh Create the script file, edit the content:

#! /bin/bash

Export path= $PATH:/tmp/

Save to Run command after exit: Source/etc/profile refresh the configuration.

2,/ETC/BASHRC: This file is mainly preset umask and PS1. This PS1 is what we prefix when we enter a command, such as

"[[Email protected] ~]#" is PS1. Let's take a look at the value of PS1:

# echo $PS 1

[\[email protected]\h \w]\$

Wherein, \u refers to the user, \h refers to the host name, \w refers to the current directory, \$ refers to the character "#" (if it is a normal user is displayed as "$") we can change this variable to change the prefix.

In addition to the two system-level profiles above, there are several hidden files under each user's home directory.

. bash_profile: This file defines the user's personalization path and the file name of the environment variable. Each user can use the file to enter their own shell information, which is executed only once when the user logs on. Note: the. Bash_profile will call. BASHRC, and if we define the same variables in these two files, the variables executed will overwrite the first executed variables.

. BASHRC: This file contains bash information specifically for your own shell, which is read when you log in or open a new shell every time. For example, we can write user-defined alias or custom variables to this file.

. bash_history: This file is used to record command history.

. bash_logout: When you exit the shell, the file is executed. We can write some cleanup commands to this file.


This article is from the Linux OPS blog, so be sure to keep this source http://zhumy.blog.51cto.com/11647651/1789297

Configuration files for Linux system and user environment variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.