environment variable configuration file for Shell programming

Source: Internet
Author: User

First, Introduction
1. Variable type:
User-defined variables (local variables)
Environment variables: Define each user's operating environment, has learned path,ps1; to be permanent, write to the corresponding location
Pre-defined variables
Positional parameter variables
2.source command
[[email protected] ~]# Source configuration file or
[Email protected] ~]#. configuration file (dot. With space behind)
[[email protected] ~]#./current directory (no spaces here)
After you modify the configuration file, you must log off the login to take effect, or you can wait for the next logon again
But you can use the source command without having to log in again
[Email protected] ~]#. . BASHRC
. BASHRC is a hidden file
Equivalent:
[[email protected] ~]# source. BASHRC
3. Introduction to environment variable configuration file
Environment variables such as PATH, Histsize, PS1, hostname are written to the corresponding environment configuration file
The environment variable configuration file is primarily defined as system default environment variables that are in effect for the system operating system, such as path, etc.
Here are some of the environment variables that come into effect when you start:
/etc/profile
/etc/profile.d/*.sh
/etc/bashc
~/.bash_profile
~/.bashrc

Put in home directory only the current user is in effect, each login user placed in/etc will work

There are also environment variable folders that take effect when exiting

Second, the environment variable configuration file function
1. Environment variable Storage location effective order:
environment variable Storage location effective order
The above is the full login process in effect order, but we sometimes use sudo to adjust the login user, which is incomplete login, full login is the process of user login or logoff, rather than switch user process
The switch user starts from/ETC/BASHRC, and the full login starts from/etc/profile.
2. Detailed environment variable file location:
(1). The role of/etc/profile:
User variable:
LogName variables:
Mail variables:
Path variable:
Hostname variables:
Histsize variables:
Umask
Call/etc/profile.d/*.sh
[Email protected] ~]# Vim/etc/profile

(2). umask
Umask

View system Default Properties

Attention:
1) Maximum file permissions is 666
2) directory with maximum permissions of 777
3) permissions cannot be converted using numbers, but must use letters
[[email protected] ~]# Touch ABC
[R[email protected] ~]# umask
0022
[email protected] ~]# LL
Total Dosage 56
-rw-r-r-. 1 root root 4906 January 01:12 ABC
[Email protected] ~]#
rw-rw-rw---w–w-(remove duplicate permissions) =rw-r-r– The result and expected consistency, but the file is not executed at the beginning, and the directory has
4) umask defined permissions are the permissions that are ready to be discarded in the system default permissions
(3). Role of ~/.bash_profile
Called the ~/.BASHRC file
The directory ": $HOME/bin" is added after the path variable.
Note: Follow-up documents do not overwrite the
(4). The role of/ETC/BASHRC
PS1 variable
Umask
Path variable
Calling the/etc/profile.d/*.sh file

Third, other environment variable configuration file
(1). Environment variable profile in effect when logging off
~/.bash_logout
Add: If you enter a clear text user name and password in the command, it is recommended to clear the history command, this command can be put ~/.bash_logout, but under normal circumstances do not have to clear every time
(2). ~/.bash_history
[Email protected] ~]# Ls–a
...
123. bash_history# storage location, HDD

Note that the currently logged in command is in memory location, and only when the command is executed at exit is saved to the specified location, which is also used with the command history and vim. Bash_history View the command historical store file and find that the number of command bars is inconsistent

(3). Shell Login Information
1) Local terminal welcome information:/etc/issue
The supported escape characters
Local Terminal welcome information
[Email protected] ~]# vim/etc/issue
CentOS Release 6.3 (Final)
Kernel \ r on an \m
Recommended to add \l to the login interface, you can use ALT + F2 to switch the local terminal, the local terminal is generally 6, with ALT+F1 cut back
2) Remote Terminal welcome information:/etc/issue.net
Escape character cannot be used in the/etc/issue.net file
Whether to display the welcome message, which is determined by the SSH configuration file/etc/ssh/sshd_config, add "banner/etc/issue.net" line to display (remember to restart the SSH service)
[Email protected] ~]# vim/etc/issue.net
[Email protected] ~]# Vim/etc/ssh/sshd_config
Find #banner None, uncomment, and change to "banner/etc/issue.net"
Restart SSH service: [[email protected] ~]# service sshd restart
Stop sshd: [OK]
Starting sshd: [OK]
[Email protected] ~]#
3) Post-login welcome information:/ETC/MOTD
This welcome message can be displayed either locally or remotely, and is displayed after logging in

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

environment variable configuration file for Shell programming

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.