Basic use of linux and vim

Linux Basics
1. Directory
 /: The root directory. Generally, the root directory only stores directories. There is one and only one root directory under Linux. Everything starts from here, for example: /home starts from the root directory / and then goes to the home directory.
 /bin, /usr/bin: directory of executable binary files, such as common commands ls, tar, mv, cat, etc.
 /boot: Place the files used when the Linux system starts, such as the Linux kernel file: /boot/vmlinuz, and the system boot manager: /boot/grub.
 /dev: Store the device files under the Linux system. Accessing a file in this directory is equivalent to accessing a device. The commonly used method is to mount the CD-ROM drive mount/dev/cdrom/mnt
 /etc: The directory where system configuration files are stored. It is not recommended to store executable files in this subdirectory.
 /home: The default user home directory of the system. When adding a user account, the user's home directory is stored under the home directory. ~ represents the current user's home directory, and ~hadoop represents the user hadoop's home directory.
 /lib, /usr/lib, /usr/local/lib: the directory where the system uses the function library. During the execution of the program, it needs the assistance of the function library when it needs to call some extra parameters.
 /lost+fount: When an error occurs due to a system exception, some lost fragments will be placed in this directory.
 /opt: The directory where additional software is installed on the host.
 /root: The home directory of the system administrator root.
 /sbin, /usr/sbin, /usr/local/sbin: Place executable commands used by system administrators, such as fdisk, shutdown, mount, etc. Unlike bin, these directories are for system administrators root The commands used can only be viewed by general users and cannot be set and used.
 /temp: The directory where the programs being executed by general users are temporarily stored. Anyone can access it, and important data cannot be placed in this directory.
2. Access rights
Users can control the level of access to a given file or directory. A file or directory may have read, write, and execute permissions:
• Read permission (r) For a file, it has the permission to read the contents of the file; for a directory, it has the permission to browse the directory.
• Write permission (w) For files, it has the permission to add and modify file contents; for directories, it has the permission to delete and move files in the directory.
• Executable permission (x) For a file, the user has the permission to execute the file; for a directory, the user has the permission to enter the directory
Note: Usually, Unix/Linux systems only allow the owner (owner) or superuser of the file to change the read and write permissions of the file.
Each user has its own read, write and execute permissions.
• The first set of permissions controls the permissions to access your own files, the owner permissions.
• The second set of permissions controls the user group's access to one of the users' files.
• The third group of permissions controls all other users' access to a user's files.

3. Establish a connection ln
Linux link files are similar to shortcuts under Windows.
Category: Soft Links and Hard Links
Soft links: do not take up disk space. If the source file is deleted, the link will fail.
Hard links: Hard links can only link ordinary files, not directories
Format:
    ln source file link file
    ln -s source file link file
Note: If there is no -s, it means to create a hard link file, the two files occupy the same size of hard disk space, delete the source file, the link file still exists. So -s is the more common form.

Vim editor
 
Command mode:
yy: Copy the line where the cursor is located
4yy: Copy four lines down
P: paste

dd: cut the line where the cursor is located
2dd: cut two lines down
D: Cut backwards from the current cursor to the end of the line
d0: Cut from the current cursor to the beginning of the line
dw: delete a word
x: Delete the current cursor. one by one
X: Delete the current cursor. one by one


Up, down, left and right: h left j down k up l right

H: Above the current screen
M: the middle of the current screen
N: below the current screen

Ctrl+f: page down one page of code
Ctrl+b: turn up a page of code

20G: Quickly locate 20 lines of code
G: Quickly locate to the end of the code
gg: Quickly return to the first line of code
w: the length of a word to skip backwards
b: skip forward the length of a word

u: undo
ctrl+r: reverse undo

select a piece of code
v:
V:
>> move code to the right
.: Repeat the last command

code jump
{: Improvement
}:down

r: replace a character
R: replace the character after the cursor

Line end model:
    w: save
    q: quit
    wq: save and exit
    shift+zz: save and exit

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326504908&siteId=291194637