Linux Learning Note 2.0

Source: Internet
Author: User
Tags control characters diff lowercase printable characters stdin expression engine line editor egrep

Command
">" | >> file Standard input redirect (overwrite); (append)
2> | 2>> file standard error redirection (overwrite); (append)
File < standard input redirection
&> File = = >file 2>&1 all standard output redirection
TR Convert and delete characters
Tee [-A] file1 stdin to file1 and output (append)
cmd1 | CMD2 | Cmd3 ... Pipe (multiple)
Additional
Mail-s "title" User e-mail
Mail receive email
Seq-s + 1 |BC from 1 to 100
OpenSSL rand-base64 10 randomly generates 10-bit strings
Chsh-s/bin/csh User Modified user shell type into CSH
CHFN Modifying user descriptions
Chown Modify Owner
CHGRP Modifying the owning group
SCP file name IP path cross-server replication
Reset resets characters
Last Display user logon information
Netstat Network connection view
&>/dev/null does not display output, $? display results
NAMP-V-SP IP Address scan IP address network segment address up or DOWN7

Additional:
"", "," the difference between the anti-primer

"": A variable that can be identified
": does not recognize the contents of
Reverse: Can identify any of the contents (for referencing the command line)

Standard inputs and outputs
Program: Instruction + data
Read-in data: Input
Outputs data: Output
Open files have a Fd:file descriptor (file descriptor)
Linux provides three I/O devices to Programs
Standard input (STDIN)-0 accepts input from the keyboard by default
Standard output (STDOUT)-1 Default output to terminal window
Standard error (STDERR)-2 default output to terminal window
I/O redirection: Changing the default location

redirect output and errors to a file
StdOut and stderr can be redirected to a file
Command: Action symbol + file name
' > ' redirect stdout to file
2> redirect stderr to file
&> |2>&1 Redirect all output to file
' > ' Action file contents will be overwritten
' >> ' based on the original content, additional content
(;) Merging stdout of multiple programs
Import stdin from a file
< REDIRECT standard input
Cat > Filea < Fileb
Single-line redirection: Enter end once
Multiline redirect:<< Terminator

TR command
converting and deleting characters
tr [OPTINO]...SET1 [Set2] Set1 converted to Set2
-D removes a set from a string
-C takes a complement to a string
-S compress consecutive characters
-T converts the character of the first character set to the corresponding character in the second character set

Piping: Pipe
cmd1 | CMD2 | Cmd3 | ...
CMD1 's stdout as stdout cmd3 as CMD2 's stdin,cmd2 stdin
stdout stderr |& cmd = = (equivalent to) stdout stderr 2>&1 | Cmd
StdOut and stderr together as stdout as CMD-labeled use
Less: View input page by page
Ls-l/etc | Less
Mail: Send input by e-mail
echo "Test Email" | Mail-s "Test" [email protected]
LPR: Send input to Printer
echo "Test print" | Lpr-p Printer_name
In Pipe-symbols
Packaging the files inside/home, but the packaged data is not recorded to the file, but sent to the stdout, after the pipeline, the TAR-CVF-home to the back of the TAR-XVF-, the latter-is to take the previous command of the stdout, so there is no need to make Use temporary file.
TAR-CVF-Home | TAR-XVF-

Tee command
Save command execution results to file and output
cmd1 | Tee [-A] file name | CMD2 cmd1 stdout into the file and output, as CMD2 stdin use (-a append does not overwrite)
Standard input:
Cat TR Mail BC (Advanced Arithmetic Command calculator), etc.

Users, groups, and permissions
Safety 3A
Authentication: Certification
Authorization: Authorization
Accouting| Audition: Audit

Users user
Token tokens (uid,gid,groups), identity
File (authorization Uid,read read R write writes W Excute execute x)
Access to resources according to the information carried in token to the corresponding authorization
Linux Users: Username/uid
Administrator: root/0
Normal Users: 1-65535
System User: 1-499,1-999 (CENTOS7)
Login User: 500+,1000+ (CENTOS7)
Interactive Login

Group
Linux Group: Groupname/gid
Administrators group: root/0
System Group: 1-499,1-999 (CENTOS7)
Normal group: 500+,1000+ (CENTOS7)
Categories of Linux Groups
User's primary group (primary group)
The user must belong to one and only one primary group
The group name is the same as the user name and contains only one user, the private group
Additional groups for users (supplementary group)
A user can belong to 0 or more, secondary groups

Security context
Context (user identity running this program, user group identity)
Run as the initiator of the process (Proces):
Root:/bin/cat
User:/bin/cat
The permissions that a process can access resources depend on the identity of the process's runner

Profiles for users and groups
/ETC/PASSWD: User and its attribute information (NAME, UID, primary group ID, etc.)
Seven fields:
User name: Password: uid:gid: Description: Home directory path: Shell type
/etc/shadow: User passwords and their associated properties (passwords are generally encrypted with sha512)
User: Password: Password modification time: Minimum password validity: Maximum password validity: Advance notice: Grace period: Account validity: Reserved field
/etc/group: Group and its attribute information
Group name: Password: GID: Team members (users with the current group as additional groups)
/etc/gshadow: group password and its related properties
Group Name: Password: Team leader: Members (users with the current group as additional groups)
Report:
1, etc under most of the configuration file (text file), can be modified but strict format
2. Create an account for the service shell type with Nologin
3. feild domain column field properties; Record Row Records
4. Files related to creating users and groups:
/etc/passwd
/etc/shadow
/etc/login.defs
/etc/default/useradd
/etc/skel/*
/etc/group
/etc/gshadow

File operations
VIPW = = NANO/ETC/PASSWD (Vi==nano)
VIGR = = Nano/etc/group
Pwck | GRPCK Checking user | Group file format

User Management Commands
User created:
useradd [Options] name creation User (AddUser-useradd)
-U Create user-specified UID
-O with-u option, no UID uniqueness checked
-G create user to specified group
-C Create a user and describe
-D create user to specified home directory
-S create user-specified shell type (available list:/etc/shells)
-R Create System user (ID:1-499CENTOS6;1-999CENTOS7)
-G Create user to specify additional group ...
-N Create user-specified primary group users
-M create home directory for system users
-M does not create a home directory for non-system users
-D Show default settings
NewUsers Batch creation of users
CHPASSWD Bulk modification of user passwords
User Property Modification:
usermod [option] name modify user properties
-U New UID
-G New GID
-G new additional group, overwrite the original group,-a append new group
-s new default shell
-C New User description
-D new home directory not created automatically,-m create new home directory and move home directory data
-L New User name
-L plus Lock
-U unlock
-e Set Account expiration date
-F Set Inactivity period
To delete a user:
Userdel [option] name Delete user (if a user is in use, the user cannot delete)
-R Delete user and home directories and mailboxes
To view the user ID information:
ID [option] name displays user information (determines whether the user exists)
-U display UID
-G display GID
-G Displays the owning group ID
-N Display user name, with U,g,g
Getent Passwd|group|shadow|gshadow
View these files, followed by U|g, to view only the u|g in the file
To switch users:
SU (switch User) Subscriber switch users (not fully switched)
Su-user Switching User (full switch)
Root switches to other users without a password, a password is required for non-root user Switching
Set Password:
passwd [option] name modifies the specified user password
-D Delete the specified user password
-L lock specified user
-U unlocks the specified user
-E force user to change password at next logon
-F Force Action
-n Specifies the shortest period of use
-X Maximum lifespan
-W Advance warning days
-I inactivity Period
Ehco ' passwd ' |passwd--stdin name receives user password from standard input
To modify a user password policy:
chage [option] name Interactive modify user password time parameter
-D Modify Deadline
-E Modify Expiration time
-I modify inactivity period
-M Modify minimum period
-M Modify maximum age
-W Modify advance warning days
-L Display Password policy
Other user-related commands:
CHFN Modify Personal Information
Chsh Modifying the Shell
Finger viewing user Information

Group Management Commands
To create a group:
groupadd [option] name create Group
-G indicates GID
-R Create System group (GID:1-499CENTOS6;1-999CENTOS7)
To modify a group:
groupmod [option] Name
-N Modify new name
-G Modify New GID
To delete a group:
Groupdel Delete a group (if a group is a user's primary group, the group cannot be deleted)
Change the group password:
gpasswd [option] name interactively adds a password (password) to the group
-a user adds user to the specified group
-D user removes the user from the specified group
-A user1,user2, ... Set up a list of users with administrative rights
NEWGRP temporarily switch the primary group (password required if the user is not in this group)
Change and view group members:
groupmems [option] [action] Displays the specified group member
Options
-G changes to the specified group
Action
-A specify user join group
-D Remove the user from the group
-P clears all members from the group
-L Display Group members list
Groups [option]. [Username] ... View the list of groups to which the user belongs

File permissions
File Properties Operations:
Modify the owner of a file
Chown
Usage:
Owner
Owner:group
: Group
":" Available "." Replace
-R recursion
chown [option] ...--reference=file1 file2 Modify file2 owner is the same as File1
Modify the owning group of a file
Chgrp
Usage:
chgrp [option] ... group file ... file belongs to group
chgrp [option] ...--reference=file1 file2 ... file2 and file belong to a group
-R recursion

Introduction to file Permissions
File permissions are primarily defined for three types of objects:
Owner: Owners (U)
Group: Affiliated groups (g)
Other: Others (O)
Each file has three permissions defined for each type of visitor:
Readable: Read permission (r)
Writable: Write Permission (W)
Excutable: Execute permissions (x)
File:
R: Use the File View class tool to get its contents
W: can modify its contents
X: You can put this file into the kernel to boot into a process
Directory:
R: You can use LS to view this directory file list
W: You can create files in this directory or delete files
X: You can use Ls-l to view this directory file list and CD access to this directory
x: Give directory x permission only, do not give file X permission
Rules:
1, ordinary users cannot change the file owner, you can change to belong to the group (the file owner is himself, and himself in the group)
2, directory dir is a special file, the content is a list of files
Deleting a file requires the W permission for the directory where the file is located
3, to the directory, there is no X, even if there is r, can not enter the directory, unable to view the directory properties, unable to access the directory file
4. The root is not controlled by R W, and the X is controlled; R W X is controlled by the normal user.
Binary R permissions are not required
5, the user gets the permission order: U-g-o, once matches, does not carry down
6. File attributes are determined by the file system, not by the operating system

Modify file Permissions
chmod (change mod)
-R Recursive modification
To modify all permissions for a class of users:
u= g= o= a=
To modify a permission for a class of users:
u+/-g+/-o+/-a+/-
chmod [Option]...--reference=file1 file2 ... Modifying file2 permissions is the same as File1

Methods 1:mode Method
chmod who opt per file
Who:u g o A (all)
opt:+-=
Per:r W x x (only the directory plus x, if the file already has X, also the file plus x)
Method 2: Digital method (octal authorization)
Rwx ...---
111 ... 000
R:4
W:2
X:1
Rwx ...---
7 ... 0

Modify the default permission method
Default permissions (file:644;dir:755)
Umask+default (default) =file666/dir777 (add to bits)
Directory 777-umask, File 666-umask
Umask true Meaning: mask
Function: Cancel the corresponding permission
Cases:
666
125
110110110
001010101 (every 1 cancel permission, 1->0)
110100010
642
The directory formula does not change, the file even the odd number plus one

Special permissions
Suid (4) (U+s)
Inherited program Owner permissions, only suitable for binary executable programs
Sgid (2) (G+s)
1) inherited program belongs to group permissions
2) Acting on the directory, the directory under which the new file inherits the directory belongs to the group
Sticky (1) (o+t)
Sticky bit, action in folder, this directory file can only be deleted by the owner

Setting file-specific properties
Chattr +i cannot be deleted, renamed, changed
Chattr +a can only append content (Echo content >>file, Nano is not available)
Lsattr Display Specific Properties

access Control List
Acl:access control List
enables flexible rights management
with the exception of the owner of the file, the group and others, you can set permissions on more users
ACL Effective Order: Owner, custom user, custom group, others
Setfacl-m u/g:name:rwx file/diretory Set File/directory permissions for user/group
-X Delete user/group file/directory permissions
Setfacl -M mask::rwx file/diretory set the file/directory Mask permission
Setfacl-b file/diretory Clear all ACL permissions
-rm recursive settings-M file.acl Batch setup (reference File.acl file)
-x file.acl Bulk Delete
Getfacl-r/tmp/dir1 > Acl.txt backup ACL
Setfacl-r--set-file=acl.txt/tmp/ Dir1
Setfacl--restore acl.txt restore ACL
The Mask permission
is equivalent to the function of the limit bar, which is the mask value on the maximum permissions
ACL file except the owner (custom user, custom group, Have the maximum permissions for the group, rather than the traditional group permissions

Text Processing Tools
File View
Command:
Cat View Text File
-e display line terminator $
-a displays all the control characters
-N numbering each displayed line
-B non-blank line number
-S compression continuous blank line into a row
TAC Anti-write cat (bottom-up)
Rev Writeback (right-to-left)
View the contents of a file on a page
Command:
More Paging View files
-D Display page flipping and exit hints
Less page-by-page view file or stdin output
/Text Search text
N jumps to the next match
N jumps to the previous match
Less command is a pager used by the man command
Show text before or after content
Command
Head Display file header (default top 10 lines)
-C # Specifies get before # bytes
-N # Specifies the first # line to get
-# the specified number of rows
Tail display end of file (default after 10 lines)
-c# Specifies the # bytes after fetching
-n# Specifies the # line after fetching
-# the specified number of rows
-F Displays new additions to the file, often used for log monitoring
-F Trace File name
Tailf similar to tail-f, but does not access files when files are not growing

Extracting and merging text
Command:
Cut out some files (columns)
-D indicates delimiter, default tab
-f# # fields (#可多个, continuous)
-C cut by character
Paste merge two files row number column to one line
-D Specify delimiter, default tab
-S all rows are composited on one line display

Parsing text
Collect text statistics:
WC display file line, Word, byte, character number
-L count of rows only
-W counts only the total number of words
-c counts only bytes total
-m count number characters total
-L Displays the length of the longest line in the file
Text sort:
Sort text sorting display (sort by column)
-R performs reverse direction (top to bottom) finishing
-R Random Sort
-N Sorting by number size
-F ignores the case of characters in a string
-U delete duplicate rows in output
-T C uses C as the field's delimiter
-K 3 Sort by 3rd column
To delete duplicate rows:
Uniq Delete duplicate rows
-C shows the number of repetitions per line
-D show only rows that have been repeated
-U displays only rows that have not been duplicated
Note: continuous and identical are duplicates
Compare files
diff compare files, command output is saved in a file called "Patch"
-U Output "unified" diff format file, best for patch files
Patch replication changes in other files (use caution)
-B automatically backs up changed files

The Three Musketeers of Linux text Processing
grep: Text Filter tool (pattern: pattern)
Print a specific line
Three variants: Grep,egrep (supports extended regular expressions), Fgrep (regular expression search not supported)
Sed:stream Editor, text editing tools
Implementation Gawk on Awk:linux, Text Report Generator

Grep
Function: Text Search tool to match the target text line by row according to user-specified "mode"
To print the matching lines.
Patterns: Filter conditions written by regular expression characters and text characters
grep prints rows to match
--color=auto: Coloring the text to match to a display
-V shows lines that are not matched by pattern
-I ignore character case
-n Displays matching line numbers
-C Statistics Match line count
-O Show only the matching string
-Q silent mode, does not output any information
-A # Multiple display after # line (after)
-B # Multi-display front # line (before)
-C # Multiple display before and after each # line (context)
-E to implement logical or relationships between multiple options
-W matches the entire word (the alphanumeric underline is part of the word)
-F Reference File content matching
-e use Ere, use extended mode
-F is equivalent to fgrep and does not support regular expressions

Regular expressions
REGEXP: A pattern written by a class of special characters and text characters, in which some characters (metacharacters) do not represent literal meanings, but are functions that represent control or a wildcard
Program Support:
Grep,sed,awk,vim,less,nginx,varnish, etc.
Divided into two categories:
Basic Regular Expressions: BRE
Extended Regular expression: ERE (Grep-e,egrep)
Regular expression engine:
Using different algorithms to check the software module for processing regular expressions
PCRE (Perl Compatible Regular Expressions)
Meta-character classification:
Character matching, number of matches, position anchoring, grouping
View Help:
Man 7 regex

basic Regular Expression meta-characters
The regular expression metacharacters match the string (the wildcard matches the file name)
/Escape character
Character matching:
. Matches any single character (. escape for.; [.] also said.)
[] matches any single character within the specified range
[^] matches any single character outside the specified range
[: Alnum:] Letters and numbers
[: Alpha:] any uppercase and lowercase character, [a-z,a-z]
[: Lower:] lowercase letters
[: Upper:] Uppercase
[: Blank:] blank characters, spaces and tabs
[: Space:] Horizontal and vertical white space characters (more than [: blank:] contains a wide range)
[: Cntrl:] non-printable control characters (backspace, delete, alarm ...) )
[:d igit:] decimal digits
[: xdigit:] hexadecimal digits
[: Graph:] printable non-whitespace characters
[:p rint:] printable characters
[:p UNCT:] Punctuation
number of matches:
Used after the number of characters to be specified, to specify the number of occurrences of the preceding character
*Match the preceding character any time, including 0 times (greedy mode: match as long as possible)
.*Any character of any length
\? Match its preceding character 0 or 1 times
+ match the characters in front of it at least 1 times
{n} matches the preceding character n times
{M,n} matches the preceding character at least m times, up to N times
{, n} matches the preceding character up to n times
{N,} matches the preceding character at least n times
Location Anchoring:
Location where the position appears
^ Beginning of anchor, user mode on the left
$ line End anchor for the right side of the pattern
^pattern$ for pattern matching whole line:
^$ Empty Line
^[[:space:]]*$Blank Line
\< or \b The first anchor for the left side of the word pattern
\> or \b Ending anchor for the right side of the word pattern
\<pattern\> Match Whole Word
Group:
() bind one or more characters together as a whole, such as: (Root) +
The contents of the pattern in the grouping brackets are recorded in internal variables by the regular expression engine, which are named: \1, \2, \3, ...
\1 represents the character that matches the pattern between the first opening parenthesis and the matching closing parenthesis from the left
Example: (string1+ (string2))
\1:string1+ (string2)

\2:string2
Back reference: Refers to the character result that matches the pattern in the preceding grouping brackets, not the pattern itself
Or: |
Example: A|b:a or B c|cat:c or cat (c|c) At:cat or cat

Egrep and extended Regular expressions
Egrep = Grep-e
Extending the meta-character of a regular expression
Character Matching:
. Any single character
[] Specify the range of characters
[^] characters not in the specified range
Number of matches:
*Match the preceding character any time
? 0 or 1 times
+1 or more times
{n} matches n times
{n,m} at least N, at most m times
Location anchoring:
^ Beginning of the line
$ End of line
\<, \b First
\>, \b Tail
Group:
()
Back reference:
\1, \2, ...
Or:
A|b:a or B
C|cat:c or Cat
(c|c) At:cat or cat

About VIM
Vi:visual Interface (Virtual interface), text editor
Text: Ascii,unicode
Type of text editing:
Line Editor: SED
Full Screen Editor: Nano,vi (Vim-vi improved)
Nano,vi single Edit
Sed bulk Edit
Other editors:
Gedit a simple graphical editor
Gvim a graphical version of the VIM editor
Open File
VIM [option] ... file ...
+# after opening the file, leave the cursor at the beginning of line #, + default end of line
+/pattern Open the file, leave the cursor at the beginning of the first line that is matched to the PATTERN
-B Binary Mode open file
-D Compare multiple files
-M read-only open file
Ex FILE|VIM-E directly into ex mode
If the file exists, the file is opened and the content is displayed
If the file does not exist, the first time after editing is to create the file
Vim mode
Vim is a pattern editor
Keystroke behavior is dependent on the VIM mode
Three modes:
Command (Normal) mode: default mode, move cursor, cut/paste text
Insert (insert) or edit mode: Modify text
Extended commands (Extended command) mode: Save, exit, etc.
ESC key to exit the current mode (always return to command mode)

Patterns and Transformations
Command mode:
Cursor jumps between characters:
H left, L right, J down, K on
#command: The number of characters to jump #
Jump between words:
W Next word First, e current or next word end, b current or previous first word
#command: Jump # Number of words
Current page Jump:
H page top, M-page middle row, L-page Bottom
Beginning and end of jump
^ Jump to the first non-null character at the beginning of a line
0 jump to the beginning of the line
$ jump to end of line
Move between rows:
#G, Extended mode: Jump to # line
G Last line
1g,gg First Line
Move between sentences:
) The next sentence
(The previous sentence
Move between paragraphs:
} Next Paragraph
{Last Paragraph
Turn screen operation:
Ctrl+f a screen to the end of the file
Ctrl+b a screen to the file header
Ctrl+d half screen to the end of the file
Ctrl+u half screen to file header
Operation:
Character editing:
X Delete character at cursor
#x删除光标处起始 # Characters
XP swap the character at the cursor position with its trailing character
~ Convert case
J Delete line breaks after the current line
Replace:
R (replace) replaces the character at which the cursor is located
R Switch to replacement (replace) mode
Delete:
d Delete command, can be combined with the cursor jump character, to achieve range deletion
d$ Delete to end of line
d^ Delete to non-empty header
D0 Delete to the beginning of the line
DW Delete to the next word first
De Delete to current or next word end
DB Delete to current or previous word header
#command指定 # A
DD deletes the cursor in the row
#dd多行删除
D is deleted from the current cursor position to the end of the line, leaving blank lines, equivalent to d$
Copy:
Y copy, behaves similar to D command
($,0,^,e,w,b, #command)
YY Copy Line
#yy复制多行
Y copy entire row
Paste
P (paste) if the buffer is an entire row, paste the current cursor below the row, or paste it at the end of the current cursor
P whole line, paste the current cursor above the line, otherwise, paste to the current cursor at the front of the
Undo Changes:
U Undo Recent Changes
#u撤销 # times changed
U undo all changes to this row after the cursor falls on this line
Ctrl+r Redo the final undo change
. Repeat the previous action
N. Repeat the previous action n times
To close a file:
ZZ Save exit
ZQ Do not save exit

Command mode---insert mode
Change Mode:
C (change) modified to toggle into insert mode
($,^,0,b,e,w, #command)
CC Delete Current line and enter new content
#cc删除 # line and enter new content
C Delete the current cursor to the end of the line and switch to insert mode
I insert, enter at the cursor location
I Enter at the beginning of the line where the current cursor is located
A append, enter after cursor location
A at the end of the line where the cursor is currently entered
o Open a new line below the current cursor line
O open a new line above the line where the current cursor is located
Insert mode---Command mode
Esc

Command mode--extended command mode
Press ":" Into ex mode
to create a command prompt at the bottom left of the screen
W write (Save) disk file
Wq write and exit
X write and exit
Q Exit
q! Do not save the file exit
R filename reads the contents of the files into the current file
W filename writes the contents of the current file to another file
!command execute command
R!command the output of the read-in command
address bound:
#具体第 # Line
#, #从左侧 # represents the starting line, to the right # indicates the end of the line
#,+ #从左侧 # represents the starting row, plus the number of rows on the right #
. Current line
$ last line
% full text, equivalent to 1,$
/pat1/,/pat2/ Start with line matching to PAT1, to first match to Pat2 Line end
#,/pat/from # line to Pat
/pat/,$ from Pat to last line
followed by an edit command
D Delete selected range
Y copy selected range
W File saves the range of rows as a file
R file inserts all the contents of the specified file in the range
Find
/pattern from the current cursor to the end of the file
? Pattern looks up the current cursor at the file header
N is in the same direction as the command
N and the command counter-direction
Find and replace
S complete the Find and replace operation in extended mode
format
s/find content/replace content/modifiers
What to look for: You can use the mode
to replace content: You cannot use the pattern, but you can use the \1,\2 to reference the symbol, and you can also use the & to refer to the entire content found in the previous lookup
modifier:
I ignore case
G global substitution Each line only replaces the first occurrence of the
GC global substitution, asks before each substitution
find the delimiter in the substitution "/" can be replaced by other characters
Extended command mode--command mode
Esc,enter

Vim Registers
26 Named Registers (A,B,...Z), 1 unnamed registers, long stored in different clipboard contents, can be shared between different sessions
Format:
#+ "Register + command
Example: 3 "tyy means copying 3 rows to T register;" TP means pasting the T register contents
Unspecified, no named registers will be used
There are 10 digital registers, with 0, 1, ... 9 means that 0 stores the most recently copied content, and 1 stores the most recently deleted content. When new text is changed and deleted, 1 dumps to 2, 2 dumps to 3, and so on. Digital registers cannot be shared between different sessions

Editing a binary file
Vim-b Binaryfile opened in binary mode (binary file)
In the extended mode:
%!xxd Convert to hexadecimal
%!xxd-r converting back to binary

Visualization mode
Allow selection of text blocks
V Character-oriented
V Line-oriented
CTRL-V Block-oriented
Visual keys can be used in conjunction with the move key:
W,),}, arrows, etc.
Highlighted files can be deleted, copied, changed, filtered, searched, replaced, etc.

Multi-file Mode
Vim file1 file2 file3 ...
Next
Prev before a
First one
Last one.
Wall Save All
Qall Quit all
Wqall Save Exit all

Multi-Window Mode
Multiple files:
Vim-o file1 file2 Horizontal split-screen file1 and File2
Vim-o file1 file2 Vertical Split-screen file1 and File2
Switching between windows: Ctrl+w,arrow
Single File:
Ctrl+w,s (split) Horizontal split screen
Ctrl+w,v (vertical) Vertical split screen
Ctrl+w,q Cancel Adjacent window
Ctrl+w,o Cancel All Windows
Wqall Save Exit all

Customizing the working characteristics of vim
Configuration file: Permanently valid
Global:/ETC/VIMRC
Personal: ~/.VIMRC
Extended mode: Current VIM process is valid
(1) Line number
Display: Set number, abbreviated as set Nu
Cancel display: Set Nonumber, abbreviated to set Nonu
(2) Case of ignoring characters
Enable: Set IC
Do not ignore: set Noic
(3) Auto Indent
Enable: Set AI
Disabled: Set Noai
(4) Smart indent
Enabled: Set smartindent shorthand set Si
Disabled: Set Nosi
(5) Highlight Search
Enabled: Set Hlsearch
Disabled: Set Nohlsearch
(6) syntax highlighting
Enabled: Syntax on
Disabled: Syntax off
(7) Display tab and line breaks (^i and display)
Enabled: Set list
Disabled: Set Nolist
(8) file format
Enable Windows format: Set Fileformat=dos
Enable UNIX format: set Fileformat=unix
Shorthand: Set Ff=dos|unix
(9) Set text width
Enabled: Set textwidth=65 (VIM only)
Disabled: Set wrapmargin=15
(10) Set the identification line of the line where the cursor is located
Enabled: Set Cursorline, abbreviated CUL
Disabled: Set no Cursorline
(11) Copy retention format
Enabled: Set paste
Disabled: Set Nopaste

Linux Learning Note 2.0

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.