This article is simply to document some of the points to note when using Linux

directory

SSH login

The SSH protocol is used for the access between different hosts and uses asymmetric encryption. Pub indicates the public key and id_rsa indicates the private key. If no key exists, you can run the ssh-keygen command to generate the key. SSH does not have a certificate like HTTPS. Therefore, to prevent man-in-the-middle attacks, you need to confirm the fingerprint of the logged-in party during the first login. If yes, the fingerprint is saved in known_hosts of the directory where the local key is located.

There are two types of SSH login credentials: one is to use the key authentication every time, and the other is to save the public key of the logged-in party in the authorized_keys file in the directory where the key of the logged-in party resides. Run the ssh-copy-id user@host command to upload the key directly.

When we use Git, we can also save the local key in git server, so that we can use SSH protocol to do push and other operations without encryption.

File attributes

The file attributes are as follows

Methods for modifying attributes include

  • CHGRP Changes the owning group of a file
[root@www ~]# chgrp [-R] dirname/filename ... Options and parameters: -r: to make continuous changes recursively, that is, to update all files and directories in the subdirectory to become the group meaning. Often used to change all the files in a directory. Example:  [root@www ~]# chgrp users install.log [root@www ~]# ls -l -rw-r--r-- 1 root users 68495 Jun 25 08:53 install.log [root@www ~]# CHGRP testing install.log CHGRP: invalid group name 'testing' <==Copy the code
  • Chown: Changes the file owner
[root@www ~]# chown [-r] Account name file or directory [root@www ~]# chown [-r] Account name: group name File or directory Options and parameters: -r: Example: Change the owner of install.log to the bin account: [root@www ~]# chown bin install.log [root@www ~]# ls-l-rw-r --r-- 1 bin Users 68495 Jun 25 08:53 install.log Change the owner and group of install.log back to root:  [root@www ~]# chown root:root install.log [root@www ~]# ls -l -rw-r--r-- 1 root root 68495 Jun 25 08:53 install.logCopy the code
  • Chmod: changes the file permissions among them
    • 4 stands for R. For files, read content. For directories, read a list of directory structures
    • 2 indicates w. Files can be edited but cannot be deleted. Directories can be added, deleted, modified, or searched
    • 1 represents X, which can be executed for files and accessed for directories
[root@www ~]# chmod [-r] x x x x x x x x x x x x x x x x x x x x Make continuous changes recursively, meaning that all files in the subdirectory will changeCopy the code

User management

Check it out here

Linux is a multi-user and multi-task system that can be used by multiple users at the same time. Therefore, many users can use SSH to log in to the system at the same time. To better distinguish users, Linux divides users into super users, system users, and ordinary users. Users can also be added to different user groups for easy management. Each user has a UID that identifies the user and a GID that identifies the group it belongs to.

The super user has only root and the uid is 0, which has the highest system rights. System users are used by the system to run some services and cannot be used for login. The uid of other users is 1 to 499, and the UID of other users is 500 to 65535. A common user has limited permissions. If you need root permission, you can use sudo, provided that the superuser is configured in /etc/sudoers, or you can use su to switch to root

yum

Yum (Yellow dog Updater, Modified) is a package management tool similar to NPM. The complete command reference is here.

  • Yum install
  • Yum remove delete
  • Yum makecache creates cache
  • Yum Clean All Clears the cache

vi/vim

Is an IDE, see here for common usage

Common commands

We usually use commands to interact with Linux. Here are a few common ones. For details, refer to man7 or the rookie tutorial

Before I introduce specific commands, I will introduce some special symbols

  • | pipe, can be the result of the command output to another command as input
  • ; Semicolon to execute multiple commands on a single line
  • & Background execution

The command

  • Cat concatenat outputs the target file, default command line
  • Ps process status, for example
Ps - ef | grep process/keyword/view the particular processCopy the code
  • Wget download

The end