Tool shortcuts, programming styles, commonly used commands, practical tools, etc.

Tool shortcut keys

sublime

  • ctrl + r, displays the function list.
  • ctrl + shift + l, scatter the selected area
  • ctrl + j, merge selected areas

Emacs

  • C-v next screen
  • M-v previous screen
  • C-l moving the test around the cursor to the center of the screen(top,bottom if you type agian)
  • C-p preivous line
  • C-n next line
  • C-b backware char
  • C-f forward char
  • M-f forward word
  • M-b backward word
  • C-a move to the beginning of a line
  • C-e move to the end of a line
  • M-a move to the beginning of a sentence
  • M-e move the end of a sentence
  • M-< move to the beginning of the whole text
  • M-> move to the end of the whole text
  • C-8 Numbers and above commands are equivalent to repeating the above commands multiple times (not all of them are possible, for example, turning pages will turn into line scrolling)
  • Cg cancel command
  • C-x 1 kill all other windows
  • M-d delete the next word after the cursor
  • M-<\DEL> delete the previous word before the cursor
  • C-k delete from the cursor position to the end of line
  • M-k delete to the end of the current sentence
  • Cy restores the row deleted by Ck. If Ck is pressed multiple times in a row, the recovery is also a multi-line statement.
  • C-/ undo
  • C-x C-f Find a file
  • C-x C-s Save a file
  • C-x C-c quit Emacs
  • Cs search Press again to search for the next one

programming style

JavaScript

  • Use single quotes for static strings and backticks for dynamic strings.
  • Prefer using destructuring assignment
  • For objects defined in a single line, the last member does not end with a comma; for objects defined on multiple lines, the last member ends with a comma.
  • The object should be as static as possible. Once defined, new attributes should not be added at will.
  • Set default values ​​for function parameters

Common commands

Linux

cd (Change Directory): switch directory

  • cd .. Return to the upper directory
  • cd ~ enter the current user's home directory
  • cd - previous working directory
  • cd ~username username's home directory

pwd (Print Working Directory): displays the current directory

  • pwd -P represents the current directory and displays the current path instead of using the link path

mkdir(MaKe Directory): Create a new directory

  • mkdir -m 711 test Specify permissions when creating a directory
  • mkdir -p test1/test2 creates the required directories recursively

rmdir(ReMove Directory): delete empty directory

  • rmdir -p test1/test2 will also delete the upper empty directory

ls to view files and directories

  • ls -a displays hidden files (starting with .)
  • ls -l displays detailed information, including file attributes such as permissions, time, etc.
  • ls -l –full-time List time attributes in full time mode

cp copy files

  • cp cname share/dir Copy the cname file to the share/dir directory
  • cp -d If the source file is a linked file, copy the linked file instead of the file itself
  • cp -i Prompt before overwriting
  • cp -p copies the file along with its attributes (permissions, ownership, time)
  • cp -r recursive copy
  • cp -a is equivalent to pdr
  • cp -l hard link instead of copy
  • cp -s symlink instead of copy

rm delete files

  • rm -f test1 force deletion
  • rm -i test1 interactive
  • rm -r directory recursively delete

od displays non-plain text file contents

  • od -ta default character
  • od -tc uses ASCII character output
  • od -t dox uses decimal, octal, and hexadecimal
  • od -tf floating point number

Three time attributes of the file

mtime will be modified when the file content changes
ctime will be modified when the file attributes are changed
atime will be modified when the file content is accessed
ls -ls –time=ctime afile

$PATH

It is a Linux file path environment variable, used to find files in any working directory. It consists of a series of directories separated by colons .

  • print echo $PATH
  • Set PATH="$PATH":/root even if the /root directory is added to the original one

The umask command is used to specify the default permissions when creating new files and directories.

  • Default permissions for new files = 666 - umask value (sign minus)
  • Default permissions for new directories = 777 - umask value (sign minus)
  • What is signed subtraction? For example, if umask is 033, then the default permissions for new files are rw-r–r– and for new folders, rwxr–r–.
  • Set umask Enter umask number

Special permissions for files

Umask actually has four numbers. The first number represents special permissions, and 4 2 1 represents SUID, SGID, and SBIT respectively. For example, 4755 means rwsr-xr-x
SUID. When the S flag appears on the x permission of the file owner, it is called setting the user ID, or SUID permission for short.

  • SUID permissions are only valid for binary files
  • SUID permissions are only valid at runtime
  • The executor must have x permissions for the program
  • The executor will have the permissions of the owner of the program
  • For example, the command to change the password is passwd, and changing the password requires modifying a file with permission 400, which means that only the root user can change it. The permission of passwd is 4755 and meets the conditions of SUID, then the executor will have the permission of root, the owner of passwd permission, so that he can modify the file with permission of 400 to change the password.

The ln command is used to create hard links and symbolic links

语法:
    ln [options] existing-file new-file
    ln [options] existing-file-list directory
常用选项:
    -f  强迫建立链接
    -n  如果“new-file”已存在,不创建链接。 
    -s 建立一个符号链接而不是硬链接
    -d 建立目录的硬链接 ???不行吧
Characteristics of hard links
  • Cannot span file systems
  • Only superusers can create directory hard links
  • Takes up no space (very little)
symbolic link
  • The system creates a new link-type file for the shared user and registers the new file in the user's shared directory entry. This link-type file contains the path name of the connected file. When this type of file is displayed in a long list using the ls command, the file type is l.
  • When a user wants to access a shared file and read a new link-type file, the operating system uses the file content as a path name to access the real shared file based on the nature of the link file type.
  • ln –s Chapter3 Chapter3.soft
Characteristics of symbolic links
  • Can span file systems and even networks (NFS)
  • If the file pointed to by the link is moved from one directory to another, it cannot be accessed through the symbolic link
  • Occupies a small amount of space and stores inode information

which finds the location of the instruction

如 which passwd  输出 /usr/bin/passwd

find

Use the find command to find all files with SUID permissions in the system.
  • find -perm -4000 -ls
Find files under /etc with file sizes between 50-60KB.
  • find /etc -size +50k -size -60k
Find files under /etc that are larger than 50KB and whose owner is not root.
  • find /etc -size +50k ! -user root

cut splits data in the same row

  • -d followed by delimiter, used with -f
  • -f specifies which paragraph to take based on the separation of -d
  • -c removes a fixed character range in character units
  • echo $PATH | cut -d “:” -f 1 output /home/ubuntu/bin
  • echo $PATH | cut -c 5-10 output e/ubun

grep removes a certain line based on conditions

  • -c counts the number of times a character is found (counted by line, that is, if there are multiple on a line, it counts as one)
  • -i ignore case
  • -n output line number
  • -v reverse selection
  • -a Search in text file
  • last | grep “freedom” -ni

The sort command is used to sort the input content

  • -f ignore case
  • -b ignores preceding whitespace characters
  • -M sorts by month
  • -n Sort purely numerically
  • -r reverse sort
  • -u remove duplicates
  • -t specifies the delimiter
  • -k specifies the partition interval

The uniq command is used to remove duplicate rows from the results

  • -i ignore case
  • -c count

The wc command is used to count words, characters, and lines

  • -l line
  • -w word
  • -m character

Utilities

Chrome DevTools

  • Right click on a breakpoint to add conditions
  • If you set it up, you can add a black box and ignore third-party components.
  • Press and hold to continue selecting the small black triangle for 500ms, which is equivalent to skipping the loop.
  • The request link can match the breakpoint according to the URL (regardless of fetch or xhr, it is all at the xhr breakpoint)
  • Watch can check variable values ​​at breakpoints

Guess you like

Origin blog.csdn.net/ZhaoBuDaoFangXia/article/details/78389985