Linux common commands and use of VIM

Source: Internet
Author: User
Tags virtual environment

First, Linux common commands
-Has learned
CD (Path switching) RM (after-RF can delete files or folders) ls (view files and folders under current path) mkdir (Create folder) Touch (create file)
Cat (view file contents) MV (move or rename files) rmdir (delete empty folder) WhoAmI (view current user) PWD (view current path)
-/# root directory Linux system has no drive letter, only root directory/.
-CD # Directory jump
-CP # Copy file CP < current folder under File > < destination folder >/< filename >
# Copy Folder Cp-rf < Folders > < destination folder >
-Find # Lookup file Find/(path)-name ' *.py '
Find/(PATH)-size 1024 (+1024 greater than 1024;-1024 less than 1024)
sudo find ... # sudo get permissions

Second, the use of vim

-Three different modes
-Command mode Yellow-green
-Enter I in insert mode command mode, turn blue. Press ESC to exit insert mode and back to command mode
-Input in the last-line mode command mode:

-Access
-Vim < file name > # Enter or create file, all files can be opened with vim

-Exit
In the last line mode:
-Q Force Quit
-Wq Save and exit the input code, WQ save exit will go to the check interface, check whether the code conforms to the PEP8 specification, then: Q Exit directly.
-q! Do not save exit

-Move Cursor
Command mode:
-direction Key: H left J down K on L right keypad arrow keys can also
Command mode:
-GG back to the beginning
-G back to the end of the line
-^ non-whitespace header
-0 beginning of the line
-$ line End

-Input mode (insert)
Command mode:
-I insert at the beginning of the current non-space line before the cursor position;
-A begins at the beginning of the cursor position, a at the end of the current line, or as input
-O Add a row below the cursor line and enter the mode;

-Copy and paste
Command mode:
-yy copy entire line content 3yy copy 3 lines of content yw copy the current cursor to the end of the word 3yw copy 3 words
-Paste P

-Delete and Revoke
Command mode:
-DD Delete Row 6DD Delete 6 lines (below the cursor) DW Delete A word x Delete the location of the cursor
-U undo Ctrl+r anti-undo

-Block operation
Command mode:
-V Block Select Ctrl + v. Column selection (move cursor selection area after entering command)
-Multiline Comment Command mode: Ctrl + V Select the line you want to annotate, Shift+i # and then press ESC

-Search
Command mode:
-/Content forward search content (down)
-Content Backward Search content (UP)
-N Search down
-N Search up

-Replace
In the last line mode:
-: S/s1/s2 replaces the first S1 of the current line as S2
-: S/s1/s2/g replaces all S1 in the current line as S2
-:%s/s1/s2/g replaces all S1 in the text as S2


Third, the operation of the py file
-Python3 < file name >
-Quick Run Command mode F5

Iv. use of Python virtual environments
-View the current virtual environment Workon
-Enter virtual environment Workon < virtual environment name >
-Exit the virtual environment deactivate
-Create a virtual environment mkvirtualenv <myvir>
-Delete Virtual Environment rmvirtualenv <myvir>

Linux common commands and use of VIM

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.