linux文本处理sed软件包管理磁盘存储和文件系统

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux文本处理sed软件包管理磁盘存储和文件系统相关的知识,希望对你有一定的参考价值。

linux文本处理sed、软件包管理、磁盘存储和文件系统

1.取基名和文件名

[root@centos7 scripts38]#echo /etc/sysconfig/network-scripts/ |sed -r ‘s@(^/.*/)([^/]+)/?$@\1@‘
/etc/sysconfig/
[root@centos7 scripts38]#echo /etc/sysconfig/network-scripts/ |sed -r ‘s@(^/.*/)([^/]+)/?$@\2@‘
network-scripts

2.把网络修改成eth0

[root@centos7 scripts38]#sed -ri ‘/^[[:space:]]+linux16/s@(.*)@& net.infnames=0@‘ /boot/grub2/grub.cfg 
[root@centos7 data]#sed -ri ‘/GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0"@‘ /etc/default/grub

3.可能需要先下载前面那个包,才可以开启神奇文件夹,可以自动挂载光盘。

[root@centos7 Packages]#[root@centos7 ~]#yum install autofs
[root@centos7 data]#systemctl start autofs
[root@centos7 data]#systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[root@centos7 data]#cd /misc
[root@centos7 misc]#cd cd/

4.导入RPM验钞机

[root@centos7 scripts38]#ls /misc/cd/
CentOS_BuildTag  images    repodata
EFI              isolinux  RPM-GPG-KEY-CentOS-7
EULA             LiveOS    RPM-GPG-KEY-CentOS-Testing-7
GPL              Packages  TRANS.TBL
[root@centos7 scripts38]#rpm --import /misc/cd/RPM-GPG-KEY-CentOS-7

4.本地和阿里YUM源配置。清除缓存yum clean all

[base]
name=cdrom base
baseurl=file:///misc/cd
gpgcheck=1
gpgkey=file:///misc/cd/RPM-GPG-KEY-CentOS-7 

[epel]
name=aliyun epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
gpgcheck=0
enabled=0     #开启epel换为1

配置阿里云repo源,注意工作目录。

[root@centos7 data]#wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@centos7 /]#mv Centos-7.repo /etc/yum.repos.d/

5.搭建网络YUM源

[root@centos7 data]#yum install httpd
[root@centos7 data]#systemctl start httpd
[root@centos7 data]#cd /var/www/html
[root@centos7 html]#mkdir -pv  centos/6,7/os/x86_64/
[root@centos7 html]#mount /dev/sr0 centos/7/os/x86_64/
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos7 html]#mount /dev/sr1 centos/6/os/x86_64/
mount: /dev/sr1 is write-protected, mounting read-only

6.删除centos7系统/etc/grub2.cfg文件中所有以空白开头的行行首的空白字符

[root@centos7 ~]#sed -r ‘s/^[[:space:]]([[:space:]]+.*)/\1/‘ /etc/grub2.cfg

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

[root@centos7 yum.repos.d]#sed -r ‘s/^#[[:space:]]+//‘ /etc/fstab

8.在centos6系统/root/install.log每一行行首增加#号

[root@centos6 ~]#sed -r ‘s/(.*)/#\1/‘ /root/install.log

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

[root@centos7 ~]#echo /etc/fstab | sed -r ‘s@(^/.*/)([^/]+)/?$@\1@‘
/etc/
[root@centos7 ~]#echo /etc/fstab | sed -r ‘s@(^/.*/)([^/]+)/?$@\2@‘
fstab

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

[root@centos7 ~]#ifconfig eth0 | sed -rn ‘2s/^[^0-9]+([0-9.]+).*/\1/p‘
172.18.145.136

11.统计centos安装光盘中Package目录下的所有rpm文件的以.分隔倒数第二个字段的重复次数

[root@centos7 Packages]#ls /misc/cd/Packages/ |sed -rn ‘s@.*\.(.*)\..*@\1@p‘|sort|uniq -c|sort -nr
   4639 x86_64
   3122 noarch
   2258 i686

SNART不知道是这么来的。。。

[root@centos7 Packages]#ls /misc/cd/Packages/ |rev|cut -d ‘.‘ -f2 |sort |uniq -c |sort -nr
   4639 46_68x
   3122 hcraon
   2258 686i
      1 SNART

12.统计/etc/init.d/functions文件中每个单词的出现次数,并排序(用grep和sed两种方法分别实现)

这个感觉应该是没毛病

[root@centos7 Packages]#cat /etc/init.d/functions |egrep -o "\<[[:alpha:]]+\>" |sort |uniq -c|sort -nr
     60 if
     54 return
     52 then
     51 fi
     49 echo
     46 pid
     38 n

这个好像也不准,sed还是没有取单词的功能的

[root@centos7 Packages]#cat /etc/init.d/functions |sed -r ‘s@[^[:alpha:]]+@\n@g‘|sort|uniq -c|sort -nr|head
   1047 
     73 pid
     60 if
     58 file
     57 echo
     54 return
     52 then
     51 fi
     39 n
     38 base

这个应该是错误的。。。

[root@centos7 Packages]#cat /etc/init.d/functions |sed -r ‘s@[[:space:]]+@\n@g‘|sort|uniq -c|sort -nr|head
    608 
    103 [
     66 #
     64 ]
     59 &&
     58 if
     54 return
     52 then
     51 fi
     43 echo

13.将文本文件的n和n+1行合并为一行,n为奇数行

[root@centos7 Packages]#seq 10 |xargs -n2
1 2
3 4
5 6
7 8
9 10

sed高级用法太变态,头发容易秃,玩不了玩不了

[root@centos7 Packages]#seq 10|sed ‘N;s/\n/ /‘
1 2
3 4
5 6
7 8
9 10

14.自己配一些yum仓库

[root@centos7 data]#mkdir dnf
[root@centos7 data]#cd dnf/
[root@centos7 dnf]#rz -E
rz waiting to receive.
[root@centos7 dnf]#ll
total 808
-rw-r--r-- 1 root root 213696 Jun  4  2018 dnf-0.6.4-2.sdl7.noarch.rpm
-rw-r--r-- 1 root root  62404 Jun  4  2018 dnf-conf-0.6.4-2.sdl7.noarch.rpm
-rw-r--r-- 1 root root  75472 Jun  4  2018 libcomps-0.1.8-3.el7.x86_64.rpm
-rw-r--r-- 1 root root  46792 Jun  4  2018 python2-libcomps-0.1.8-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 416988 Jun  4  2018 python-dnf-0.6.4-2.sdl7.noarch.rpm
自动生成repodata
[root@centos7 dnf]#createrepo .
Spawning worker 0 with 3 pkgs
Spawning worker 1 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
自己配置repo
[root@centos7 yum.repos.d]#cat dnf.repo 
[dnf]
name=dnf
baseurl=file:///data/dnf
gpgcheck=0
查看是否成功
[root@centos7 yum.repos.d]#yum repolist 

后面编脚本了

tar -xvf httpd-2.4.25.tar.bz2
cd httpd-2.4.25/
指定路径,配置文件所在位置,开启一些服务,报错,缺APR
[root@centos7 httpd-2.4.25]#./configure  --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-ssl --enable-so
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
一般都是devel开发包
[root@centos7 httpd-2.4.25]#yum search apr
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
========================================== N/S matched: apr ===========================================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
下载APR包
[root@centos7 httpd-2.4.25]#yum install apr-devel
缺少什么包补什么包
[root@centos7 httpd-2.4.25]#yum install apr-util-devel
[root@centos7 httpd-2.4.25]#yum install pcre-devel
错误,不是这个包[root@centos7 httpd-2.4.25]#yum install mod_ssl
[root@centos7 httpd-2.4.25]#yum install openssl-devel
还有前面装了个gcc
成功后,执行make编译
然后再make install
[root@centos7 httpd-2.4.25]#make
[root@centos7 httpd-2.4.25]#make install
完成后
[root@centos7 httpd24]#cd /apps/httpd24/
写到环境变量中
[root@centos7 httpd24]#vim /etc/profile.d/env.sh
PATH=/apps/httpd24/bin:/apps/tree/bin:$PATH 
重读,刷新环境变量
[root@centos7 httpd24]#. /etc/profile.d/env.sh
开启服务
[root@centos7 httpd24]#apachectl restart
自动启动的文件,要把路径写里去
[root@centos7 httpd24]#ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 Oct 31  2018 /etc/rc.d/rc.local
[root@centos7 httpd24]#vim /etc/rc.d/rc.local
把下面的写到里面
/apps/httpd24/bin/apachectl start 
然后给这个文件执行权限。
[root@centos7 httpd24]#chmod +x /etc/rc.d/rc.local
页面显示的地方,可以自己修改。
[root@centos7 httpd24]#cd htdocs/
[root@centos7 htdocs]#ll
total 4
-rw-r--r-- 1 root root 45 Jun 12  2007 index.html

15.编译一个小东西

[root@centos7 data]#tar -xvf cmatrix-1.2a.tar.gz 
[root@centos7 cmatrix]#yum install ncurses-devel
[root@centos7 cmatrix]#./configure --prefix=/apps/cmatrix
[root@centos7 cmatrix]#make
[root@centos7 cmatrix]#make install

16.mbr分区表的备份和还原

查看MBR分区表前512个字节
[root@centos7 data]#hexdump -C /dev/sda -n 512
把分区表的64个字节拷贝出来,skip是跳过原文件的446个字节。
[root@centos7 data]#dd if=/dev/sda of=/data/mar_db bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000585693 s, 109 kB/s
把数据拷贝到其他服务器上
[root@centos7 data]#scp mar_db root@172.18.7.7:/data
破坏原来的分区表,seek是跳过目标的446个字节。服务器无法启动。
[root@centos7 data]#dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
重启进入救援模式。临时配一个IP地址
[root@centos7 ~]#ifconfig ens33 172.18.145.164
把备份的拷回来
[root@centos7 ~]#scp root@172.18.7.7:/data/mar_db .
[root@centos7 data]#dd if=mar_db of=/dev/sda bs=1 count=64 skip=446
重启电脑
exit

MBR分区
按柱面

最多4个分区,3个主分区,一个扩展分区,扩展分区中可以有多个逻辑分区。

最多管理2T的空间

GPT分区

按扇区

128个分区

最多管理8Z的空间

128位UUID

分区表有备份功能

17.parted命令

parted的操作都是实时生效的,小心使用
用法:parted [选项]... [设备 [命令 [参数]...]...]
parted /dev/sdb mklabel gpt|msdos
parted /dev/sdb print
parted /dev/sdb mkpart primary 1 200 (默认M)
parted /dev/sdb rm 1
parted  /dev/sdb –l 列出分区信息

18.模拟文件系统出故障

破坏
[root@centos7 data]#dd if=/dev/zero of=/dev/sda5 bs=1M count=1
已经被破坏,超级块打不开了
[root@centos7 data]#tune2fs -l /dev/sda5
tune2fs 1.42.9 (28-Dec-2013)
tune2fs: Bad magic number in super-block while trying to open /dev/sda5
Couldn‘t find valid filesystem superblock.
先取消挂载。必须在取消挂载的情况下修复
[root@centos7 ~]#umount /data
文件系统故障。无法挂载
[root@centos7 ~]#mount /dev/sda5 /data/
mount: mount /dev/sda5 on /data failed: Structure needs cleaning
xfs系统的修复方法
[root@centos7 data]#xfs_repair /dev/sda5
centos6 ext系列的修复方法
fsck /dev/sda5 -y
修复完成可以挂载
[root@centos7 ~]#mount /dev/sda5 /data/
[root@centos7 ~]#cd /data/
数据丢失
[root@centos7 data]#ll
total 12
drwxr-xr-x 246 root root 8192 Aug  8 16:34 lost+found

19.增加swap分区,过程没写。文件不能用UUID,不然重启会丢,要写文件名。

[root@centos7 ~]#swapon -s
Filename                Type        Size    Used    Priority
/dev/sdb1                               partition   4194300 0   -1
/dev/sda3                               partition   2097148 0   -2
/swapfile                               file    2097148 0   -3

20.文件挂载文件

创建一个大文件
[root@centos7 ~]#dd if=/dev/zero of=/bigfile bs=1M count=1024 
格式化EXT4
[root@centos7 ~]#mkfs.ext4 /bigfile
mke2fs 1.42.9 (28-Dec-2013)
/bigfile is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done                 
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
查看格式信息
[root@centos7 ~]#blkid /bigfile
/bigfile: UUID="9e1393ae-8e18-4dee-af73-4fafa373ff29" TYPE="ext4" 
写入文件永久挂载

21.迁移/home数据到一个新的地方,在维护状态。也就是单用户模式。init 1

[root@centos7 data]#mkfs.xfs /dev/sdb2
[root@centos7 data]#mkdir /mnt/home
[root@centos7 data]#mount /dev/sdb2 /mnt/home/
[root@centos7 data]#cp -av /home/. /mnt/home/
[root@centos7 data]#vim /etc/fstab 
UUID=63b5335d-a455-45a8-8f3f-3ebf66fb240a   /home              xfs      defaults    0  0 
[root@centos7 data]#mount -a
数据保留一段时间,没问题,取消挂载,准备删除原来的数据
[root@centos7 data]#umount /home/
现在看到的是原来/home的数据,挂载的时候是被覆盖的,看不到的
[root@centos7 data]#ls /home
zhang
把原来的数据都删除了,一定要注意不要把文件夹删除
[root@centos7 data]#rm -rf /home/*
重新挂载一下,数据就都迁移到新的硬盘。
[root@centos7 data]#mount -a
[root@centos7 data]#df
/dev/sdb2        2086912   33052   2053860   2% /home

22.创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

[root@centos7 data]#fdisk /dev/sdb
[root@centos7 data]#mke2fs -t ext4 -b 2048 -L ‘TEST‘ -m 1 /dev/sdb5
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
    16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 
[root@centos7 data]#vim /etc/fstab
UUID=e02a9d53-6f8a-4dca-a130-5296fe24975b  /mnt/sdb5              ext4     acl            0 0
[root@centos7 data]#mount -a

23.写?个脚本,完成如下功能:(1) 列出当前系统识别到的所有磁盘设备(2) 如磁盘数量为1,则显?其空间使?信息。否则,则显?最后?个磁盘上的空间使?信息。

#颜色配置
COLOR="\033[1;$[RANDOM%7+31]m"                                                             
COLOREND=‘\033[0m‘

df |grep /dev/sd | tr -s ‘ ‘|cut -d ‘ ‘ -f1

echo -e "$COLOR磁盘设备检查完毕 $COLOREND"

NUM=`df |grep /dev/sd |wc -l`
[ "$NUM" -eq 1 ] && echo -e "磁盘的利用率: $COLOR`df |grep /dev/sd | tr -s ‘ ‘|cut -d ‘ ‘ -f5` $COLOREND"
[ "$NUM" -gt 1 ] && echo -e "最后一个磁盘的利用率: $COLOR`df |grep /dev/sd | tr -s ‘ ‘|cut -d ‘ ‘ -f5|tail -n 1` $COLOREND" 
[root@centos7 data]#bash  aaa.sh 
/dev/sda2
/dev/sda5
/dev/sda1
/dev/sdb5
磁盘设备检查完毕 
最后一个磁盘的利用率: 1% 

24.简述linux下常?的?件系统有哪些,他们有什么区别?

1. EXT3 
(1)最多只能支持32TB的文件系统和2TB的文件,实际只能容纳2TB的文件系统和16GB的文件
(2)Ext3目前只支持32000个子目录
(3)Ext3文件系统使用32位空间记录块数量和i-节点数量
(4)当数据写入到Ext3文件系统中时,Ext3的数据块分配器每次只能分配一个4KB的块
2. EXT4 
EXT4是Linux系统下的日志文件系统,是EXT3文件系统的后继版本。
(1)Ext4的文件系统容量达到1EB,而文件容量则达到16TB 
(2)理论上支持无限数量的子目录
(3)Ext4文件系统使用64位空间记录块数量和i-节点数量
(4)Ext4的多块分配器支持一次调用分配多个数据块
3. XFS 
(1)根据所记录的日志在很短的时间内迅速恢复磁盘文件内容
(2)采用优化算法,日志记录对整体文件操作影响非常小
(3) 是一个全64-bit的文件系统,它可以支持上百万T字节的存储空间
(4)能以接近裸设备I/O的性能存储数据

25.个人配置简陋般脚本。

#!/bin/bash
#
#********************************************************************
#Author:        zhangfeng
#QQ:            553645084
#Date:          2019-08-03
#FileName:      reset.sh
#URL:           https://blog.51cto.com/14451122
#Description:       The test script
#Copyright (C):     2019 All rights reserved
#********************************************************************

#颜色配置
COLOR="\033[1;$[RANDOM%7+31]m"                                                                         
COLOREND=‘\033[0m‘

echo -e "$COLOR开机提示配置 $COLOREND"
cat > /etc/issue << EOF
\S
time is \t
tty is \l
hostname is \n 
Kernel \r on an \m
EOF
sleep 1

echo -e "$COLOR别名环境变量配置 $COLOREND"
cat > /etc/profile.d/env.sh << EOF
alias cdnet="cd /etc/sysconfig/network-scripts"
alias editnet="vim /etc/sysconfig/network-scripts/ifcfg-ens33"
alias scandisk="echo ‘- - -‘ > /sys/class/scsi_host/host2/scan;echo ‘- - -‘ > /sys/class/scsi_host/host0/scan" 
export PATH=/app/bin:$PATH
export EDITOR=vim
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL=ignoreboth
EOF

echo -e "$COLOR提示符配置 $COLOREND"
echo ‘PS1="\[\e[1;32m\][\u@\h \W]\\$\[\e[0m\]"‘ >> /etc/profile.d/env.sh
sleep 1 

echo -e "$COLORVIM配置$COLOREND"
cat > ~/.vimrc << EOF
set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
    if expand("%:e") == ‘sh‘
    call setline(1,"#!/bin/bash") 
    call setline(2,"#") 
    call setline(3,"#********************************************************************") 
    call setline(4,"#Author:        zhangfeng") 
    call setline(5,"#QQ:            553645084") 
    call setline(6,"#Date:          ".strftime("%Y-%m-%d"))
    call setline(7,"#FileName:      ".expand("%"))
    call setline(8,"#URL:           https://blog.51cto.com/14451122")
    call setline(9,"#Description:       The test script") 
    call setline(10,"#Copyright (C):    ".strftime("%Y")." All rights reserved")
    call setline(11,"#********************************************************************") 
    call setline(12,"") 
    endif
endfunc
autocmd BufNewFile * normal G
EOF
sleep 1 

#关闭selinux
echo -e "$COLORselinux已经关闭 $COLOREND"
sed -i  ‘s/SELINUX=enforcing/SELINUX=disabled/ ‘ /etc/selinux/config
sleep 1 

#把ens33改为eth0
echo -e "$COLOR网卡名改为eth0 $COLOREND"
sed -ri ‘/GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0"@‘ /etc/default/grub
sed -ri ‘/^[[:space:]]+linux16/s#(.*)#\1 net.ifnames=0#‘ /boot/grub2/grub.cfg
sleep 1 

#7版本关闭防火墙
echo -e "$COLOR关闭7版本防火墙 $COLOREND"
systemctl disable firewalld.service
sleep 1 

#6版本关闭防火墙
echo -e "$COLOR关闭6版本防火墙 $COLOREND"
chkconfig iptables off
sleep 1 

#配置阿里云YUM源适合7版本                                                            
echo -e "$COLOR7版本阿里云repo源配置 $COLOREND"
#wget http://mirrors.aliyun.com/repo/Centos-7.repo
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
#mv Centos-7.repo /etc/yum.repos.d/
#touch /etc/yum.repos.d/mirrorlist
#cat > /etc/yum.repos.d/mirrorlist <<EOF
#https://mirrors.aliyun.com/epel/$releasever/$basearch/
#EOF
touch /etc/yum.repos.d/epel.repo
cat > /etc/yum.repos.d/epel.repo <<EOF
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
gpgcheck=0
enabled=1
EOF
sleep 1 

echo -e "$COLOR阿里云普通源配置 $COLOREND"
touch /etc/yum.repos.d/base.repo
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd
    https://mirrors.aliyun.com/centos/7/os/x86_64/                                                 
gpgcheck=0
EOF
sleep 1 

yum clean all

echo -e "$COLOR自动下载软件 $COLOREND"
yum install tree -y
yum install ftp -y
yum install lftp -y
yum install telnet -y
yum install autofs gcc gcc-c++ glibc glibc-devel pcre pcre-devel
openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof
tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils -y

sleep 1 

echo -e "$COLOR服务器基本信息 $COLOREND"
echo -e  "CPU type is $COLOR`cat /proc/cpuinfo|grep -im1 ‘model name‘|cut -d: -f2|tr -s ‘ ‘`$COLOREND"
echo -e "Mem is $COLOR`cat /proc/meminfo |head -1 | tr -s " " |cut -d: -f2`$COLOREND"
echo -e "Disk size is $COLOR`cat /proc/partitions |grep "sda$" |tr -s " " |cut -d" " -f4` kB$COLOREND"

echo -e "OS version is $COLOR`cat /etc/redhat-release`$COLOREND"
echo -e "Kernel version is $COLOR`uname -r`$COLOREND"

26.httpd2.4.25自动安装脚本

#!/bin/bash
#
#********************************************************************
#Author:        zhangfeng
#QQ:            553645084
#Date:          2019-08-06
#FileName:      httpdaz.sh
#URL:           https://blog.51cto.com/14451122
#Description:       The test script
#Copyright (C):     2019 All rights reserved
#********************************************************************

#颜色配置
COLOR="\033[1;$[RANDOM%7+31]m"
COLOREND=‘\033[0m‘
echo -e "$COLORhttpd2.4.25安装脚本 适合centos7.6、7.5版本 ,其他未知 $COLOREND"

#前提必须要有/data目录才可以实现
#获取压缩包的2种方法
#scp root@172.18.7.7:/data/httpd-2.4.25.tar.bz2 /data/
wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.bz2

#下载配置环境
yum install apr-devel -y 
yum install pcre-devel -y 
yum install openssl-devel -y
yum install gcc -y 
yum install apr-util-devel -y 

#编译安装
tar -xvf /data/httpd-2.4.25.tar.bz2 -C /data/
cd /data/httpd-2.4.25/
./configure  --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-ssl --enable-so
make
make install
echo $? &&  echo -e "$COLORhttpd2.4.25安装完成 $COLOREND"
echo -e ‘\a‘

#配置环境变量
echo ‘PATH=/apps/httpd24/bin:$PATH‘ >> /etc/profile.d/env.sh
. /etc/profile.d/env.sh

#开启服务
cd /apps/httpd24/
apachectl restart

#开机自动启动配置
echo ‘/apps/httpd24/bin/apachectl start‘ >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
echo -e "$COLORhttpd2.4.25安装完成,已启动。开机自动启动开启 $COLOREND"

27.卸载httpd2.4.25脚本

#!/bin/bash
#
#********************************************************************
#Author:        zhangfeng
#QQ:            553645084
#Date:          2019-08-07
#FileName:      httpd2.4.25xz.sh
#URL:           https://blog.51cto.com/14451122
#Description:       The test script
#Copyright (C):     2019 All rights reserved
#********************************************************************

#颜色配置
COLOR="\033[1;$[RANDOM%7+31]m"
COLOREND=‘\033[0m‘
echo -e "$COLORhttpd2.4.25卸载脚本 适合centos7.6、7.5版本 ,只配合httpdaz.sh $COLOREND"

#删除安装目录、配置文件目录、解压包、压缩包。
rm -rf /etc/httpd
rm -rf /apps/httpd24
rm -rf /data/httpd-2.4.25.tar.bz2
rm -rf /data/httpd-2.4.25
echo -e "$COLOR安装目录、配置文件目录、解压包、压缩包删除完成 $COLOREND"

sed -i ‘/PATH=\/apps\/httpd24\/bin:$PATH/d‘ /etc/profile.d/env.sh
sed -i ‘/\/apps\/httpd24\/bin\/apachectl start/d‘ /etc/rc.d/rc.local

echo -e "$COLORhttpd2.4.25卸载完成 $COLOREND"

以上是关于linux文本处理sed软件包管理磁盘存储和文件系统的主要内容,如果未能解决你的问题,请参考以下文章

linux 文本处理sed&软件管理

Linux学习- sed,软件包管理

Linux文本处理和软件包管理

LVM实验分享和文本处理工具sed

Linux基础管理——sed(文本处理三剑客)

04-Linux文本处理-sed