Summary of linux basic knowledge

Summary of Xiaobai's notes:

Record some basic knowledge for easy learning and searching. I will add it slowly~~

1. root user

  In Android system, Linux system, Unix system, the super user of the system is named by defaultroot. Root is the only super user in the system. It has all the permissions of the system and has root permissions. It can modify and delete Android system files, start or stop a certain process, delete or add users, and add or disable a certain hardware. You can install third-party system themes, etc. The function of root authority is very powerful. If you do not understand the Android system and delete system files by mistake, the system will crash. Therefore, the Android system does not have root permissions by default. If you want to obtain root permissions, you must use cracking methods to achieve it.

  The Root of the Android system is equivalent to the Administrator of the Windows system, which is a super user (super administrator).

---------------------------------------------------------------------------------------------

2. The meaning of file color in Linux terminal

Green file-executable file, executable program

Red file-compressed file or package file

Blue file-directory

White files-general files, such as text files, configuration files, source code files, etc.

Light blue files-link files, mainly files created with the ln command

Yellow file-device file

Gray files-other files

Flashing red-there is a problem with the linked file

---------------------------------------------------------------------------------------------

3. Terminal operation

format

The format of input at the terminal is generally like this: command [-options] parameter1 parameter2

Insert picture description here
E.g:

note:

  1. Press [Enter] to start executing this command;
  2. If the command line is too long, you can use a backslash (\) to escape the [Enter] symbol to make the command line continue to the next line;
  3. If you have several commands to be executed together, each command can be separated by a semicolon (;), and then press [Enter] to execute them together (for example: ls -a;ls -al).
  4. Note: The special character can be escaped immediately after the backslash.

"~"-refers to the directory where the current user is located
"/"-refers to the current main computer directory
' . ' And " ./"-the current directory

shell command

First, what is a shell

  Shell means shell, which is the shell of the operating system. It is relative to the kernel, because it is based on the kernel and is a form of expression for users. For example, when we see a ball, we see its shell instead of the core.
   The shell in Linux refers to a user-oriented command interface. The form of expression is an interface that can be entered by the user. This interface can also feed back running information;
   we can operate and control the operating system through shell commands, such as the Shell in Linux Commands include ls, cd, pwd, etc.
   In summary, Shell is a command interpreter that starts, pauses, and stops the running of programs or controls the computer by accepting Shell commands entered by the user.

Common shell commands

  1. ls-Display the files in the current directory
  2. cd-switch to the specified directory
  3. pwd-view the absolute path of the current directory
  4. touch-create a file in the current directory
  5. mkdir-create folder
  6. rm-delete files or folders
  7. rm -rf directory name-delete the folder
  8. cat-open the specified file and display it to the terminal
  9. mv-file renaming and moving files, equivalent to cutting
  10. tree——Display all files in the current directory, and use a tree to display
  11. cp-copy the given file or directory to another file or directory
  12. find——find files, usually used to search for files that meet the conditions in a specific directory, and can also be used to search for files owned by a specific user
  13. sudo su-switch torootUser exit-exit
  14. ifconfig-display network configuration information
  15. reboot-reboot
  16. poweroff-shutdown
  17. ps-View the current process of the system
  18. file-view file type
  19. df-View the disk usage of the file system
  20. du-view file size
  21. ctrl+c-interrupt the current process
  22. top——View the real-time running status of the process
    Note:
  1. Once a file or directory is deleted under Linux system, it will disappear, and under Windows system, we can also restore it through the recycle bin;

  2. "Rm -rf /" This command, if executed under the root user, will delete the entire operating system.
    -------------------------------------------------- -------------------------------------------

4. Compression and decompression

Compression formats
commonly used under Linux Compression extensions commonly used under Linux are: .tar .tar.bz2 .tar.gz The
latter two are more commonly used, the following two tools are compression tools for the latter two files

gzip compression tool

The gzip compression tool is responsible for compressing and decompressing .gz files

gzip compresses files

  1. gzip XXX //compression command
  2. gizp -d XXX.gz//Unzip command
    Insert picture description here

gzip compresses the folder
3. gzip -r XXX //compression command
4. gizp -rd XXX//decompression command (without gz)
Note:
Although gzip can compress folders, it cannot provide packaging services. All files in the folder are individually compressed.

bzip2 compression tool

The bzip2 compression tool is responsible for compressing and decompressing files in **.bz2** format

bzip -z XXX //compression command
bzip -d XXX.bz2//decompression command

Packaging tool

tar tool parameters:

  1. -c create a new archive, compress
  2. -f use archive file
  3. -x extract files from the archive, unzip
  4. -j uses bzip2 compression format
  5. -z uses gzip compression format
  6. -v print out the command execution process

Packing and unpacking

tar -vcf a.tar a//Pack folder a into a.tar
tar vxf a.tar //Unpack
Insert picture description here

Compress and decompress .tar.bz2

tar -vcjf xx.tar.bz2 xx//Compress the xx folder
tar -vxjf xx.tar.bz2 //Unzip
Insert picture description here

Compress and decompress .tar.gz

tar -vczf xx.tar.gz xx//Compress the xx folder
tar -vxzf xx.tar.gz //Unzip

Compression and decompression in other formats

1. In .rar format,
rar needs to be installed first: sudo apt -get install rar
rar a xxx.rar xxx//compression
rar x xxx.rar //uncompress
2 .zip format
zip -rv xxx.zip xxx//compression
unzip -v xxx.zip //Unzip

---------------------------------------------------------------------------------------------

5.Linux system users and permissions

Linux system user account management

Linux system is aMulti-user and multi-task time-sharing operating system.
Any user who wants to use system resources must first apply for an account from the system administrator, and then enter the system as this account.
Each user account has a unique user name and its own password (ie, password).

There are three types of users:

  1. First time user-the user created when the system was installed
  2. root user-super administrator
  3. Ordinary user
    Note: User authority: root user> first time user> ordinary user.

About the user's profile:

account information Password information
user /etc/passwd /etc/shadow

Insert picture description here

The file structure of passwd:
xyb:X:1000:1000:xyb,:/home/xyb:/bin/bash

  1. : —— Separator
  2. xyb —— username
  3. X-password placeholder
  4. 1000-user id, namely uid
  5. 1000-group id, ie gid
  6. xyb,-user description
  7. /home/xyb-home directory
  8. /bin/bash-the command-line language shell used after login

File structure of shadow:
xyb:$6 98 v 1 rs / N 98v1rs/N98v1rs/NLPdVf3TehxK9qm2cbimBfuiBzr87xqp7olAtAQH/CHhlL7x8qL6JIvc0tNBOEZmPLDjnlH1PvEPEQzRmeJGBs0:18370:0:99999:7:::

  1. xyb —— username
  2. $6$98v1... —— the encrypted password
  3. 18370-the time of recent password change (days)
  4. 0 —— The password cannot be changed within a few days
  5. 99999-password expiration time
  6. 7-Initiate notification 7 days before the password expires
  7. How many days of grace

Linux user group management

In order to facilitate management, users are grouped. In this way, people who are not in this group can not access certain files. Each user can belong to multiple different groups

User: There are you, brother, every three people, everyone has their own room, everyone is Yonghua, and you can’t just browse other people’s stuff.
User group: You three belong to the same family. They belong to the same user group, and three people can share kitchen, study and other spaces

Therefore, users and user groups exist to control file access rights.
Each user group has an ID called GID

About the user group configuration file:

account information Password information
group /etc/group /etc/gshadow

The file structure of the group:
xyb:X :1000:

  1. xyb —— 名 名
  2. X —— password (x represents the encrypted password)
  3. 1000-group ID
  4. Followed by group members

Create users and user groups

1. Graphical interface creation

To use the graphical interface to create users and user groups, you need to install the gnome-system-tools tool:
Insert picture description here
you can find it laterUsers and groupsWith this tool, users and user groups can be created graphically.
Insert picture description here

2. Use shell commands to create

User command

  1. Add user: adduser username
  2. Modify user password: passwd username
  3. Delete user: deluser username
  4. Modify user: usermod username
  5. Switch user: su username

Some additional options for user commands:
-u —— uid
-d —— home directory
-g —— start group
-G —— additional group
-s —— use shell

Group command

  1. Add user group: addgroup user group name
  2. Display user names in the group: groups user group name
  3. Delete user: delgroup user group name
  4. Modify user group: groupmod user group name

Some additional options for user group commands:
-g —— group id

Guess you like

Origin blog.csdn.net/qq_43690936/article/details/105641474