linux基础练习4

1.查找/var/目录下不属于root。lp,gdm的所有文件

##利用find 加参数指定为用户文件在进行取反操作 传递给ls 显示列表
find /var ! -user root -a ! -user lp ! -user gdm | xargs ls -ld
2.统计/etc/init.d/functions文件钟每个单词的出现次数,并排序(用grep和sed两种方法分别实现)
cat /etc/init.d/functions | grep -o ‘ [[:alpha:]]\+ ‘ | sort | uniq -c
sed -r ‘[^[:alpha:]]\‘ /etc/init.d/functions | sort | uniq -c
3.利用sed取出ifconfig命令钟本机的ipv4地址
ifconfig | sed -n ‘/inet .* netmask/p‘| sed -n -r ‘s/inet (.*) netmask.*$/\1/p‘ | head -1
4.总结yum的配置和使用,包括yum仓库的创建
linux中软件安装需要将好的源码制作成二进制程序供linux内核使用,但是对用户来说编译源码难度有点大,因此软件制作公司在制作好软件的时候,将写好的软件包打包成一个rpm包Red-Hat Package Manager(RPM软件包管理器)由红帽公司开发。用户可以根据需要下载对应的rpm包来实现安装rpm -ivh 命令,但是rpm命令由于不能解决软件的依赖性问题,yum的出现解决了软件彼此依赖性问题
yum软件仓库在各地分布有yum服务器,里面存放的各种软件包,当我们配置好软件仓库路径时第一次通过yum命令下载软件包会获取yum服务器的软件包然后缓存到我们本地机器的yum缓存中,下次安装时我们通过本地yum缓存列表中查找到软件包及依赖的包然后安装
/etc/yum.conf中存放系统公共yum仓库配置,包括软件包校验,路径缓存等

我们可以配置自己的yum仓库来实现yum安装在/etc/yum.repo/目录中新建一个以.repo后缀中的文件指定本机yum安装路径通常分四种http:// https:// ftp:// file:// 前三中为网络路径 file为本地路径
配置本地yum路径,将路径指向光盘路径
1挂载光盘到目录

2创建修改/etc/yum.repos.d/.repo文件

[base]可以根据自己爱好指定
name=cdrom repo 给软件仓库指定一个名字
baseurl=file://data/base 指定指向本地挂载光盘
gogcheck=0 包校验 0为不校验1为校验
配置本地的yum路径将本地路径指向本地yum源就可以使用了


也可将路径指向网络中的yum仓库
5.编写系统初始化脚本reset.sh,包括别名,显示提示符颜色,予命仓库配置文件
另一个
#!/bin/bash
c="alias cdnet=‘cd /etc/sysconfig/network-scripts/‘"
a="alias ednet=‘vim /etc/sysconfig/network-scripts/ifcfg-ens33‘"
echo $c >> /root/.bashrc
echo $a >> /root/.bashrc
source /root/.bashrc
echo -e "PS1=\"\e[33m[\\h \W]\$\e[m\"" > /etc/profile.d/env.sh
source /etc/profile.d/env.sh
echo ‘PATH=/data/bin:$PATH‘ > /etc/profile.d/input.sh
source /etc/profile.d/input.sh
chmod +x /etc/profile.d/*
mkdir /data/base
mount /dev/sr0 /data/base
[ -d /etc/yum.repos.d/bak ] && echo "yes" exit || mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
touch /etc/yum.repos.d/base.repo
echo -e "[base]\nname=cdrom\nbaseurl=file:///data/base\ngpgcheck=0" >>/etc/yum.repos.d/base.repo
6。安装tree,ftp,lftp,telnet等包
yum install tree ftp lftp telnet
7,centos7上编译安装apache2.4源码包并启动此程序
先下载好源码编译必要的工具安装包
yum groupinstall "development tools" 使用组包安装。需要加引号让shell识别成一个组包
下载好源码包后解压到目录

将下载好的源码包解压到指定目录中源码编译过程我们需要一直在目录中进行操作

查看 install安装说明

一共有四步
通过./configure --指定软件总目录,二进制目录和其他功能
make 使用make命令创建make文档文档中存放着各种文件路径
make install 讲各文件复制到所对应的目录
systemctl start apache 启动服务


我们可以选择软件的安装目录,--prefix选项指定目录可以指定一个目录讲所有的软件包文件放入目录中,也可以分开放如--bindir=DIR 用户可执行文件目录--sbindir=DIR系统管理员可执行文件
指定总目录然后sys文件目录开始安装

发现缺少APR包我们先安装ARP包

使用yum install apr-devel 安装成功,继续往下安装

发现又缺少一个apr-util包,接着安装 yum install apr-util

发现缺少pcre包,安装pcre包 yum install pcre-devel

安装完成。
目录中自动生产makefile文件,文件中存放这各种文件要拷贝的路径

我们用make && make install 编译安装包,及讲对应的文件复制到对应的目录的过程

等待几分钟后安装完成,我们指定的目录为创建系统会自动为我们创建目录

进入/app/httpd/bin/目录中发现apachectl 文件,我们就可以开始启动文件了
由于不在path变量中,我们可以将apachectl路径放入环境变量中

指定路径加入环境变量
之后我们可以在任何目录中使用命令
使用apachectl start 开启网站服务

输入我们机器地址,发现已经可以访问
发下字面不太好看,进入软件安装的目录/app/httpd/htdocs/修改index.html

可以改成自己想要的哦
