03, what is the shell, some of the most basic commands and tips.

Source: Internet
Author: User

What is a shell:

The shell is a human-computer interface, so that humans can control computers, usually have a graphical interface and text interface of two

Graphical interface: Gui:graphic User Interface:

Windows

IOS, Android

X-window

Gnome

Kde

Xfce

Text interface: Cli:command line Interface:

PowerShell

Ds.

Csh

Tcsh

Ksh

Bash

Zsh

Linux Terminal:

Serial Terminal: (The terminal of the plain text interface, cannot display the graphical interface)

/dev/ttys#

Physical Terminal:

/dev/console

Virtual Terminal: Ctrl+alt+f[1-6]

Graphics Terminal: Ctrl+alt+f7

/dev/tty#

The STARTX command launches the graphics terminal, StartX & indicates the start of the graphics terminal and lets the process run in the background, freeing the command prompt

Pseudo terminal (analog terminal): Remote connection, graphical environment Open command interface

/dev/pts/#


# TTY Command: Displays the current terminal device file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/D3/wKiom1RF8RXi-fPKAAA_3_3luoc182.jpg "style=" float: none; "title=" Tty1.png "alt=" Wkiom1rf8rxi-fpkaaa_3_3luoc182.jpg "/>

This is a TTY command executed in virtual Terminal 1.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/D4/wKioL1RF8WHjSYQIAABE_oOp-dY232.jpg "style=" float: none; "title=" Tty2.png "alt=" Wkiol1rf8whjsyqiaabe_oop-dy232.jpg "/>

This is a TTY command executed in the Xshell remote terminal.

# who command: View all users logged on on the current system and their information

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D4/wKioL1RF8sCQXruzAAB8HrvrwG4258.jpg "title=" Who8.png "alt=" Wkiol1rf8scqxruzaab8hrvrwg4258.jpg "/>

Now my system has a total of two users, they are all logged in with root, but the device is not the same login.

Linux Philosophy thought:

1, all documents;

Open, read, write, close

2, by a number of purposes of a single application: A program to do only one thing, and do well;

3, the combination of single-purpose small procedures to complete complex tasks;

4, try to avoid interaction with users;

5, the use of text files to save configuration information;

6, provide the mechanism, but not the strategy;

Bash Simple introduction:

Administrator's command prompt: # 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D3/wKiom1RF9LjDzDfHAAARWeSyQu4214.jpg "Ti Tle= "#.png" alt= "Wkiom1rf9ljdzdfhaaarwesyqu4214.jpg"/>

Command prompt for ordinary users: $650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/4C/D3/wKiom1RF9MnhYmi0AAAS9AFdPrM003.jpg " Title= "$.png" alt= "Wkiom1rf9mnhymi0aaas9afdprm003.jpg"/>

The prompt is preceded by a line of characters that can be modified by modifying the environment variable

Environment variable: PS1

echo $PS 1 #显示环境变量PS1

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D4/wKiom1RF9X3zIOWqAAA1JnwEEjk461.jpg "title=" Ps1.png "alt=" Wkiom1rf9x3ziowqaaa1jnweejk461.jpg "/>

Visible [\[email protected]\h \w]\$, where the "\u" is the user name, "\h" is the hostname, "\w" is the user's current directory

Now the directory is displayed "~", this is the user's home directory shorthand


To modify the PS1 environment variable:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D4/wKiom1RF-Fixje1-AAAjODFwhiM929.jpg "title=" Ps111111111111111111111.png "alt=" Wkiom1rf-fixje1-aaajodfwhim929.jpg "/>

Here I changed the "@" between "\u" and "\h" to "%" and then look at the command prompt.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D4/wKiom1RF-MyyZeoSAAA6cLUWicY644.jpg "title=" 2222222222222222222111.png "alt=" Wkiom1rf-myyzeosaaa6cluwicy644.jpg "/>

It's been changed.

------------------------------------------

Linux paths:

/: This is called root, and all files in Linux are in the root directory.

. : Current directory

.. : Parent Directory

Absolute path: Is the path starting with the root

Relative path: A path starting at the current directory, such as "./a", which represents a file in the current directory

-------------------------------------------

CD path: Switch directories, directly enter the CD command, you can switch to the home directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D4/wKiom1RF-uLRw_4iAABAZf8vfyw135.jpg "title=" Cd8.png "alt=" Wkiom1rf-ulrw_4iaabazf8vfyw135.jpg "/>

Switch from home directory to/etc directory, switch to home directory from/etc directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D4/wKiom1RF-1XRX2AAAABXVh9jvSg017.jpg "title=" CD 555555555555555555557.png "alt=" Wkiom1rf-1xrx2aaaabxvh9jvsg017.jpg "/>

CD-: Can be implemented to switch to the first access to the directory, a bit like a TV remote in the back, where "-" indicates the last visited directory

--------------------------------------------

Features of the Linux file system:

1, the file name can use any character except/, but the total length must not exceed 255;

2. Strictly case-sensitive

--------------------------------------------

Linux commands:


There are two types of commands in bash, namely internal and external commands

Internal command: Bash comes with commands and is the most basic command

External command: Later you install the commands for some software.


To view the command type:

Which command to see the path of the command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/D4/wKiom1RF_P3Ct3qdAADUNqEmr44747.jpg "title=" Which.png "alt=" Wkiom1rf_p3ct3qdaadunqemr44747.jpg "/>

Type to view the types of commands

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D8/wKiom1RGKBfz0ExOAACCvHZ_gk8547.jpg "title=" Type.png "alt=" Wkiom1rgkbfz0exoaaccvhz_gk8547.jpg "/>

As can be seen here, LS is an external command, and the CD is an internal command, because the installation path cannot find the CD installation files, there are a lot of file paths, these file paths are also an environment variable, called path

Environment variables: PATH

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D4/wKiom1RF_b6CcVc-AACGwOFw2J0971.jpg "title=" Path.png "alt=" Wkiom1rf_b6ccvc-aacgwofw2j0971.jpg "/>

This environment variable is used to hold the path of the command, with ":" As a delimiter, the command is usually stored in these directories, the command will be executed in accordance with the order of the directory to traverse, until the command is found and executed, but there is a Problem. , traversal command is a very slow operation, so need a mechanism that can quickly find the command, this mechanism is called hash, look at the hash.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D6/wKioL1RF_v-zfWg1AACmehSg26w824.jpg "title=" Hash.png "alt=" Wkiol1rf_v-zfwg1aacmehsg26w824.jpg "/>

This is my hash table, the table is stored in my usual command path, the number in front of the table indicates the number of executions of this command,

To formally say the order,

Command format:

Command Options arguments

Command option Parameters

Options: Adjust the execution characteristics of a command

Options can be multiple, and multiple options must be separated by a space

Short option:-char

Long option:--word

Short options can be combined; Long options cannot be combined;

Some options require a parameter

Parameters: The Action object of the command

Some commands can take multiple parameters, and each parameter needs to be separated by a space


Get help:

Built-in commands:

# Help Command name

For example, Help CD

External command: There are two forms of getting help

# command--help

Use the command manual:

Man Handbook:

man [1-8] command name

The meaning of the option format character in the manual:

[]: Optional section

{a|b}: grouping, A and B as a unit of use, only one can be selected between A and a

| : Or, select only one

<>: Required option

... : Similar content can appear at multiple

Brief operation of Man

Flip Screen:

SPACEBAR: Turn down one screen

B: Turn up one screen

Enter: Turn down one line

K: Turn up one line

Ctrl+d: Flip Down half screen

Ctrl+u: Flip up half screen

Text Search:

/keyword: Search Down

? Keyword: Search up

N: Next

N: Previous

The segmentation mechanism of the man command: divided into 8 segments, each paragraph represents a content, the same command in different sections of the content displayed differently, such as passwd in the first paragraph shows the passwd Command manual, and in the fifth paragraph shows the passwd configuration file use Help, man If you do not add a paragraph, the first help manual that he finds will be displayed by default.

1: User command

2: System call

3: library Call

4: Device files

5: Configuration file format

6: Game

7: Miscellaneous

8: Management Commands


View keywords can be used in those paragraphs

# Whatis Keyword 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/4C/D5/wKiom1RGDKGSflnNAACQxXuyQzk090.jpg "Title=" Whatis.png "alt=" Wkiom1rgdkgsflnnaacqxxuyqzk090.jpg "/>

Visible passwd in 1, 5, 1ssl three segments

# man-k Keyword

This is a fuzzy search, the place where the Keyword have appeared more than the list.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D5/wKiom1RGDZGDx2qkAANkeBAOOyY168.jpg "title=" Mank5.png "alt=" Wkiom1rgdzgdx2qkaankebaooyy168.jpg "/>


Here again, the internal command manual with Help to check, external command with man to check.

-----------------------------------------------------------

Info command:

This is the online Help document, as long as the internet can be used, the operation is similar to man.

-----------------------------------------------------------

There are redhat official documents, but in English ....

Www.redhat.com/docs

And our big Google ~:

Google is very powerful and has a lot of skills to use. I won't say it here.

Simple Management class Commands:

shutdown [option] ... Time

-R: Restart

-H: Turn off the machine:

-C: Cancel restart command

Time Format:

Now: Direct shutdown

+#: #分钟后关机

HH:MM: Fixed time shutdown

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D7/wKioL1RGEKLQ8_m2AAC2xpUI-hk228.jpg "title=" Shutdown.png "alt=" Wkiol1rgeklq8_m2aac2xpui-hk228.jpg "/>

---------------------------------------------------

Reboot: Restart, this is usually used

Sync;sync;reboot, the sync here is to manually save data in memory before it is saved to the hard drive.

---------------------------------------------------

Halt [-P]: shutdown now

-P: After shutdown and power off.

---------------------------------------------------

Poweroff: With halt, almost no difference.

Date: Display time

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D6/wKiom1RGEj2Ck7AoAAA6LsJhYkE557.jpg "title=" Date.png "alt=" Wkiom1rgej2ck7aoaaa6lsjhyke557.jpg "/>

You can also customize the format in which the time is displayed.

%Y: four-bit year

%y: Two-bit year

%m: Month

%d: Day

%H: When

%M: Min

%s: Seconds

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D6/wKiom1RGE4-TKl8JAAA7Bu_aSI0111.jpg "title=" Date2.png "alt=" Wkiom1rge4-tkl8jaaa7bu_asi0111.jpg "/>

UNIX: 1970-01-01-00:00:00

%s: The number of seconds from the beginning of the Unix period to the present can solve the time difference problem.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4C/D7/wKioL1RGE-_yg3wgAAArRdh1000148.jpg "title=" Date3.png "alt=" Wkiol1rge-_yg3wgaaarrdh1000148.jpg "/>

-----------------------------------------------------------------------------------

Cal: Show Calendar

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D6/wKiom1RGFB_iaEDjAACK1iaIHk4221.jpg "title=" Cal1.png "alt=" Wkiom1rgfb_iaedjaack1iaihk4221.jpg "/>

---------------------------------------------------------------------

Two types of clocks for Linux:

Hardware clock: Computer hardware comes with a clock

Software Clock: The system automatically reads the hardware clock when it is powered on, and then calculates the time itself.

Date shows the time of the software clock


Hwclock [-SW]: Hardware clock time

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/D7/wKioL1RGFUKgAfG7AABJgE3d9yE655.jpg "title=" Hwclock.png "alt=" Wkiol1rgfukgafg7aabjge3d9ye655.jpg "/>

There are two options:

-S: Synchronize the system clock with the hardware clock

-W: Synchronize the hardware clock, whichever is the system clock.

------------------------------------------------------------------------

DirName: Displays prefixes other than file names for the specified path

basename: Displays the suffix of the specified path,

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/D7/wKioL1RGFtXQyu--AACwcR-xQrI711.jpg "title=" Dir4.png "alt=" Wkiol1rgftxqyu--aacwcr-xqri711.jpg "/>


Shell Common tips:(here to summarize some of what I know, will continue to organize in the future). )

CTRL + C: Cancel command, when command is executing, you can force cancel this command

Shift+pgup and SHIFT+PGDN: These two are the page-flipping commands of bash,

ESC +.: Gets the arguments for the last command, equivalent to!$

This article is from the "Serenity Indifferent" blog, please make sure to keep this source http://vrgfff.blog.51cto.com/6682480/1566362

03, what is the shell, some of the most basic commands and tips.

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.