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
E.g:
note:
- Press [Enter] to start executing this command;
- 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;
- 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).
- 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
- ls-Display the files in the current directory
- cd-switch to the specified directory
- pwd-view the absolute path of the current directory
- touch-create a file in the current directory
- mkdir-create folder
- rm-delete files or folders
- rm -rf directory name-delete the folder
- cat-open the specified file and display it to the terminal
- mv-file renaming and moving files, equivalent to cutting
- tree——Display all files in the current directory, and use a tree to display
- cp-copy the given file or directory to another file or directory
- 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
- sudo su-switch torootUser exit-exit
- ifconfig-display network configuration information
- reboot-reboot
- poweroff-shutdown
- ps-View the current process of the system
- file-view file type
- df-View the disk usage of the file system
- du-view file size
- ctrl+c-interrupt the current process
- top——View the real-time running status of the process
Note:
-
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;
-
"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
- gzip XXX //compression command
- gizp -d XXX.gz//Unzip command
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:
- -c create a new archive, compress
- -f use archive file
- -x extract files from the archive, unzip
- -j uses bzip2 compression format
- -z uses gzip compression format
- -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
Compress and decompress .tar.bz2
tar -vcjf xx.tar.bz2 xx//Compress the xx folder
tar -vxjf xx.tar.bz2 //Unzip
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:
- First time user-the user created when the system was installed
- root user-super administrator
- 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 |
The file structure of passwd:
xyb:X:1000:1000:xyb,:/home/xyb:/bin/bash
- : —— Separator
- xyb —— username
- X-password placeholder
- 1000-user id, namely uid
- 1000-group id, ie gid
- xyb,-user description
- /home/xyb-home directory
- /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:::
- xyb —— username
- $6$98v1... —— the encrypted password
- 18370-the time of recent password change (days)
- 0 —— The password cannot be changed within a few days
- 99999-password expiration time
- 7-Initiate notification 7 days before the password expires
- 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:
- xyb —— 名 名
- X —— password (x represents the encrypted password)
- 1000-group ID
- 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:
you can find it laterUsers and groupsWith this tool, users and user groups can be created graphically.
2. Use shell commands to create
User command
- Add user: adduser username
- Modify user password: passwd username
- Delete user: deluser username
- Modify user: usermod username
- 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
- Add user group: addgroup user group name
- Display user names in the group: groups user group name
- Delete user: delgroup user group name
- Modify user group: groupmod user group name
Some additional options for user group commands:
-g —— group id