, The use of rpm yum command and the meaning of parameters. 2. Upload the image to the virtual machine to build a local yum source. 3. The meaning of each parameter of the chown chomd command. 4. How to use the fdisk partd hard disk partition command? 5. In your own virtual

1. Use of rpm, yum commands, parameter meanings

(1) The use of common rpm commands and the meaning of parameters

  1. Install a software package: rpm -i package.rpm: Install a software package. parameter:

    • -i: Install the software package.
    • --nodeps: Ignore dependencies.
    • --force: Force installation even if the package is already installed.
  2. Upgrade software package: rpm -U package.rpm: Upgrade an installed software package. parameter:

    • -U: Upgrade software package.
    • --nodeps: Ignore dependencies.
    • --force: Force upgrade, even if the package is already installed.
  3. Delete a software package: rpm -e package: Delete an installed software package. parameter:

    • -e: Delete the software package.
    • --nodeps: Ignore dependencies.
    • --noscripts: Do not execute scripts.
  4. Query the software package: rpm -q package: Query the detailed information of the software package. parameter:

    • -q: Query software packages.
    • -a: Query all installed software packages.
    • -i: Display detailed information of the software package.
  5. List installed packages: rpm -qa: List all installed packages.

  6. Query which software package a file belongs to: rpm -qf file: Query which software package the specified file belongs to.

  7. Display the file list of the software package: rpm -ql package: Display the file list of the software package.

  8. Query the dependencies of the software package: rpm -qR package: Query the dependencies of the software package.

  9. Query the change log of the software package: rpm -q --changelog package:

(2) Common command uses and parameter meanings of yum

  1. yum install : Install the specified software package.
  2. yum update : Update the specified software package.
  3. yum remove : Uninstall the specified software package.
  4. yum search : Search for software packages containing the specified keyword.
  5. yum list: Lists all installed software packages.
  6. yum info : Display detailed information of the software package.
  7. yum clean all: Clear all cached packages and metadata.
  8. yum upgrade: Upgrade all installed software packages.
  9. yum check-update: Check whether there are available package updates.
  10. yum provides : Finds packages that provide the specified file.

2. Upload the image to the virtual machine to build a local yum source.

1. On the local computer, copy the image file you want to upload to a directory of the virtual machine, such as /home

2. Mount the IOS image to /home/rhel

mount -o loop rhel-server-7.9-x86_64-dvd.iso /home/rhel

3.

Add automatic mounting at boot

chmod +x /etc/rc.d/rc.local

vi /etc/rc.d/rc.local

Add mount -o loop rhel-server-7.9-x86_64-dvd.iso /home/rhel at the bottom of vi /etc/rc.d/rc.local

(No need to add the last line, it will be used for later expansion)

3. Add local yum source

(1. Add in vi /etc/yum.repos.d/local.repo

[local]
name=local
baseurl=file:///home/rhel
enable=1
gpgcheck=0

(2.View

yum repolist

.The meaning of each parameter of the chown chomd command

1.The meaning of each parameter of the chown command

The chown command is used to change the owner of a file or directory. Its syntax is:

chown [options]… [owner][:[group]] file…

where the options can be one of the following:

  • -c: Display prompt information only when the owner of a file or directory is changed.
  • -f: Do not display error messages.
  • -h: Fix the owner of the symbolic link, not the file or directory the symbolic link points to.
  • -R: Recursively change the owners of all files in a directory and its subdirectories.
  • -v: Display detailed operation information.

The owner parameter is used to specify the new owner, which can be a username or user ID. You can also specify a new group if you follow the owner with a colon (:) and the group parameter. If only the group parameter is specified without the owner parameter, only the group of the file or directory is changed.

The file parameter specifies the path of the file or directory whose owner you want to change. Multiple files or directories can be specified at the same time, separated by spaces.

Note: The chown command can only be executed by the superuser or the owner of the file.

2.The meaning of each command parameter of chomd

The chmod command is used to change the permissions of a file or directory. Its parameters usually consist of three numbers, each number representing a different permission.

These three numbers represent the permissions of the file owner, the group to which the file belongs, and other users respectively. Each number can represent different permissions using a number between 0-7.

Here are the permissions each number represents:

  • 0: No permission
  • 1: Execute permissions
  • 2: Write permission
  • 3: Write and execute permissions
  • 4: Read permission
  • 5: Read and execute permissions
  • 6: Read and write permissions
  • 7: Read, write and execute permissions

In addition to numbers, you can also use symbols to represent permissions:

  • r: read permission
  • w: write permission
  • x: execution permission

Here are some examples of commonly used chmod commands:

  1. Set the owner of the file to have read, write, and execute permissions, and the group and other users to whom the file belongs have only read permissions:

    chmod 744 file.txt 
  2. Set the owner of the file and the group to which the file belongs to have read and write permissions, and other users have no permissions:

    chmod 660 file.txt 
  3. Set the owner of the directory and the group to which the file belongs to have read, write, and execute permissions, and other users have read and execute permissions:

    chmod 775 directory/

4. Usage of fdisk partd hard disk partition command

1.

fdisk is a command line tool for managing hard disk partitions. Here’s how to use the fdisk command:

  1. View hard disk partition information: fdisk -l

  2. Enter the fdisk command line interface: fdisk /dev/sda (where sda is the hard disk device name and can be replaced according to the actual situation)

  3. View current partition information: Enter the p command

  4. Create a new partition: Enter the n command, and then follow the prompts to enter information such as partition type, starting position, and ending position.

  5. Delete a partition: Enter the d command followed by the partition number to be deleted

  6. Save partition information: Enter w command

  7. Exit the fdisk command line interface: enter the q command

2.

parted is a command line tool for hard disk partitioning that can be used to create, delete, and adjust hard disk partitions.

The general usage of using the parted command is:

  1. Open a terminal and enter the sudo parted command to gain root privileges.
  2. Enter the parted /dev/sdX command, where sdX is the hard disk device code to be partitioned, such as sda, sdb, etc. Note: Before using the parted command, please make sure you have backed up your data, as the partition operation may cause data loss.
  3. Use the following command to perform partitioning operations:
  4. mklabel label-type: Create a new disk label, label-type can be msdos, gpt, etc.
  5. mkpart partition-type [file system-type] start end: Create a new partition, partition-type can be primary, logical, extended, etc., file system-type can be ext4, ntfs, etc., start and end are the starting and ending positions of the partition, and units such as MB, GB, etc. can be used.
  6. rm partition: Delete a partition.
  7. resizepart partition end: Adjust the size of a partition, end is the new end position.
  8. print: Print the partition table.
  9. Enter the quit command to exit parted.

5. Create a /backup on your own virtual machine. Add a new 5G disk to the virtual machine, create the lv mount /backup directory, and expand it to 10G again. (operate)

1. Add a new 5G disk to the virtual machine

2. Check the newly added disk fdisk -l

3. Create a new partition (enter the root directory and run su root)

fdisk /dev/sdb

n #Create a new partition

p #Create primary partition

1 #Partition number

Enter #Select the starting sector by default

Enter #The end sector is selected by default

w #Save and exit

4. Create a logical volume and mount it in the /cwl (a new directory created by yourself) directory

mkdir cwl

pvcreate /dev/sdb1

vgcreate cwl-vg /dev/sdb1

lvcreate -L + 4.5G -n cwl-lv cwl-vg (Originally, 5G was added, but the disk space was insufficient, so I wrote it smaller)

mkfs.ext4 /dev/cwl-vg/cwl-lv #Format the virtual machine hard disk partition

mount /dev/cwl-vg/cwl-lv /cwl #Mount

5. Expansion to 10G

(1. Hard drive expansion to 10G

(2.fdisk /dev/sdb

n #Create a new partition

p #Create primary partition

Enter #default number

Enter #Select the starting sector by default

Enter #The end sector is selected by default

w #Save and exit

(3. After restarting, enter fdisk -l # You must restart otherwise an error will be reported when formatting the disk later.

(4. Format the disk

mkfs.ext4 /dev/sdb2

(5. Enter logical volume management

lvm

(6.Initialize partition

pvcreate /dev/sdb2

(7. Add the initialized partition to the virtual volume group cwl-vg

vgextend cwl-vg /dev/sdb2

(8. Expand the capacity of existing volumes

vgextend cwl-vg /dev/sdb2

lvextend -l + 1406 /dev/mapper/cwl-vg/cwl-lv

Then exit lvm exit

Return to the root directory cd ../

Expand the file system

resize2fs /dev/mapper/cwl–vg-cwl–lv

View mounts

df-h

6. Set up automatic mounting at boot (if you do not set it up, you must type mount /dev/cwl-vg/cwl-lv /cwl again every time you boot)

vi /etc/rc.d/rc.local

Add mount /dev/cwl-vg/cwl-lv /cwl to the last line

After exiting, enter chmod 755 /etc/rc.d/rc.local

6. The meaning of each field in the fstab configuration file: UUID=”93ce6cdb-1f9c-4b70-b055-31adec159d89″ /data defaults 0 0

In Linux systems, fstab is an important configuration file used to define the settings for mounting file systems when the system starts. The meaning of each field is as follows:

  1. UUID (Universally Unique Identifier): This is the unique identifier of the file system. UUID can ensure that the file system can be correctly identified when remounting or reconnecting the device.

  2. “/data”: This is the device node or device file path of the file system to be mounted. In this example, “/data” means mounting the file system to a directory named “data”.

  3. “defaults”: This is a set of keywords used to specify mount options for the file system. These options can include read and write permissions, automounting, device node permissions, etc. In this example, “defaults” means to use the default mount options.

  4. “0”: This is the field used to specify the backup order of the file system. Normally, this field is set to 0, indicating that no backup is required.

  5. “0”: This is a field used to specify the verification order of the file system. Normally, this field is set to 0, indicating that no verification is required.

To summarize, the meanings of the fields in this configuration file are as follows:

  • UUID: Unique identifier of the file system.
  • /data: The path of the file system to be mounted.
  • defaults: Mount options for the file system.
  • 0: Backup order.
  • 0: Inspection order.

The virtual machine expansion draws lessons from Redhat7.9 to create a new 5g hard disk, create an LV and mount it, set up permanent mounting, and expand it to 10g. -CSDN Blog