Linux Learning Note--bash command and Shell variable introduction

Source: Internet
Author: User
Tags aliases clear screen

Bash and its features

Shell Shell

Gui:gnome KDE Xface

Cli:shell CSH Ksh Bash

Program, Process

Process: Each process appears to have only kernel and current processes present on the current host

A process is a copy of a program, and a process is a program execution instance

User's working environment:

Bash:

# root User

$ normal User

Shell, child shell

Bash:

1. Command history

2. Piping, redirection

3. Command-line editing

4. Command aliases

5. Command line expansion

6. File name Wildcard

7. Variables

8. Programming

Tips for command exercise:

Ctrl + A cursor jumps to the top

Ctrl + e cursor jumps to the end of a career

CTRL + u delete the cursor to the beginning of the content

Ctrl + k Delete cursor to end of line content

Ctrl +l for Clear screen

Command history Usage Tips:

!n executing the nth line command in the command history

!-n execution of the penultimate line command in the history command

!! Executes the previous command

! CHARACTER the last command in the history command that starts with CHARACTER

!$ references the last parameter of the previous command

ESC Release Press. Reference the last parameter of the previous command


TAB key function:

Command completion: Searches for executable files at the beginning of each path specified by the PATH environment variable with the string we give

Path completion: Search for each file name under the starting path that we gave me, and try to complement the whole

Command aliases:

#alias cmdalias=comand Command Rename

Aliases defined in the shell are valid only in the current shell life cycle, the valid range of aliases the current shell process

#unalias Cancel Command Rename, #unalias COMAND

The quotes and functions that bash supports:

' anti-quotes, command substitution

"" Double quotes, weak references, you can complete the variable substitution

' Single quotes, strong references, non-complete variable substitution

Command substitution

The process of replacing a subcommand in a command with the result of a command execution

#echo "The directory is $ (PWD)"

#touch./file-$ (date +%f-%h-%m-%s). txt = = #touch./file-' date +%f-%h-%m-%s'. txt, same functionality


Command history:

#history

[[email protected] skel]# help historyhistory: history [-c] [-d  Offset]  [n]  or  history -anrw [filename]  or  history -ps  parameter  [parameter ...]      display or manipulate the history list.          Show History list with line numbers and prefix each modified entry with   ' * '.      parameters  N  lists only the last  N  entries.          Options:      -c          Delete all entries to clear the history list.       -d         offset   Delete History list from specified location.           -a         Append the history line of the current painting to the history file       -n         Read all unread rows from the history file       -r         Reads the history file and appends the contents to the History list    &NBsp;  -w         writes the current history to the history file   and appends to the history list 

Environment variables:

Path command paths

histsize Command History size

Example: # echo $HISTSIZE, showing the size of the cache command

#echo $shell to display the user shell environment

File name wildcard, globbing

* matches any character of any length, including an empty #ls *

? Match any single character, #ls? y*

[] matches any single character within the specified range, such as [A-za-z][0-9][0-9a-za-z]

[[: Space:]] all whitespace characters

[[:p UNCT:]] all punctuation

[[: Lower:]] all lowercase characters

[[: Upper:]] all uppercase characters

[[: Alpha:]] all uppercase and lowercase letters

[[:d Igit:]] All numbers

[[: Alnum:]] numbers and uppercase and lowercase

[^] matches any single character outside the specified range

Example #ls[[:alpha:]]*[[:space:]]*[[:alpha:]], displaying a file that starts with a letter and ends with a letter and contains spaces in the middle

The type of shell that stands in terms of user login

Log-in Shell

Log in normally via a terminal

Su-username

Su-l USERNAME

Non-sign-on shell

Su USERNAME

Command window open under graphical terminal

Shell scripts that are executed automatically

Bash's configuration file

Global configuration

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

Personal configuration

~/.bash_profile, ~/.BASHRC

File for Profile class

Setting Global environment variables

Sign in to run a command or script

Files for bash classes

Setting Local Variables

Defining command aliases


How the login shell reads the configuration file

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

Non-sign-on shell

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


This article is from the "Wish_" blog, be sure to keep this source http://itwish.blog.51cto.com/11439802/1963152

Linux Learning Note--bash command and Shell variable introduction

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.