4.linux基础-文本处理sed&软件管理
1、自建yum仓库,分别为网络源和本地源
01)本地源
[root@centos7-v1 yum.repos.d]#mkdir /mnt/cdrom [root@centos7-v1 yum.repos.d]#mkdir /yum [root@centos7-v1 yum.repos.d]#mount /dev/cdrom /mnt/cdrom mount: /dev/sr0 is write-protected, mounting read-only [root@centos7-v1 yum.repos.d]#cp -r /mnt/cdrom/* /yum [root@centos7-v1 yum.repos.d]#mkdir backup [root@centos7-v1 yum.repos.d]#ll total 8 drwxr-xr-x 2 root root 6 Apr 6 02:30 backup drwxr-xr-x 2 root root 256 Feb 8 03:31 bak -rw-r--r-- 1 root root 98 Feb 7 20:54 base.repo.bak -rw-r--r-- 1 root root 2523 Dec 26 2020 CentOS-Base.repo [root@centos7-v1 yum.repos.d]#mv CentOS-Base.repo base.repo.bak backup/ [root@centos7-v1 yum.repos.d]#vim Centos-Media.repo [root@centos7-v1 yum.repos.d]#yum clean all
02)网络源
[root@centos7-v1 yum.repos.d]#ll total 4 drwxr-xr-x 2 root root 51 Apr 6 02:30 backup drwxr-xr-x 2 root root 256 Feb 8 03:31 bak -rw-r--r-- 1 root root 106 Apr 6 02:31 Centos-Media.repo [root@centos7-v1 yum.repos.d]#mv Centos* ./backup [root@centos7-v1 yum.repos.d]#wget wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo [root@centos7-v1 yum.repos.d]#yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: base extras updates Cleaning up list of fastest mirrors Other repos take up 187 M of disk space (use --verbose for details) [root@centos7-v1 yum.repos.d]#yum repolist Loaded plugins: fastestmirror, langpacks Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 246 kB 00:00:00 (3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:07 (4/4): updates/7/x86_64/primary_db | 14 MB 00:00:18 repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 509 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 3,598 repolist: 14,179
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
[root@centos7-v1 ~]#wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.gz --no-check-certificate --2022-04-06 02:41:32-- https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.gz Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132 Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected. WARNING: cannot verify dlcdn.apache.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’: Issued certificate has expired. HTTP request sent, awaiting response... 200 OK Length: 9726558 (9.3M) [application/x-gzip] Saving to: ‘httpd-2.4.53.tar.gz’ 100%[============================================================================================>] 9,726,558 2.78MB/s in 3.7s 2022-04-06 02:41:36 (2.50 MB/s) - ‘httpd-2.4.53.tar.gz’ saved [9726558/9726558] cd httpd-2.4.53/ mkdir /apps/httpd24 ./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-ssl --enable-so make make install [root@centos7-v1 httpd-2.4.53]#/apps/httpd24/bin/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.188.101. Set the 'ServerName' dir ective globally to suppress this message[root@centos7-v1 httpd-2.4.53]#curl http://192.168.188.101 <html><body><h1>It works!</h1></body></html> [root@centos7-v1 httpd-2.4.53]#
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@centos7-v1 httpd-2.4.53]#ifconfig eth0 | sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)#\2#gp' 192.168.188.101
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@centos7-v1 httpd-2.4.53]#cat /etc/fstab |sed -r 's/^#\ ?(.*)/\1/'|sed '/^$/d' /etc/fstab Created by anaconda on Sat Jan 22 00:10:21 2022 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 UUID=17fa4193-81c5-465c-b553-28637ac97717 / xfs defaults 0 0 UUID=28811210-772f-4aa2-904d-0e418172d319 /boot xfs defaults 0 0 UUID=60a5bdf8-3cd2-4d27-b293-2835dadd906b /data xfs defaults 0 0 UUID=9d8212dc-e6d2-45c3-b12a-d5575c24a7b4 /db1 ext4 defaults 0 0 /dev/vg0/mysql /mysql ext4 defaults 0 0 /dev/vg0/log /log xfs defaults 0 0 [root@centos7-v1 httpd-2.4.53]#cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Jan 22 00:10:21 2022 # # 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 # UUID=17fa4193-81c5-465c-b553-28637ac97717 / xfs defaults 0 0 UUID=28811210-772f-4aa2-904d-0e418172d319 /boot xfs defaults 0 0 UUID=60a5bdf8-3cd2-4d27-b293-2835dadd906b /data xfs defaults 0 0 UUID=9d8212dc-e6d2-45c3-b12a-d5575c24a7b4 /db1 ext4 defaults 0 0 /dev/vg0/mysql /mysql ext4 defaults 0 0 /dev/vg0/log /log xfs defaults 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@centos7-v1 httpd-2.4.53]#basename /etc/fstab fstab [root@centos7-v1 httpd-2.4.53]#dirname /etc/fstab /etc [root@centos7-v1 httpd-2.4.53]#echo /etc/fstab | sed -nr 's/(^\/.*)\/(.*$)/\1/p' /etc [root@centos7-v1 httpd-2.4.53]#echo /etc/fstab | sed -nr 's#(^\/.*)\/(.*)#\2#p' fstab [root@centos7-v1 httpd-2.4.53]#
6、列出ubuntu软件管理工具apt的一些用法(自由总结)
#apt install 安装软件包 #apt remove 移除软件包 #apt purge 移除软件包及配置文件 #apt update 刷新存储库索引 #apt search 搜索应用程序 #apt show 显示安装细节 #apt list 列出包含条件的包(已安装,可升级等) #apt edit-sources 编辑source源⽂件 #apt-cache madison nginx 查看仓库中软件包有哪些版本可以安装 #apt install nginx=1.14.0-0ubuntu1.6 安装软件包的时候指定安装具体的版本 查看文件来自于哪个包,类似redhat中的yum provides <filename> #apt-file search 'string' 默认是包含此字符串的文件 #apt-file search -x '正则表达式' 显示系统安装包的统计信息,可以统计已经安装包的数量,大小,占用空间等 #apt-cache stats 显示xxx包的信息,可以看到某个包的源、版本等信息 #apt-cache show xxx 更详细 #apt show xxx 查询软件xxx依赖哪些包 #apt depends xxx #apt-cache depends xxx
posted on 2022-04-06 14:58 N64_849411472 阅读(35) 评论(0) 编辑 收藏 举报