Bash's environment variable configuration file

Source: Internet
Author: User

Date: August 30, 2015


Bash 's configuration file

Bash's configuration file is used to configure Bash's usage environment and save many predefined variables in the system.

The most common environment variables for bash are:

Path: Command Search Path

Histfile: Where to save the command history

SHELL: Used by the current user

Home: Current user's home directory


Types of variables:

Local variable: Valid only for the current shell process, not for its child shell and other shells;

Defining variables: [set]var_name= "Value"

Reference variable: ${var_name}

Undo Variable: Unset var_name


Local variables: Only valid for local code

Local var_name= "Value"


Environment variables: Valid for Shell processes and their child shells;

Export Var_name= "Value"


Positional variables:

$ $, ..., $n

./first.sh 2 8


Special variables:

$: script name itself

$?: The execution status of the previous command;

The state is represented by numbers: 0-255;

0: Success

1-255: Failure (1, 2, 127 is reserved by the system)

$$

$!

$#

$*


Naming Requirements for variables:

Only numbers, letters and underscores are used;

Cannot begin with a number;

Cannot use keywords in the program;

Totalweight of the name and righteousness;



To view the variables on the system:

Set: Displays all variables on the current bash

Show all environment variables: export, env, printenv



The environment configuration file is divided into two categories:

Profile class: Provides configuration for interactively logged-on users

/etc/profile: Global

/ETC/PROFILE.D/*.SH: Global

~/.bash_profile: Personal configuration, valid only for the current user

Function:

Setting environment variables

Run a command or script


BASHRC class: Non-interactive login user provides configuration

/ETC/BASHRC: Global

~/.BASHRC: Personal Configuration

Function:

Setting Local Variables

Defining command aliases



SHELL type of:

Interactive Login Shell:

Enter user information directly through the terminal login system

Su-username

Su-l USERNAME

non-interactive login Shell:

Su USERNAME

Open Command Window under graphics terminal

Shell scripts that are executed automatically

Interactive login shell, config file and order:

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

Non-interactive login shell, config file and order:

~/.bashrc-->/ETC/BASRC--/etc/profile.d/*.sh

How the new configuration will take effect:

1 , re-login

2 , tell the shell to reread the configuration file commands:

Source (.)

. FILE

Instance:

// append the path under the PAHT variable

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/7E/wKiom1XkmSnSJtm5AAC_oLnVEaM078.jpg "title=" 1.png " alt= "Wkiom1xkmsnsjtm5aac_olnveam078.jpg"/>



Bash's environment variable configuration file

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.