Bash Small Summary

Source: Internet
Author: User

Bash's configuration file,

Divide by Range:

Global configuration:

/etc/profile,

/etc/profile.d/*.sh

/etc/bashrc

Personal configuration:

~/.bash_profile

~/.bashrc

by function:

Profile class: Provides configuration for the interactive logon shell

/etc/profile,

/etc/profile.d/*.sh

~/.bash_profile

1, define environment variables, such as Path

2. Run the command or script

BASHRC class: Shell provides configuration for non-interactive logon

/etc/bashrc

~/.bashrc

1, used to provide command aliases

2, defining local variables

Variable: variable name is pointer, point to variable

Type:

Environment variables: The current shell and its child processes

Export Name=value

Declare–x Name=value

Local variables: Current process only

Name = value

Local variables: A snippet of code in the current shell process

Position variable: $1,$2

Special variables: $?

How to define:

Bash built-in variables, without definition, can be called directly. PATH

Custom variables:

Assignment method: Variable name = value

Self-increment: name= "$name dddddd"

Weak type!!! Save as character type by default

Pstree can query the process tree

View environment variables

Env

Printenv

Export

Undo Variable

unset name

Reference variable

$name ${name}

Reference symbol

' Strong reference, variable substitution does not occur

"" Weak reference

"Command reference, the execution result of the reference command

Shell Logon Type:

Interactive: Direct Terminal su-username

Non-interactive: graphical interface su username

Order of action at logon

Interactive:/etc/profile->/etc/profile.d/*.sh-> ~/.bash_profile

The following overrides the previous

Non-interactive:~/.bashrc–>/etc/bashrc–>/etc/profile.d/*.sh

How the new configuration takes effect:

1, re-login

2, reread the configuration file

Source/path/to? Somefile

. /path/to? Somefile

After the experiment, correct:

1. How do I define an alias that is valid for the user you are using?

/ETC/BASHRC I guess it's here to change,

2. What to do if only the modification of the PATH environment variable takes effect for the root user

~/.BASHRC Modify the root of this file

Bash Small Summary

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.