Linux Study Notes 2-linux basic commands and Study Notes 2-linux

Source: Internet
Author: User

Linux Study Notes 2-linux basic commands and Study Notes 2-linux

 

First blog: linux Study Notes 1-ubuntu installation and basic settings, has introduced how to install the linux operating system and some basic settings and modifications.

This blog introduces some basic Console Commands in linux.

 

========================================================== ======

Connect to a remote machine

The command to log in with the specified user name is: ssh username@XXX.XXX.XXX.XXX (typically the user name needs to be specified)

The command to log in with the specified user name and the specified port is: ssh username@XXX.XXX.XXX.XXX-p XXX

The disconnection command is: exit

========================================================== ======

View hidden files

The command for displaying all files (including hidden files) is ls-.
The command to show only hidden files is: ls-d .*

========================================================== ======

Vi command Overview

[Access the vi command]

Vi filename open or create a file and place the cursor at the beginning of the first line

Vi + n filename open the file and place the cursor at the beginning of line n

Vi + filename open the file and place the cursor at the beginning of the last line

Vi +/pattern filename open the file and place the cursor at the first string matching pattern

A system crash occurred when vi-r filename was being edited with vi last time.

Vi filename1 filename2 filename3... Open multiple files and edit them one by one

[Move the cursor command]

H move the cursor one character to the left

L move the cursor one character to the right

Space cursor shifts one character to the right

Move the Backspace cursor one character left

K or Ctrl + p move the cursor up a row

J or Ctrl + n move the cursor down a row

Enter move the cursor down a row

W or W move one word to the beginning of the word

B or B move one word left to the beginning of the word

E or E move one word to the end of the cursor

) Move the cursor to the end of the sentence

(Move the cursor to the beginning of the sentence.

} Move the cursor to the beginning of the paragraph

{Move the cursor to the end of the paragraph

NG cursor moves to the beginning of line n

N + move the cursor down n rows

N-move n rows above the cursor

N $ move the cursor to the end of line n

H move the cursor to the top line of the screen

M: move the cursor to the middle line of the screen

L: move the cursor to the last line of the screen

0: (Note the number is zero) move the cursor to the beginning of the current row

$: Move the cursor to the end of the current row

[Screen tumble command]

Ctrl + u: half screen at the beginning of the file

Ctrl + d: Flip the half screen to the end of the file

Ctrl + f: Flip the screen to the end of the file

Ctrl + B; open a screen at the beginning of the file

Nz: Rolls row n to the top of the screen. If n is not specified, the current row is rolled to the top of the screen.

Insert a text command]

I: Before the cursor

I: at the beginning of the current row

A: After the cursor

A: At the end of the current row

O: open a new row under the current row

O: open a new row above the current row.

R: Replace the current character

R: Replace the current and subsequent characters until you Press ESC.

S: Starting from the current cursor position, replace the specified number of characters with the input text

S: delete a specified number of rows and replace them with the input text

Ncw or nCW: modify a specified number of characters

NCC: modifies a specified number of rows.

DELETE command]

Ndw or ndW: n-1 characters starting at and following the cursor

Do: Delete to the beginning of a row

D $: Delete to the end of the row

Ndd: Delete the current row and the next n-1 row

X or X: delete a character. x deletes the character after the cursor, and X deletes the character before the cursor.

Ctrl + u: delete text entered in input mode

[Search and replace command]

/Pattern: Search for pattern from the beginning of the cursor to the end of the file

? Pattern: Search for pattern from the beginning of the cursor

N: Repeat the previous search command in the same direction.

N: Repeat the previous search command in the reverse direction.

: S/p1/p2/g: replace all p1 in the current row with p2.

: N1, n2s/p1/p2/g: replace all p1 from line n1 to line n2 with p2.

: G/p1/s // p2/g: replace all p1 files with p2.

[Option settings]

All: lists all options.

Term: Set the terminal type

Ignorance: Case Insensitive in search

List: displays the stop table (Ctrl + I) and end mark ($)

Number: displays the row number.

Report: displays the number of changes made by line-oriented commands.

Terse: displays brief warning information

Warn: NO write information is displayed if the current file is not saved when it is transferred to another file.

Nomagic: allows you to use special characters without "\" in search mode.

Nowrapscan: Prohibit vi from searching at both ends of the file and starting from the other end.

Mesg: Allows vi to display the information that other users write to their terminal using write.

[Line command]

: N1, n2 co n3: copy the content from line n1 to line n2 to line n3.

: N1, n2 m n3: Move the content from line n1 to line n2 to line n3

: N1, n2 d: Delete content from line n1 to line n2

: W: Save the current file

: E filename: open the file filename and edit it.

: X: Save the current file and exit.

: Q: Exit vi.

: Q! : Do not save the file and exit vi

:! Command: execute shell command

: N1, n2 w! Command: The content from line n1 to line n2 in the file is used as the command input and executed. If n1 and n2 are not specified, the entire file content is used as the command input.

: R! Command: place the output result of the command to the current line.

Register operation]

"? Nyy: Save the content of the current row and Its n rows to the register? , Where? It is a letter, and n is a number.

"? Nyw: Save the current row and Its n characters to the register? , Where? It is a letter, and n is a number.

"? Nyl: Save the current row and Its n characters to the register? , Where? It is a letter, and n is a number.

"? P: retrieve the register? And place it at the cursor position. Here? It can be a letter or a number.

Ndd: delete n lines of text from the current row and its bottom, and put the deleted content in the delete Register No. 1.

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.