Linux学习 第四周

1. 自建yum仓库,分别为网络源和本地源

  • 创建本地源

首先先把版本相应的镜像挂载上去

[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# mkdir /opt/CentOS8;cp -rvf /mnt/* /opt/CentOS8
[root@localhost ~]# ls /opt/CentOS8/
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL

然后创建repo文件

[root@localhost ~]# vim /etc/yum.repos.d/local.repo
[local]
name=centos
baseurl=file:///opt/CentOS8
gpgcheck=0
enable=1
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
centos 3.6 MB/s | 3.6 kB 00:00
Metadata cache created.

  • 自建网络源仓库

首先安装httpd服务

[root@localhost ~]# yum -y install httpd

在/var/www/html/目录下创建存放包的文件夹,并且把包拷贝到该文件夹下

[root@localhost ~]# mkdir /var/www/html/centos/{7,8}
[root@localhost ~]# cp -rvf /mnt/* /var/www/html/centos/8

创建repo文件

[root@localhost ~]# cat /etc/yum.repos.d/base.repo 
[BaseOS]
name=BaseOS
baseurl=http://192.168.237.8/centos/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=AppStream
baseurl=http://192.168.237.8/centos/8/AppStream
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

 [root@localhost ~]# yum makecache
 BaseOS 2.7 MB/s                                 3.9 kB 00:00
 ppStream 4.2 MB/s                               4.3 kB 00:00
 centos 3.6 MB/s                                3.6 kB 00:00
 Metadata cache created.

2. 编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

首先要先装上相应的包

[root@localhost ~]# yum -y install gcc make autoconf apr-devel apr-util-devel pcredevel openssl-devel redhat-rpm-config-125-1.el8.noarch

 [root@localhost ~]# wget https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.gz
 --2021-12-14 05:29:26-- https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.gz
 Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
 Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 9873874 (9.4M) [application/x-gzip]
 Saving to: ‘httpd-2.4.51.tar.gz’

 httpd-2.4.51.tar.gz 100%[============================>] 9.42M 15.0MB/s in 0.6s

 2021-12-14 05:29:28 (15.0 MB/s) - ‘httpd-2.4.51.tar.gz’ saved [9873874/9873874]

 [root@localhost ~]# tar -xvf httpd-2.4.51.tar.gz -C /usr/local/src/

通过./configure --help命令可以看到很多选项可以添加,再次选择默认,开始编译安装httpd,安装完成后启动

[root@localhost httpd-2.4.51]# make && make install
[root@localhost httpd-2.4.51]# cd /usr/local/httpd/bin
[root@localhost httpd-2.4.51]# ./apachectl

启动成功

 

 

 

 

3. 利用sed 取出ifconfig命令中本机的IPv4地址

[root@localhost httpd-2.4.51]# ifconfig ens33 | sed -r -n '2s/.*inet ([1-9.]+).*/\1/p'
192.168.237.28

4. 删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@localhost ~]# sed -r -i 's/^(#[[:space:]]?)(.*)/\2/g'  cat /etc/fstab
[root@localhost ~]# cat /etc/fstab

/etc/fstab
Created by anaconda on Fri Nov  5 11:11:46 2021

Accessible filesystems, by reference, are maintained under '/dev/disk/'.
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.

After editing this file, run 'systemctl daemon-reload' to update systemd
units generated from this file.

/dev/mapper/cl-root     /                       xfs     defaults        0 0
UUID=702357c7-0dab-49b1-8339-a495f7d2f8cb /boot                   xfs     defaults        0 0
/dev/mapper/cl-swap     none                    swap    defaults        0 0

处理/etc/fstab路径,使用sed命令取出其目录名和基名

取去目录名
[root@localhost ~]# ls /etc/fstab | sed -rn 's#(^/.*/)([^/]+/?)#\1#p'
/etc/
取文件名
[root@localhost ~]# ls /etc/fstab | sed -rn 's#(^/.*/)([^/]+/?)#\2#p'
fstab

列出ubuntu软件管理工具apt的一些用法(自由总结)

 

update 更新软件包列表
upgrade 升级系统中的所有软件包
install 安装软件包
remove 卸载软件包
autoremove 仅删除不需要再次下载的软件包
purge 彻底删除软件包(包括配置文件)
source 下载源代码
build-dep 自动下载安装编译某个软件所需要的软件包
dist-upgrade 升级整个发行版
dselect-upgrade 安装dselect的选择进行升级
clean 删除本地缓存的所有升级包
autoclean 删除本地缓存中无用的软件包
check 检查是否存在有问题的依赖关系
posted @ 2021-12-13 22:20  比奇堡的朋友  阅读(133)  评论(0)    收藏  举报