Cigarette Smoker---------Linux bash Basic features profile (4)

Source: Internet
Author: User
Tags terminates

Objective

During the bash process, the data in the bash process memory is read, and when the bash process terminates, the data in the process is recycled by the operating system, and the variable is also the data that is defined in the current shell process memory space. When the shell terminates, the variable is also invalidated


Role

Options: Define the working behavior of the command

Profiles can also define the behavior of the work, primarily storing the many options of the command, defining long-term effective behavior


Function

Make it easier for users to use bash


Classification of configuration files

Configurations that are in effect for all users:

/etc/profile,/etc/profile.d/

/etc/bashrc

Valid for current user

~/.bashrc

~/.bash_profile


Profile class, defining environment variables and scripts

BASHRC class: Defining local Variables and aliases


Login Switch : Read the target user's profile, initialize the environment

1) su-l User

2) Enter Password login

# echo $PATH/usr/local/apache/bin:/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/ bin# su-l testbash-sh-4.2$ Echo $PATH/usr/local/nginx/sbin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/ sbin-sh-4.2$

Read the configuration file in order: profile--PROFILE.D----~/.bash_profile---~/.BASHRC

$ nano/etc/profile.d/nginx.sh # #在profile The path of the Nginx binary text defined in D before $path export Path=/usr/local/nginx/sbin: $PATH $ vim ~/. Bash_profile # #在 ~/.bah_profile The path to the binary files defined in MySQL before ¥path path=/usr/local/mysql/bin: $PATH: $HOME/.local/bin: $HOME/bi N Export PATH If read first, show in the order of reading the configuration file before restarting the bash process $ echo $PATH/usr/local/mysql/bin:usr/local/nginx/sbin:

non-logon switchover : The target user's profile is not read

2) No need to enter the password login: Su user, the terminal under the graphical interface

2) When the script runs, run in the child shell of the current shell

# echo $PATH/usr/local/apache/bin:/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/ bin# su testbash$ echo $PATH/usr/local/apache/bin:/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ Usr/bin:/root/bin

Read configuration file Order: ~/.BASHRC-/ETC/BASHRC-PROFILE.D


Verify that the script runs as a child shell process for the current shell *********

environment variable takes effect on the child shell process of the current shell

[[Email protected] ~]# name= "Obama jerry"   # #有空格的字符引用, add quotation marks, otherwise the error will be [[email  protected] ~]# echo  $nameobama  jerry[[email protected] ~]# declare -x  name     # #申明为环境变量 [[Email protected] ~]# nano tr_d_dc_s_ i.sh #!/bin/bashecho  $name [[email protected] ~]# chmod +x tr_d_dc_s_i.sh   # #给予脚本执行权限  [[email protected] ~]# ls -l tr_d_dc_s_i.sh-rwxr-xr-x  1 root root 23 jun 10 14:48 tr_d_dc_s_i.sh[[email protected]  ~]# ./tr_d_dc_s_i.sh       # #变量生效obama  jerry[[email  protected] ~]# unset name              # #撤消变量 [[email protected] ~]# ./tr_d_dc_s_i.sh        # #变量为空 [[EMAIL PROTECTED]&Nbsp;~]# 


This article is from the "Reading" blog, make sure to keep this source http://sonlich.blog.51cto.com/12825953/1952878

Cigarette Smoker---------Linux bash Basic features profile (4)

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.