Linux basic learning notes 1
Modify automatic Disk Partitions
The automatic disk partitioning scheme is insecure. An automatic disk partition only creates a root (/) File System Based on the logical volume (LV). This means that all data will be stored in a unique root file system, this is not safe for the actual system. The security method is to create multiple shared LV.
1. LV root: stores system commands and user data. 2. LV usr: a Linux application. 3. LV var: stores frequently changed data in the system. 4. LV home: stores data of common users. 5. LV swap: Used to implement virtual memory.
Disk Partitions should follow the following principles: 1)/the/directory must contain/etc/lib/bin/sbin. That is to say, these four directories cannot be independent file systems. 2) typical mounting methods include/root/home/usr/var/tmp/usr/local/opt. In other words, these directories can all be independent file systems. 3) Generally, an independent SWAP file system must be created on a system with non-massive physical memory to implement the virtual memory technology. Generally, it is twice the physical memory size. 4) An independent file system can be created on either a disk partition or a logical volume. 5) generally, at least a separate home partition or logical volume must be created in an actual system that provides services to multiple users.
System Operation Level and Shutdown
Any training in Linux runs at a specified running level (also known as running level), and different running-level programs and services are different, the work to be done and the purpose to be achieved are also different.
Linux running level per household
| Running level |
Description |
| 0 |
All operations will be terminated, and the machine will be stopped in an orderly manner. |
| 1 |
Single User mode. Used for system maintenance. Only a few of them run and all services are not started. |
| 2 |
Multi-user mode. Like Level 3, the Network File System (NFS) service is not started. |
| 3 |
Multi-user mode. Allows multiple users to log on to the system, which is the default startup level of the system. |
| 4 |
Left to the user's custom running level |
| 5 |
Multi-user mode. Run X-Window after the system is started to provide a graphical logon Window. |
| 6 |
All processes are terminated and the system restarts. |
You can run the following command to view the current system running level:
# Runlevel
You can use the following command to switch the running level
# Init [0123456Ss]
Shutdown and restart
Shutdown command # init 0
Restart command # init 6
In addition, you can use the halt and reboot commands to shut down and restart the instance.
Differences between init and shutdwon shutdown and restart:
The command init is used to immediately shut down and restart the instance. However, in a multi-user system, if you want to send a shutdown warning message so that each user can complete their work and log out, you must use the shutdown command. The shutdown command can shut down the system in a safer way. All users logging on to the system will be notified that the system will be shut down, and new Login operations will be blocked; at the same time, all processes will be notified that the system will shut down. In this way, some programs, such as vi, can save the files edited by the user in time and exit. The shutdown command format is
# Shutdown options
Description of the shutdown command options
| Item |
Description |
| -T sec |
Wait sec seconds before notifying init to shut down the system |
| -K |
Does not really close the system, but sends a warning message to each user. |
| -R |
Shut down and restart the system |
| -H |
Shut down and hold the system down |
| -F |
Disk check is not required after disk restart |
| -F |
Force disk check after restart |
| Time |
Set the time when the system is shut down, followed by a time in the format of hh: mm |
| Warning-nessage |
Warning message sent to the user |
Example: # shutdown-r + 5 "System will be reboot in 5 minites, Please save your work ."