-
Preparation before the experiment:
-
How to add a hard disk to the system:
- 1) linux virt-manager, click the light bulb, addhardware, select virtio as the mode
- 2) Windows is in the closed state, set, add, hard disk, next step, sata, next step, create, 5G, next step, location storage, complete
1. Device identification
-
After the equipment is connected to the system, it is in the form of files
-
Device file name:
- SATA/SAS/USB /dev/sda,/dev/sdb ##s=SATA,d=DISK a=first block, b=second block
- IDE /dev/hd0,/dev/hd1 ##h=hard
- VIRTIO-BLOCK /dev/vda,/dev/vdb ##v=virtio
- M2 (SSD) / dev / nvme0, / dev / nvme1 ## nvme = m2
- SD/MMC(card) /dev/nmcblk0,/dev/nmcblk1 ##nmcblk=nmc card
- CD-ROM drive /dev/cdrom, /dev/sr0, /dev/sr1
-
Device view
-
fdisk -l ##Check the disk partition situation, the real device situation in the system
-
lsblk ##Device usage
-
blkid ##Device management mode and device id, you can see the id, indicating that the device has been processed
-
df ##View the device mounting situation
-
df -h ##Unit 2^n
-
df -H ##Unit 10^n
-
cat /proc/partitions ##View the devices recognized by the system
-
2. Mount the device
-
A device with a device id in the system can be used by the system
-
Mount command
-
mount -o mount parameter device mount point
-
umount Equipment|Mounting Point##Uninstalling the device, busy shows that the uninstalled device is being used by the system program, and the uninstallation cannot be completed
-
Uninstall the mount in use:
- fuser -vm /mnt ##View what programs are running on the device
- kill -9 ###End the program
- fuser -kvm /mnt ##End most processes running on the device and solve the problem of program occupation
-
mount ##View mount information
-
mount device mounted point##Mounting device
-
mount -o rw /dev/vda1 /mnt
-
mount -o remount, ro /mnt ## (add mount point, no device) convert the mount parameters from read-write to read-only (only read but not write)
4. Partition
- Partition method:
MBR partition method
Primary partition: The partition that records the partition information in the primary partition table and can be used directly.
Extended partition: The partition recorded in the primary partition table cannot be used directly, but the logical partition goes to the
logical partition: the partition on the extended partition is also called Logical partition
o ##mbr分開去方法
p ##Check the partition situation.
Create an extended partition, and you can create 4 more partitions. Note: When creating an extended partition, you must give the remaining space to the extended partition
(when deleting the device, make sure that the device is not Use, otherwise the system is likely to crash)
GPT partition
g #Select GPT partition method
p##gpt partition method can always be created
-
fdisk /dev/sdb ##Partition interface
-
m ##hint
-
d ##Delete
-
n ##New
-
p ##View
-
-l ##View information
-
q ##Exit (do not save information)
-
wq ## (Exit and save to hard disk)
-
-
udevadm settle ##Synchronize the partition table to the system
-
dd if=/dev/zero of=/dev/vdb bs=1M count=1 ##Delete partition table information
-
1. Set the partition method
-
parted /dev/vdb mklabel msdos ##Set the partition method to mbr
-
parted /dev/vdb mklabel gpt ##Set the partition method gpt
-
-
2. Divide the partition
-
parted /dev/vdb mkpart primary 1 100 ##New partition
-
parted /dev/vdb mkpart primary 101 200 ##New partition
-
-
3. Delete the partition
- parted /dev/vdb rm 3 ##Delete 3 partition
- parted /dev/vdb rm 3 ##Delete 3 partition
5. System file formatting
-
The newly created device cannot be mounted and used
-
Need to install file system
-
Common file system comparison:
-
Device file system format
-
mkfs.xfs /dev/vdb1 -f ##Data needs to be formatted with -f
-
mount /dev/sdb1 /mnt ##Temporary mount
-
-
vim /etc/fstab
-
/dev/sdb1 /mnt xfs defaults 0 0 ##Permanently hang on the strategy
-
mount -a ##Make the policy take effect immediately
-
No need to delete it directly
-
The file is written incorrectly: (will cause the system to fail to start)
-
Enter the supervisor password
-
vim /etc/fstab modify the wrong location
-
-
df -sh ##View device size
6. Disk quota
-
Allow users not to monopolize the disk and limit the size of data written to the disk by users
-
umount /mnt
-
mount -o usrquota /dev/sdb1 /mnt ##Activate disk quota
-
mount | tail -n 1 ##
-
edquota -u lee ##Edit disk quota
-
vim /etc/fstab ##Permanent activation of disk quota
-
Permanent activation: /dev/sdb1 /mnt xfs defaults,usrquota 0 0 ##Automatically activate quotas when the disk is activated
-
Delete: directly delete the corresponding content
-
hard ##The maximum size of data that can be written
7. Find instruction to use
- Experiment preparation: Create file: in /mnt/ file
touch westosfile{1..5}
chmod 000 westosfile*
chown lee westosfile1
chgrp westos westosfile2
chown westos.lee westosfile3
chmod ug+w westosfile1
chmod ugo+w westosfile2
chmod 755 westosfile3
chmod 666 westosfile4
chmod 700 westosfile5
mkdir westosdir
ls -l /mnt
-
Monitoring command watch -n 1 ls -l /mnt
-
File name search
find /mnt/ -name westosfile1
find /mnt -name westosf*
-
最大深度
find /etc/ -name passwd
find /etc/ -maxdepth 2 -name passwd
find /etc/ -maxdepth 1 -name passwd
-
深度 浅 深度
find / mnt -mindepth 2 -type d
find / mnt -mindepth 1 -type d
find / mnt -mindepth 0 -type d
-
User search
find /mnt -user root
-
Group search
find /mnt -group westos
-
User and group search -a
find /mnt -user westos -a -group lee
-
User or group -o
find /mnt -user westos -o -group lee
find /mnt -user root -o -group lee
-
Reverse search
find /mnt -not -user root -o -group lee
-
File modification time
touch /mnt/westosfile1 ##Modification timestamp
find /mnt -cmin 1 ##File
date modified within one minute ##View time
find /mnt -cmin +1 ##Modification time is greater than one minute
-
File size search
dd if=/dev/zero of=/mnt/westosfile1 bs=1M count=10
dd if=/dev/zero of=/mnt/westosfile2 bs=1M count=20 dd if=/dev/zero of= /mnt/westosfile3 bs=1M count=30
find /mnt -size 20M ##File size of 20M
find /mnt -size -20M ##File size less than 20M find /mnt -size +20M ##File size greater than 20M
-
File permission search
exact##File permission bit 111 find /mnt -perm 222Or ##u bit has 2 or g bit has 2 or o bit has 2 find /mnt -perm /222
And ##u bit has 2 and g bit has 2 and o bit has 2 find /mnt -perm -222
-
Process the search results
find /mnt -perm -002 -exec rm -rf {}; ##Delete files with o bit 2