Linux Basics--Bash

Source: Internet
Author: User
Tags aliases clear screen

First, what is the shell?

1. Shell: Shell

Gui:gnome, KDE, Xface

Cli:sh, CSH, ksh, bash, tcsh, zsh

2, prompt, command prompt

#:root Users

$: Normal User

3, child shell?

Output bash directly in the shell to enter its child shell, and the parent shell and child shell are not mutually


Second, bash features

(1) Command line editing

CTRL + A: command line cursor jumps to the beginning of the command

Ctrl+e: command line cursor jumps to the end of the command line

Ctrl+u: Delete the command line cursor to the beginning of the command

Ctrl+k: Delete the contents of the command line cursor to the end of the command line

Ctrl+l: Clear Screen

Ctrl+d: Delete the content at the current command line cursor

Ctrl+p: Show previous command (or up and down arrows)

(2) Strong references & weak references & command substitution

': Strong reference, do not complete variable substitution

Echo ' user shell is ${shell} ', output:User shell is ${shell}, variable substitution not completed

"": weak reference, can implement variable substitution (variable substitution: Replace variable name with variable value)

echo "User shell is ${shell}", Output: User shell Is/bin/bash, complete variable substitution

' |$ (): command substitution, nesting a subcommand in a command and replacing it with output results

echo "Work dir is $ (pwd)", Output: Work dir is/root

echo "Work dir is ' pwd '", Output: Workdir is/root

Touch file$ (date +-%y-%m-%d-%h-%m-%s). txt, the output is: file-2016-05-01-09-12-07.txt

(3) file wildcard character, globbing (man 7)

*: matches any character of any length

?: matches any single character

[]: matches any single character within the specified range, examples of commonly used ranges:

Capital letters: [A-z], [: Upper:]

lowercase letters: [A-z], [: Lower:]

Uppercase and lowercase letters: [a-za-z], [: Alpha:]

whitespace characters: [: space:]

Number:[0-9], [:d igit:]

Numbers and uppercase and lowercase letters: [0-9a-za-z], [: Alnum:]

Punctuation: [[:p UNCT:]]

[^]: matches any single character outside the specified range

(4) Command aliases

Definition alias: Alias cmdalias= ' COMMAND [options] [arguments] '

View Aliases: Alias

Alias: Unalias Cmdalias

Using the command itself: \command (when command aliases exist for this command)

Writes a command alias to a bash configuration file, permanently valid, or only in the current Shell's life cycle

(5) Command completion

Complement function key: TAB

Command completion: Search for PATH environment variable specified under each route

Path completion: Search from the start path


This article from "Tornado" blog, declined reprint!

Linux Basics--Bash

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.