Marco Linux Learning Notes (bash variable configuration)

Source: Internet
Author: User

Bash : Interpreter, compiler

configuration file, the scope of effective, there are two categories:

Global configuration:

/etc/profile,/etc/profile.d/*.sh

/etc/bashrc

Personal configuration:

~/.bash_profile

~/.bashrc

By function, there are two categories:

Profile classes: For interactive logins Shell Provide configuration

/etc/profile,/etc/profile.d/*.sh

~/.bash_profile

Function:

(1) Define environment variables, such as PATH,PS1

(2) Run a command or script

BASHRC class: For non-interactive logins Shell Provide configuration

/etc/bashrc

~/.bashrc

Function:

(1) define command aliases;

(2) define local variables;

Variables: Memory space, variable name

Type:

Environment variables: scope Current Shell process and its child processes

Local Variables: scope current Shell Process

Local Variables: The scope is only the current Shell a piece of code in the process ( typically a function context )


How variables are defined:

Bash built-in variables: can be called directly, built in a number of environment variables, such as PATH wait

Custom variables:

variable Assignment: variable name = value

Bash Weak type:

When a variable stores data, it is written by default, and any variable can be directly referenced without being declared;

- : 24bits

120:8bits

To define a local variable:

Name=value

View: Set

Define Environment variables:

Export Name=value

Declare-x Name=value

View: env, printenv, export

Undo Variable:

unset name

Reference variable:

${name}, $name

Bash the reference symbol in:

"': strong references, variable substitution does not occur

"" : Weak references

``: Command Reference

Shell Login Type:

Interactive login:

Login directly through the terminal;

through su-l Username User Switching of the command implementation;

Non-interactive logon:

A command-line window opens under the graphical interface;

Execute the script;

Su Username;

Configuration file Action Order:

Interactive login:

/etc/profile-->/etc/profile.d/*.sh---~/.bash_profile, ~/.BASHRC--/ETC/BASHRC

Non-interactive logon:

~/.BASHRC-->/ETC/BASHRC--/etc/profile.d/*.sh

How does the new configuration of the Edit profile definition take effect?

(1) re- login;

(2) let the current Shell process to re-read the specified configuration file;

Source/path/to/somefile

. /path/to/somefile

Note: Side effects


Marco Linux Learning Notes (bash variable configuration)

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.