Environment variable configuration file for Shell programming,

Source: Internet
Author: User

Environment variable configuration file for Shell programming,

I. Introduction
1. Variable type:
User-Defined variables (local variables)
Environment variables: Define the operation environment for each user. The learned paths and ps1 are used. To take effect permanently, write the corresponding location.
Predefined Variables
Location Parameter Variable
2. source command
[Root @ localhost ~] # Source configuration file or
[Root @ localhost ~] #. Configuration file (point. There is a space behind it)
[Root @ localhost ~] #./Current Directory (no space here)
After the configuration file is modified, you must log out and log on again to take effect. Otherwise, you can only log on again later.
However, you do not need to log on again using the source command.
[Root @ localhost ~] # .. Bashrc
. Bashrc is a hidden file
Equivalent:
[Root @ localhost ~] # Source. bashrc
3. environment variable configuration file Introduction
PATH, HISTSIZE, PS1, HOSTNAME, and other environment variables are written into the corresponding environment configuration file.
The environment variable configuration file mainly defines the default system environment variables that take effect for the system operating system, such as PATH.
The following are some environment variables that take effect upon startup:
/Etc/profile
/Etc/profile. d/*. sh
/Etc/bashc
~ /. Bash_profile
~ /. Bashrc

In the home directory, only the current user takes effect. In the/etc directory, every logged-on user will take effect.

There are also some environment variable folders that take effect upon exit

Ii. Functions of environment variable configuration files
1. The order in which environment variables are stored is as follows:
Effective sequence of environment variable storage locations
The above shows the order in which the complete logon process takes effect, but we sometimes use sudo to adjust the logon user. This is an incomplete logon. The complete logon process is a user logon or logout process, rather than switching the user process.
The switching user starts from/etc/bashrc, and the full login starts from/etc/profile.
2. Detailed description of the Environment Variable file location:
(1)./etc/profile:
USER variable:
LOGNAME variable:
MAIL variable:
PATH variable:
HOSTNAME variable:
HISTSIZE variable:
Umask:
Call/etc/profile. d/*. sh
[Root @ localhost ~] # Vim/etc/profile

(2). umask
Umask

View Default System Properties

Note:
1) The file has a maximum permission of 666.
2) The Directory has a maximum permission of 777.
3) permissions cannot be converted using numbers, but must use letters
[Root @ localhost ~] # Touch abc
[Root @ localhost ~] # Umask
0022
[Root @ localhost ~] # Ll
Total usage 56
-Rw-r-. 1 root 4906 January 15 01:12 abc
[Root @ localhost ~] #
Rw--- w-(remove duplicate permissions) = rw-r-the calculation result is consistent with the expectation, but the file has no execution permission at the beginning, while the directory has
4) umask-defined permissions are the permissions to be discarded in the system's default permissions
(3 ).~ /. Role of bash_profile
Called ~ /. Bashrc File
Add the ": $ HOME/bin" directory to the PATH variable.
Note: Do not overwrite the subsequent files.
(4)./etc/bashrc Function
PS1 variable
Umask
PATH variable
Call the/etc/profile. d/*. sh File

3. Other environment variable configuration files
(1). environment variable configuration file that takes effect upon Cancellation
~ /. Bash_logout
Note: If you enter the plaintext user name and password in the command, we recommend that you clear the history command ~ /. Bash_logout, but normally you do not need to clear it every time
(2 ).~ /. Bash_history
[Root @ localhost ~] # Ls-
...
123. bash_history # storage location, Hard Disk

Note that the currently logged-on command is in the memory location. The command will be saved to the specified location only when it is exited, which also uses commands history and vim. bash_history

(3). Shell logon information
1) Welcome to the local terminal:/etc/issue
Supported escape characters
Local terminal welcome information
[Root @ localhost ~] # Vim/etc/issue
CentOS release 6.3 (Final)
Kernel \ r on an \ m
We recommend that you add \ l to the login interface. You can use Alt + F2 to switch to the local terminal. Generally, there are 6 local terminals, and Alt + F1 is used to switch back.
2) Remote Terminal welcome information:/etc/issue.net
Escape characters cannot be used in the/etc/issue.net file.
Whether to display the welcome information is determined by the ssh configuration file/etc/ssh/sshd_config. Add the "Banner/etc/issue.net" line to display the information (remember to restart the SSH service)
[Root @ localhost ~] # Vim/etc/issue.net
[Root @ localhost ~] # Vim/etc/ssh/sshd_config
Locate # Banner None, cancel the annotation, and change it to "Banner/etc/issue.net"
Restart the ssh service: [root @ localhost ~] # Service sshd restart
Stop sshd: [OK]
Starting sshd: [OK]
[Root @ localhost ~] #
3) welcome information after Logon:/etc/motd
This welcome message can be displayed for both local and remote logins.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.