Linux basic Commands (2)

Source: Internet
Author: User


1. Alias

Define or display aliases

eg

Alias date= ' Date ' +%f%T "'


    • When we enter date , in fact, it is equivalent to enter the date "+%f%T", simple and convenient;
      However, this alias is only valid in the current shell process, and once we exit and then log in, the alias will no longer take effect.

The workaround is to modify the file ~/.bashrc, write this alias command in the file, so that even if the device restarts, we can still use the alias date;

Use the nano text Editor to modify the file, and then sequentially execute CTRL + x--yes--carriage return;

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-0fb47d5c495c39ce.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

Attention:

This modification is the user's home directory files, only for the current user to take effect. If modifying the /ETC/BASHRC file is effective for all users of the global, it is not recommended to modify this file.


    • The Linux command is divided into internal commands and external commands, internal commands are stored in memory, and external commands are saved on disk. Therefore, the internal command has higher precedence than the external command. Who is the priority of alias with internal and external commands? Who's low? The following operations can be verified:

PWD is an internal command that looks at the current path

We do the following:

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-2668f7898754537e.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

When we perform the pwd , the result of hostname is displayed, stating that the alias takes effect before the internal command, and hostname is an external command

so priority order: aliases > Internal commands > External commands

    • Sometimes we just want to use the command itself and don't want to use aliases. Here are three ways to find out:

Take alias date= ' Date ' +%f%T ' as an example

              a, /bin/date

b, \date

C,' date '

    • Cancel Alias

unalias Date

2. Screen

command-line terminal switchover

    • SCR Een-s session Create a session

    • Screen-ls View current session information

    • Span style= "Color:rgb (0,176,240);" > screen-x session Join a session

    • screen-d session

    • Ctrl + A,d Peel session

    • screen-r session resume session

screen has a lot of parameters, and there are some problems with it, here I share with you my own understanding:

Use ScreenCreate a session
Screen-s Test
View ScreenSession
screen-ls attachedIndicates that it is connected
And then do the operation, if something goes on halfway,
HoldCtrl + A, and then press and holdDTo temporarily exit the session
Resuming a sessionscreen-r Test
If Detached indicates no connection, you can resume the session
If the attached indicates that the session has been occupied by a person, this can be done with Screen-d Testkick the current session user out and then resume the session yourself, orscreen-x TestJoin this session directly


Remote login to a server, you can use screen to create a session, even if the connection is interrupted, the session is still there, we log in again and resume the session can still continue the last operation

Example:

Create a session

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-ce05289919f9b2bb.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>


Temporary something, split session

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-2ad8513e6a75920a.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>


Resuming a session

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-4323949886a8f5cd.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>


After you create a screen session, perform a ping 127.0.0.1 operation, manually disconnect, and then log on to the screen session, you will notice that the ping command is still executing


3. Echo

Echo Information

echo {A.. Z} displays all letters A-Z

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-f86032880b41fc7c.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>


echo {0..20..2} displays 0-20 all digits with a step size of 2, arithmetic progression

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-9a8eb98334f5cc32.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

echo "host name is ' hostname '" command nesting command, inverted single quote ' '

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/6886239-3095000e2d751b6b.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>


Finally, let's share a couple of bash shortcut keys:

Ctrl + L Clear Screen

Ctrl + A beginning

Ctrl + E End of Line

Ctrl + U Delete from cursor to beginning of command

Ctrl + K Remove from cursor to end of command line

Ctrl + W Delete to the top of the word from the cursor to the left

Ctrl + D Delete a character at the cursor


Welcome to give guidance, thank you thank you!

This article is from the "A_pan" blog, make sure to keep this source http://panpangao.blog.51cto.com/10624093/1948622

Linux basic Commands (2)

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.