Linux commands:
(1) Linux yum command
yum (Yellow dog Updater, Modified) is a shell front-end package manager in Fedora and RedHat and SUSE. Based on RPM package management, RPM packages can be automatically downloaded and installed from designated servers, dependencies can be automatically processed, and all dependent software packages can be installed at once, eliminating the need to download and install them again and again. yum provides commands to find, install, and delete a certain, a group, or even all software packages. The commands are concise and easy to remember.
yum syntax
yum [options] [command] [package …]
- options: Optional, options include -h (help), -y (select all “yes” when prompted during the installation process), -q (do not display the installation process), etc.
- command: The operation to be performed.
- package:The name of the installed package.
yum command
- 1. List all updateable software inventory commands: yum check-update
-
2. Update all software commands: yum update
-
3. Install only the specified software command: yum install
-
4. Update only the specified software command: yum update
-
5. List all installable software command: yum list
-
6. Delete software package command: yum remove
-
7. Search software package command: yum search
-
8. Clear cache command:
- yum clean packages: Clear the software packages in the cache directory
- yum clean headers: clear headers in the cache directory
- yum clean oldheaders: clear old headers in the cache directory
- yum clean, yum clean all (= yum clean packages; yum clean oldheaders): clear cache directory
- Packages and old headers under
Linux yum commandhttps://www.runoob.com/linux/linux-yum.html
?Edit Linux command list
(2)Linux rpm command
The Linux rpm command is used to manage the suite.
rpm (full English spelling: redhat package manager) was originally a program used by the Red Hat Linux distribution to manage various Linux packages. It is very popular because it follows GPL rules and is powerful and convenient. Gradually adopted by other distributions. The emergence of the RPM package management method makes Linux easy to install and upgrade, which indirectly improves the applicability of Linux.
Grammar
rpm [-acdhilqRsv][-b
Parameter description:
- -a Query all packages.
- -b
+ or -t + Set the completion stage of the packaging package and specify the file name of the package file. - -c Only the configuration configuration files are listed. This parameter needs to be used in conjunction with the “-l” parameter.
- -d Only text files are listed. This parameter needs to be used with the “-l” parameter.
- -e
or –erase Delete the specified package. - -f
+ Query the packages that have the specified file. - -h or –hash List tags when the package is installed.
- -i Displays package related information.
- -i
or –install Install the specified package file. - -l Display the file list of the package.
- -p
+ Query the specified RPM package file. - -q Use query mode. When encountering any problems, the rpm command will first ask the user.
- -R Displays package dependency information.
- -s Displays the file status. This parameter must be used in conjunction with the “-l” parameter.
- -U
or –upgrade upgrade the specified package file. - -v Displays the instruction execution process.
- -vv Displays the instruction execution process in detail to facilitate troubleshooting.
- -addsign
+ Add a new signature certification to the specified package. - –allfiles Install all files.
- –allmatches Delete files that match the specified package.
- –badreloc Reconfigure the file when an error occurs.
- –buildroot
Set the directory to be used as the root directory when generating packages. - –changelog Display the change log of the package.
- –checksig
+ Check the signature authentication of the package. - –clean After completing the packaging of the suite, delete the directory created during the packaging process.
- –dbpath
Set the directory where the RPM database is to be stored. - –dump Display verification information for each file. This parameter needs to be used in conjunction with the “-l” parameter.
- –excludedocs When installing the package, do not install files.
- –excludepath
Ignore all files in the specified directory. - –force Forcefully replace the package or file.
- –ftpproxy
Specify FTP proxy server. - –ftpport
Set the communication port used by the FTP server or proxy server. - –help Online help.
- –httpproxy
Specify HTTP proxy server. - –httpport
Set the communication port used by the HTTP server or proxy server. - –ignorearch does not verify the structural correctness of the package file.
- –ignoreos Do not verify the structural correctness of the package file.
- –ignoresize does not check whether the disk space is sufficient before installation.
- –includedocs When installing the package, install the files together.
- –initdb Confirm that the correct database is available.
- –justdb Update the database without changing any files.
- –nobulid Do not execute any completion phase.
- –nodeps Do not verify the dependencies of package files.
- –nofiles Do not verify file attributes.
- –nogpg Skip all GPG signature verification.
- –nomd5 Do not use MD5 encoding algorithm to confirm the size and correctness of the file.
- –nopgp Skip all PGP signature authentication.
- –noorder Do not rearrange the installation order of packages to satisfy their dependencies.
- –noscripts Do not execute any installation script files.
- –notriggers Do not execute any Script files in the package package.
- –oldpackage Upgrade to an older version of the package.
- –percent Displays the completion percentage when installing the package.
- –pipe
Establish a pipeline and convert the output results into the input data of the execution command. - –prefix
If you reconfigure the file, put the file in the specified directory. - –provides Query the compatibility provided by this package.
- –queryformat
Set the representation method of file header. - –querytags List tags available for header format.
- –rcfile
Use the specified configuration file. - –rebulid
Install the original code package and regenerate the binary file package. - –rebuliddb Rebuild a database based on the existing database.
- –recompile
The effect of this parameter is similar to that of specifying the “–rebulid” parameter. When the package file is not generated. - –relocate
= Move the files that would have been placed in the original directory to the new directory. - –replacefiles Forcefully replace files.
- –replacepkgs Forcefully replace the package.
- –requires Query the required compatibility of this package.
- –resing
+ Delete the existing certificate and regenerate the signature certificate. - –rmsource Remove the original code after finishing packaging the suite.
- –rmsource
Delete the original code and the specified file. - –root
Set the directory to be used as the root directory. - –scripts List the variables of the scripts used to install the package.
- –setperms Set file permissions.
- –setugids Set the owner and group of the file.
- –short-circuit Directly skip the steps of the specified completion stage.
- –sign Generate PGP or GPG signature authentication.
- –target=
+ Set the installation platform of the generated package. - –test Just for testing, it does not actually install the package.
- –timecheck
Set the number of seconds for check time. - –triggeredby
Query the packager of this package. - –triggers Display the packaging script in the package file.
- –verify The effect of this parameter is the same as specifying the “-q” parameter.
- –version Display version information.
- –whatprovides
Query the compatibility provided by the package for the specified feature. - –whatrequires
Query the compatibility required by the package for the specified feature.
Build a local yum source
(1) Download Centos-7-X86_64-DVD-2009.iso
https://mirrors.bfsu.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso
Upload iso
Create a folder to mount the image
mkdir -p /mnt/iso
Mount the image to the specified folder
mount -o loop /data/CentOS.iso /mnt/iso/
Back up the original yum source
cp /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak
Delete original yum source
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls redhat.repo redhat.repo.bak [root@localhost yum.repos.d]# rm -rf redhat.repo [root@localhost yum.repos.d]# ls redhat.repo.bak
New local source file
[root@localhost yum.repos.d]# vim /etc/yum.repos.d/local.repo
Add content
[base] name=Server baseurl=file:///mnt/iso enabled=1 gpgcheck=0
Clear the original yum source and generate cache
yum clean all yum makecache yum list
The meaning of each parameter of chown and chmod commands.
1. The meaning of each parameter of chmod
Access: All users
Usage: chmod [-cfvR] [–help] [–version] mode file
Note: Linux/Unix file access permissions are divided into three levels: file owner, group, and other. Use chmod to control how files are accessed by others.
mode: permission setting string, the format is as follows: [ugoa…][[ + -=][rwxX]…][,…], where:
u represents the owner of the file,
g means someone who belongs to the same group as the owner of the file,
o means someone other than someone else,
a means all three.
+ means adding permissions,
– Indicates cancellation of permission,
= indicates the only setting permission.
r means readable,
w means writable,
x means executable,
X means only if the file is a subdirectory or the file has been set to executable.
-c: If the file permissions have indeed been changed, the change action will be displayed.
-f : Do not display an error message if the file permissions cannot be changed
-v: Display details of permission changes
-R: Make the same permission changes to all files and subdirectories in the current directory (that is, change them one by one in a recursive manner)
–help : show help information
–version : display version
In addition, chmod can also use numbers to represent permissions, such as chmod 777 file
The syntax is: chmod abc file
Among them, a, b, and c are each a number, respectively representing the permissions of User (the owner of the file), Group (other users in the user group of the file owner), and Other (users in other user groups).
r=4, w=2, x=1
If you want rwx attribute, then 4 + 2 + 1=7;
If you want rw-attribute, then 4 + 2=6;
If you want the r-x attribute, 4 + 1 = 7.
Example:
chmod a=rwx file has the same effect as chmod 777 file
chmod ug=rwx,o=x file has the same effect as chmod 771 file
Expansion operation
Create a /zy on your own virtual machine, add a new 5G disk to the virtual machine, create the lv mount /dxj directory, and expand it to 10G again.
One is to format the hard disk and mount it automatically at boot, and the other is to create an lvm volume and expand the lvm volume.
fdisk partd hard disk partition command usage
fdisk is a commonly used hard disk partition command, used in Linux systems. It can be used to create, edit and delete hard disk partitions.
When using the fdisk command, you need to run it as the root user. You can use fdisk with the following command:
“`
sudo fdisk /dev/[hard disk device name]
“`
Among them, [hard disk device name] should be replaced with the hard disk device you want to partition, such as /dev/sda.
After entering the fdisk command line interface, you can use the following commands to operate the partition:
– n: Create a new partition
-d: delete a partition
-p: Display the current partition table
-w: save and exit
The specific usage is as follows:
1. Create a new partition:
– Enter n and choose to create a new partition
– Select primary partition (enter p) or logical partition (enter l)
– Enter the starting and ending sectors (or size) of the partition
– You can choose to set the partition type (enter t) or partition name (enter c) for the new partition
2. Delete the partition:
– Enter d and select delete partition
– Enter the partition number to be deleted
3. Display the current partition table:
– Enter p to display the current partition table information
4. Save and exit:
– Enter w to save the partition table changes and exit fdisk.
1. Add hard disk
2. Check the system partition mounting status
lsblk -f
3. Create physical volume
[root@localhost ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created.
Check whether the creation is successful
pvdisplay
4. Create a logical volume group
vgcreate myvg /dev/sdb
5. Create logical volumes
Create a logical volume mylv with a size of 1G and attach it to the volume group of myvg
lvcreate -L 4.9g -n mylv myvg
Format logical volume
mkfs -t ext4 /dev/myvg/mylv
Mount logical volume
mount /dev/myvg/mylv /zy
Set up automatic mounting
UUID can be viewed using lsblk -f
Modify the file /etc/fstab
mount -a
reloads the file; mount
displays the contents of the file
Restart to check whether it is automatically mounted
reboot
df -l
Expansion
Mount a new hard drive 5G sdc
Add it to mylv of myvg according to the above steps:
[root@localhost ~]# pvcreate /dev/sdc Physical volume "/dev/sdc" successfully created. [root@localhost ~]# vgextend myvg /dev/sdc Volume group "myvg" successfully extended [root@localhost ~]# lvextend -L + 5G /dev/myvg/mylv Size of logical volume myvg/mylv changed from 4.90 GiB (1255 extents) to 9.90 GiB (2535 extents). Logical volume myvg/mylv successfully resized.
Expand the file system to allocate new space
[root@localhost ~]# resize2fs /dev/myvg/mylv resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/myvg/mylv is mounted on /dxj; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2 The filesystem on /dev/myvg/mylv is now 2595840 blocks long.
Expansion completed
The meaning of each field in the fstab configuration file
In Linux systems, fstab (file systems table) is an important configuration file used to define the file systems to be mounted when the system starts.
For a given line of configuration, the meaning of each field is as follows:
1. The first field: the identifier of the file system
– File systems are usually identified using UUID (Universally Unique Identifier) or device file paths.
– In the example you provided, UUID=”93ce6cdb-1f9c-4b70-b055-31adec159d89″ indicates the file system identified by the specified UUID.
2. The second field: mount point
– Specifies the target directory path to which the file system will be mounted.
– In the example you provided, /data indicates that the file system will be mounted to the /data directory.
3. The third field: File system type
– Specify the type of file system.
– Common file system types are usually used, such as ext4, ntfs, vfat, etc.
4. The fourth field: Mount options
– Specify the mounting options of the file system, such as defaults, noatime, ro, etc.
– In the example you provided, defaults means using the default mount options.
5. The fifth field: backup frequency
– Specify the frequency of file system backups.
– Usually set to 0, which means no backup.
6. The sixth field: fsck (file system check) sequence
– Specifies the order in which the system checks file systems during startup.
– Usually set to 0, meaning no checking.