Linux Command Learning Notes

Source: Internet
Author: User

Linux Command Learning Notes

1. file renaming

The command MV for renaming files or folders under Linux can be renamed, and files or folders can be moved.

Example: Renaming directory A to B

MV A B

Example: Move the/a directory to/b and rename to C

mv/a/b/c

In fact, in the text mode to rename the file or directory is also very simple, we only need to use the MV command, for example, we want to rename a file named ABC to 1234 can be written like this: MV ABC 1234, but note that If there is a 1234 file in the current directory, our file will be overwritten.

2. compile and run a C language file

Like writing a hello.c file with VI.

Compile and build the Hello file: gcc–o Hello hello.c

Run the hello file:./hello

3. vi copy-paste command

The VI editor has 3 modes: Command mode, input mode, and last line mode. It is important to master these three models:

Command mode: VI starts after the default entry is the command mode, from this mode to use the command can switch to the other two modes, and no matter in any mode just click the [ESC] key can return to the command mode. Enter the subtitle "I" in the command mode to edit the file into the input mode of VI.

Input mode: In this mode we can edit, modify, input and other editing work, in the last line of the editor to display a "--insert--" Mark VI entered the input mode. We need to save the file when we have finished modifying the input, then we need to return to the command mode and save it in the last line mode.

Last-line mode: Enter ":" in the command mode to enter the mode, there are many good commands in the last line mode.

 

Operation of input mode

Home cursor to beginning of line

End cursor to end of line

Page UP and PAGE Down

Delect Delete the character of the cursor position

Delete operation (Command mode use)

x Delete a single character at the cursor

DD deletes the cursor in the row

DW deletes all characters from the current character to the end of the word including spaces

#x例如3x删除光标处向右的三个字符

#dd例如3dd从当前行开始向下删除三行文本

Undo Action

U command cancels the last operation and can be used multiple times to restore the original operation

U Cancel all operations

Ctrl+r can revert to operations that use the U command

Copy operation

YY command copies the contents of the current entire line to the VI buffer

YW Copy the contents of the current cursor to the end of the word to the vi buffer, the equivalent of copying a word

y$ copy cursor position to end of line content to buffer area

y^ copy cursor position to the beginning of the content to the buffer area

#yy例如: 5yy is copying 5 rows

#yw例如: 2yw is a copy of two words

P Paste the contents of the buffer

If you want to copy the contents of line m to nth row, you can enter M,ny in the last line mode for example: 3,5y copy the third line to the fifth row of contents to the buffer.

Open the second file in the same edit window with: SP [filename]

Switch between multiple edit files, using CTRL+WW

Linux Command Learning Notes

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.