Linux Bash Shell detailed

Source: Internet
Author: User
Tags aliases

First, Bash shell overview

1. What is Bash
BASH is the abbreviation for the Bourne Again Shell, developed from the SH-unix system, and is a tool for users to interact with the Linux kernel, using the bash operation kernel to complete the system's use and management.

Types of 2.shell
/bin/sh (has been replaced by/bin/bash)
/bin/bash (the default shell)
/bin/ksh (from Bell Labs, bash-compatible)
/BIN/TCSH (Consolidated C shell, more powerful)
/BIN/CSH (has been replaced by TCSH)
/bin/zsh (from Ksh features more powerful)
Each shell has a similar function, but the syntax is slightly different.

The history and development of 3.bash

    

Ii. Overview of Bash shell variables

1. A variable is a symbol that represents some value.

2. You can set up a shell or other program by using a variable.

3. The variable exists in memory.

4.Linux has custom variables (local) and environment variables (environment).

5. Custom variables and environment variables are scoped differently.

6. You can use the following directives to view all variables

Set can see all the variables

Env can only view environment variables

Iii. how Bash Shell is set up

1. Customize variable settings

Variable=value to set

$variable to get the value of the variable

Variable names cannot start with numbers or special characters

If you want a space in the value to exist, you need to use double or single quotation marks to define the value, such as: key= "key is one"

The difference between single and double quotation marks is that double quotation marks support the existence of a variable as part of the value, such as: key= "key is $key 2"

unset key command to delete a variable

Common variables
Histfilesize: Record the maximum value saved by the historical instruction
Histsize: Records Use the history command to view the maximum number of historical specified outputs
COLUMNS: The width of the terminal window display
LINES: Height of terminal window display
PS1: Set the content style before the cue symbol (\d,\h,\t,\u,\w,\!,\$,\l,\ #等)

2. Set by Alias (Aliases)

Alias lss= ' Ls-la ' setting aliases

Use alias to view all the alias in the system

To view the specified alias definition using alias aliasname

Type-a alias name to view the specific definition description

Unalias deleting alias Definitions

3. Set via SET command

Set view all variable values of the system

Set property values inside the shell (set-o noclobber, Set-o VI)

4. Setting through environment variables

Custom variables can only be valid in the current shell environment.

Environment variables take effect in the shell environment under the entire host.

Use export variable name to set environment variables.

Introduction to Common variables
Home: The home directory that points to the current user.
LANG: What language the application uses to display the interface.
PWD: Points to the user's current working directory path.
PATH:
System-Preset environment variables.
Perform some instructions that do not specify a path when looking in the path.
Path= $PATH.: Setting the hidden path to path poses a security issue.
You can use the which directive to find where an instruction is located.

Iv. Overview of Shell startup scripts

1.Shell startup scripts is a user logon or other non-logon action that automatically executes some Shell scripts

2. Create a custom variable or execute a SET command to set the shell

3. Create environment variables and set up other programs

4. Use alias to simplify subsequent operations

5. Which programs are executed when logging out

V. Login and Non-login Shell's explanation

1.login Shell:
Run the shell through the full login process.
/etc/profile (path/user/hostname/histsize, etc.) will be read first.
Read/etc/profile.d/*.sh (color, language, instruction alias, etc.).
~/.bash_profile, ~/.bash_login, ~/.profile (read only one of them sequentially).
~/.BASH_RC,/ETC/BASHRC.
The source directive can load changes to the script, such as: Source/etc/profile.

2.non-login Shell:
A shell that does not require a login process to execute, such as a new bash action under Su and the original bash
~/.BASH_RC,/ETC/BASHRC
Read/etc/profile.d/*.sh
~/.bash_logout:
The script is made when the user is logged off
Tasks such as backup, cache, and temporary file cleanup can be performed

    

    

Linux Bash Shell detailed

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.