Linux Learning Essay Nine

Source: Internet
Author: User

Knowledge of the main shell basics

Standing at the user's angle: Shell type

Logon Shell: Normal is usually a certain terminal sign-in

Su-username

Su-l USERNAME

Non-sign-on shell

Su Usernmae

Open Command Window under graphics terminal

Shell scripts that are executed automatically

Configuration file for Kash:

Global configuration:/etc/profile/etc/profile.d/*.sh

/etc/bashrc

Personal configuration: ~/.bash_profile, ~/.BASHRC

Function:

File for Profile class

Setting environment variables

Run a command or script


Files of the BASHRC class

Setting environment variables

Defining command aliases


Login Shell If you read the configuration file:

/etc/profile-->/ETC/PROFILE.D/*.SH-->~/.BASH_PROFILE-->/.BASHRC-->/ETC/BASHRC

Non-logon Shell if the configuration file:

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

We all know that the computer includes a controller (instruction), an arithmetic, a memory

Bus includes: Address bus (memory addressing), data bus (transmit data), Control Bus (Control command)

Register: CPU Ephemeral memory

I/O devices: hard drives, etc. input

Input device

Output device:

System settings: Default output device, standard output stdout,1

Default input device: standard input stoin,0

Standard error Output: stderp,2

I/O redirection:

>: Overwrite Output

>>: Append output

Example: LS var >>/tmp/var.out

Set-c prohibit overwrite redirection for already existing files, forcing overwrite redirection

Set +c turn off the above functions

Standard output and error output are not the same data stream

2>: Redirect Error output

2>>: Append method

such as: Ls/var >/tmp/var3.out 2>/tmp/err.out

Ls/var >/tmp/var4.out 2>/tmp/var4.out

&>: Redirect standard output or error output to the same file

&>>

<: Input redirection

<<:here Document

Eof:end of File =end

Cat >>/tmp/myfile.txt<<eof generating files in scripts


Pipeline: The output of the previous command as input to the latter command

Command 1| Command 2| command 3| ....

Example: echo "Hello World" |tr ' A-Z ' A-Z '

echo "Redhat" |passwd--stdin Hive

cut-d:-f3/etc/passwd |sort-n

Tee: Save and display

echo "Hello,world" |tee/tmp/hello.out

Wc-l/etc/passwd |cut-d '-f1

Ls-l/usr/bin/head-1

Cut-d:-f1/etc/passwd/sort-n

Head-6/etc/inittab |tail-1

Tail-9/etc/passwd |head-1|cut-d:-f1,7|tee/tmp/users

Ls-d/etc/pa*|wc-l

echo "Alias Cls=clear" >>~/.BASHRC


Need for File lookup: grep, Egrep, Fgrep

grep: Search for text according to pattern, and conform to pattern text display

Pattern: (pattern) text Word wildcards regular the expression's meta-character combination to match the condition

I: Ignore case

V: Show rows that are not matched by pattern

--color Display Color

-O: Displays only strings that are matched by the pattern

Alias grep= ' grep--color ' take aliases

Grep-o ' Root '/etc/passswd

Regular expression: Regular,expression,regexp

Metacharacters

. :

* :

.* :

\?:

\{m,n\}: Matches the preceding character at least m times, up to N times

\{1,\}, match its preceding characters at least 1 times, at most 0650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/> Times

\{0,3\}: Match its preceding characters at least 0 times, up to 3 times

grep ' a \{1,3\}b ' text.txt

Location anchoring:

^: Anchor the beginning of the line, any content after this character must appear at the beginning of the line

grep ' ^r. Root '/etc/passwd

$: Anchor line end, any content of this character money must appear at the end of the row

^$: whitespace character

[]: matches any character in the specified range

[^]: matches any character outside the specified range

[:d Igit:] [: Lower:] [: Upper:] [:p UNCT:] [: Space:] [: Alpha:] [: Alnum:]

grep ' [[:d igit:]]$ '/etc/inittab

\< or \b: Anchor word, any character following it must appear as the first word

\> \b: Anchors the ending, any character preceding it must appear as the tail of the word

Group:

\(\)

\ (ab\) *:ab can occur 0 or more times

\1: Refers to the first opening parenthesis and all the contents of the corresponding closing parenthesis

\2: \ 3:

Regular Expressions: Includes the basic regular expression (REGEXP) extended Regular expression (EXTENDED REGEXP)

Basic Regular Expressions:

. :

[ ]:

[^ ]:

Number of matches:

*:

\?:

\{m,n\}:

.*:

Anchoring:

^:

$:

\< \b:

\> \b:

\(\):

\1,\2,\3 ...

grep: Filtering text commands using patterns defined by basic regular expressions

I

-V:

-O:

--color:

-E: Using extended regular expressions

-a#: Displays matching rows and rows following this line

-b#: Display matching rows and lines preceding this line

-c#: Displays matching rows and rows before and after this line

Grep-a 2 ' ^core ID '/proc/cpuinfo


To extend the regular expression:

Character Matching:

. [] [^] Same as basic expression

Number of matches:

* ?

+: Match its first character at least once

{M,n}

Location anchoring:

^ $ \< \>

Group:

(): Group

\1,\2,\3 ...

Or

|:or

such as: C|cat: Is it cat or cat or C or cat?

Grep-e ' c| Cat ' Test6.txt

Gerp--color-e ' C|cat ' test6.txt

grep--color-e ' (c|c) at ' Test6.txt

grep--color-e ' ^[[:space:]]+ '/boot/grub/grub.conf

Grep-e=egrep (supports extended regular expressions using commands)

If a number from 1 to 255 is displayed

Egrep--color ' \< ([1-9][1-9][0-9]|[ 0-9]2[0-4][0-9]25[0-5]>\> '/boot/grub/grub.conf

Show IP Address:

Ifconfig |egrep-o ' above. \>.\

\>1. | {3}

IP Address:

Class 5: A B C D E

a:1-127

b:128-191

c:192-223

This article is from the "Rotten Pen" blog, please make sure to keep this source http://lanbitou.blog.51cto.com/9921494/1709999

Linux Learning Essay Nine

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.