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

#放在家home目录下只有当前用户生效, every logged-on user 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:

650) this.width=650; "title=" Environment variable storage location effective order "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt = "Environment variable storage location effective order" src= "http://s3.51cto.com/wyfs02/M01/71/15/wKiom1XEf4viMzjcAAB77ruHGps927.jpg" width= "603" height= "/>"

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

#查看系统默认属性

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

[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--evaluates and is expected to be consistent, but the file does not have permission to execute at first, 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

#注意当前登陆的命令在内存位置, the command will be saved to the specified location only when the command is exited, and this is also done with the commands 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

650) this.width=650; "title=" Local terminal welcome Information "Style=" Border-top:0px;border-right:0px;background-image:none;border-bottom : 0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" Local terminal welcome Information "src="/HTTP/ S3.51cto.com/wyfs02/m02/71/15/wkiom1xef5oratpqaace6d55hvi001.jpg "height="/>

[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, but is displayed after logging in

This article is from the "8626774" blog, please be sure to keep this source http://8636774.blog.51cto.com/8626774/1682756

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.