1、查找/var目錄下不屬于root、lp其屏、gdm的所有文件
find /var ! \( -user root -o -user lp -o -user gdm \) -ls
[root@centos7 ~]#find /var ! \( -user root -o -user lp -o -user gdm \) -ls
73 0 drwxr-xr-x 2 abrt abrt 6 May 6 19:21 /var/tmp/abrt
101354809 0 drwxr-xr-x 4 colord colord 67 May 6 19:22 /var/lib/colord
279449 0 drwxr-xr-x 2 colord colord 6 Aug 6 2017 /var/lib/colord/icc
101898310 4 -rw-r--r-- 1 colord colord 4096 May 6 19:22 /var/lib/colord/mapping.db
101898311 8 -rw-r--r-- 1 colord colord 7168 May 6 19:22 /var/lib/colord/storage.db
36406408 0 drwx------ 2 colord colord 6 May 6 19:22 /var/lib/colord/.cache
67530828 0 drwx------ 2 rpc rpc 6 Oct 31 2018 /var/lib/rpcbind
34876696 0 drwx------ 2 pulse pulse 6 Apr 13 2018 /var/lib/pulse
355825 0 drwxr-xr-x 2 chrony chrony 6 Apr 13 2018 /var/lib/chrony
358967 0 drwx------ 4 rpcuser rpcuser 30 May 6 18:56 /var/lib/nfs/statd
34908271 0 drwx------ 2 rpcuser rpcuser 6 Nov 8 2018 /var/lib/nfs/statd/sm
2证鸥、統(tǒng)計/etc/init.d/functions文件中每個單詞的出現(xiàn)次數(shù),并排序(用grep和sed兩種方法分別實現(xiàn))
方法一 cat /etc/init.d/functions | grep -o "[[:alpha:]]\+" | sort | uniq -c | sort -nr
[root@centos7 profile.d]#cat /etc/init.d/functions | grep -o "[[:alpha:]]\+" | sort | uniq -c | sort -nr
73 pid
60 if
58 file
57 echo
54 return
52 then
51 fi
39 n
38 base
37 local
34 kill
28 z
方法二 cat /etc/init.d/functions | sed -r 's/[^[:alpha:]]/\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr
[root@centos7 data]#cat /etc/init.d/functions | sed -r 's/[^[:alpha:]]/\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr
73 pid
60 if
58 file
57 echo
54 return
52 then
51 fi
39 n
38 base
37 local
34 kill
28 z
3、利用sed取出ifconfig命令中本機的IPv4地址
方法一ifconfig ens33 | sed -n '2p' | sed 's/.*inet //' | sed 's/ netmask.*$//'
[root@centos7 data]#ifconfig ens33 | sed -n '2p' | sed 's/.*inet //' | sed 's/ netmask.*$//'
192.168.38.101
方法二ifconfig ens33 | sed -n '2s/ *inet *\(.*\) \{2,\}netmask.*/\1/pg'
[root@centos7 data]#ifconfig ens33 | sed -n '2s/ *inet *\(.*\) \{2,\}netmask.*/\1/pg'
192.168.38.101
4娶眷、總結(jié)yum的配置和使用似嗤,包括yum倉庫的創(chuàng)建
yum:Yellowdog Update Modifier,rpm的前端程序届宠,可解決軟件包相關(guān)依賴性烁落,可在多個庫之間定位軟件包,up2date的替代工具
yum repository: yum repo豌注,存儲了眾多rpm包伤塌,以及包的相關(guān)的元數(shù)據(jù)文件(放置于特定目錄repodata下)
文件服務(wù)器:
http://
https://
ftp://
file://
yum配置:
yum的配置文件分為兩部分:main和repositoy
· man部分定義了全局配置選項,整個yum配置文件應(yīng)該只有一個main轧铁,位于 /etc/yum.conf 中每聪;
· repository 部分定義了每個源/服務(wù)器的具體配置,可以有一到多個齿风。位于 /etc/yum.repo.d 目錄下的各個文件中
倉庫指向的定義:
[repositoryID]
name=Some name for this repository
baseurl=url://path/to/repository/
enabled={1|0}
gpgcheck={1|0}
gpgkey=URL
enablegroups={1|0}
failovermethod={roundrobin|priority}
roundrobin:意為隨機挑選药薯,默認(rèn)值
priority:按順序訪問
cost= 默認(rèn)為1000
命令 | 說明 | 命令 | 說明 |
---|---|---|---|
yum repolist | 顯示倉庫列表 | yum list | 顯示程序包 |
yum install package1 | 安裝程序包package1 | yum update package1 | 升級程序包package1 |
yum remove package | 卸載程序包 | yum downgrade package1 | 降級程序包package1 |
yum info [...] | 查看程序包信息 | yum clean | 清理本地緩存 |
yum search keyword | 以指定的關(guān)鍵字搜索程序包 | yum makecache | 構(gòu)建緩存 |
--disablerepo=repoidglob | 臨時禁用此處指定的repo | --enablerepo=repoidglob | 臨時啟用此處指定的repo |
加入epel源
[root@centos7 yum.repos.d]#cat base.repo
[base]
name=CentOS
baseurl=file:///media
gpgcheck=0
[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch/
gpgcheck=0
enabled=1
搭建局域網(wǎng)內(nèi)部服務(wù)器,不連接外網(wǎng)救斑,局域http協(xié)議的網(wǎng)絡(luò)yum倉庫
也可以先建立本地yum用yum安裝httpd
[root@centos7 ~]#rpm -ql httpd
/etc/httpd
/etc/httpd/conf
/var/www
/var/www/cgi-bin
/var/www/html
[root@centos7 ~]#cd /var/www/html
[root@centos7 html]#systemctl start httpd
[root@centos7 html]#systemctl stop firewalld.service
此時在瀏覽器輸入IP可以看到測試頁面
建立一個頁面
[root@centos7 html]#echo welcome to nyc! > index.html
建立目錄
[root@centos7 html]#mkdir -pv centos/{6,7}/os/x86_64/
mkdir: created directory ‘centos’
mkdir: created directory ‘centos/6’
mkdir: created directory ‘centos/6/os’
mkdir: created directory ‘centos/6/os/x86_64/’
mkdir: created directory ‘centos/7’
mkdir: created directory ‘centos/7/os’
mkdir: created directory ‘centos/7/os/x86_64/’
掛載光盤到目錄
[root@centos7 html]#mount /dev/sr0 /var/www/html/centos/7/os/x86_64/
mount: /dev/sr0 is write-protected, mounting read-only
修改repo后yum clean all 清理緩存
yum repolist 緩存刷新成功
同理添加光驅(qū)掛載c6.10光盤
echo - - - > /sys/class/scsi_host/host2/scan 刷新顯示光驅(qū)
參考上步驟
自己建立無庫的rpm安裝包的庫
createrepo
5童本、編寫系統(tǒng)初始化腳本reset.sh ,包括別名,提示符顏色, yum倉庫配置文件
#!/bin/bash
#
#********************************************************************
#Author: Jack
#QQ: Secret
#Date: 2019-06-03
#FileName: reset.sh
#URL: Building
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
rootbashrc=`cd;pwd`/.bashrc
echo "alias net='cd /etc/sysconfig/network-scripts/'" >> $rootbashrc
echo "PS1='\[\e[1;32m\][\u@\h \W]\\$\[\e[0m\]'" > /etc/profile.d/env.sh
cd `df | grep /dev/sr* | tr -s ' ' | cut -d ' ' -f 6-` || \
mount `df | grep /dev/sr* | tr -s ' ' | cut -d ' ' -f 1` /media
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///media
#baseurl=http://192.168.2.165/centos/$releasever/os/$basearch/
gpgcheck=0
[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch/
gpgcheck=0
enabled=1
EOF
6、安裝tree,ftp,lftp,telnet等包
yum install tree ftp lftp telnet -y
7系谐、在CentOS7上編譯安裝apache2.4源碼包巾陕,并啟動此服務(wù)
- 安裝開發(fā)工具包讨跟,此方法偷懶,生產(chǎn)中建議依賴什么裝什么
yum grouplist
yum groupinstall "development tools"
- 解壓下載的源碼后1擅骸A澜场!必須L莞铡A构荨!要進入到編譯的目錄
查看說明
[root@centos7 httpd-2.4.39]#./configure --help
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/apache2]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
- 創(chuàng)建帳號
[root@centos7 httpd-2.4.39]#getent passwd | grep 80
[root@centos7 httpd-2.4.39]#useradd -r -u 80 -d /data/www/ -s /sbin/nologin httpd
[root@centos7 httpd-2.4.39]#id httpd
uid=80(httpd) gid=80(httpd) groups=80(httpd)
- 開始選擇設(shè)置
[root@centos7 httpd-2.4.39]#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
- 提示依賴亡资,安裝軟件
yum install apr-devel
yum install apr-util-devel
yum install pcre-devel
yum install openssl-devel
- 再次運行編譯
[root@centos7 httpd-2.4.39]#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
- 編譯成功生成了Makefile文件澜共,開始編譯,有可能會提示依賴
[root@centos7 httpd-2.4.39]#make
- 提示完成
make[4]: Leaving directory `/data/httpd-2.4.39/modules/mappers'
make[3]: Leaving directory `/data/httpd-2.4.39/modules/mappers'
make[2]: Leaving directory `/data/httpd-2.4.39/modules'
make[2]: Entering directory `/data/httpd-2.4.39/support'
make[2]: Leaving directory `/data/httpd-2.4.39/support'
make[1]: Leaving directory `/data/httpd-2.4.39'
- 開始編譯
[root@centos7 httpd-2.4.39]#make install
Making install in srclib
進入安裝目錄的bin下
[root@centos7 httpd-2.4.39]#cd /app/httpd/bin/
[root@centos7 bin]#pwd
/app/httpd/bin
[root@centos7 bin]#ls
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs
- 由于此處bin目錄不存在PATH變量中锥腻,把目錄加進去
[root@centos7 bin]#echo 'PATH=/app/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@centos7 bin]#cat /etc/profile.d/httpd.sh
PATH=/app/httpd/bin:$PATH
[root@centos7 bin]#. /etc/profile.d/httpd.sh
[root@centos7 bin]#echo $PATH
/app/httpd/bin:/data/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
- 啟動運行軟件
[root@centos7 ~]#apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos7.localdomain. Set the 'ServerName' directive globally to suppress this message
- 此時瀏覽器打開查看頁面嗦董,頁面地址在這里
[root@centos7 ~]#cd /app/httpd
[root@centos7 httpd]#ls
bin build cgi-bin error htdocs icons include logs man manual modules
[root@centos7 httpd]#cd htdocs/
[root@centos7 htdocs]#ls
index.html
[root@centos7 htdocs]#cat index.html
<html><body><h1>It works!</h1></body></html>
- 查看賬號是否被用上
[root@centos7 htdocs]#ps aux
root 48304 0.0 0.2 101656 2636 ? Ss 22:29 0:00 /app/httpd/bin/httpd -k start
daemon 48305 0.0 0.3 456104 3024 ? Sl 22:29 0:00 /app/httpd/bin/httpd -k start
daemon 48333 0.0 0.2 456104 2420 ? Sl 22:29 0:00 /app/httpd/bin/httpd -k start
daemon 48334 0.0 0.2 456104 2416 ? Sl 22:29 0:00 /app/httpd/bin/httpd -k start
daemon 48394 0.0 0.2 456104 2408 ? Sl 22:30 0:00 /app/httpd/bin/httpd -k start
- 未用上 需要更改
[root@centos7 htdocs]#vim /etc/httpd24/httpd.conf
166 User httpd
167 Group httpd
保存后,停止應(yīng)用再啟動
[root@centos7 htdocs]#apachectl stop
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos7.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@centos7 htdocs]#apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos7.localdomain. Set the 'ServerName' directive globally to suppress this message
- 再次查看查看賬號是否被用上 成功瘦黑!
[root@centos7 htdocs]#ps aux
root 48525 0.0 0.2 101656 2632 ? Ss 22:36 0:00 /app/httpd/bin/httpd -k start
httpd 48526 0.0 0.2 456104 2952 ? Sl 22:36 0:00 /app/httpd/bin/httpd -k start
httpd 48527 0.0 0.2 456104 2412 ? Sl 22:36 0:00 /app/httpd/bin/httpd -k start
httpd 48528 0.0 0.2 456104 2412 ? Sl 22:36 0:00 /app/httpd/bin/httpd -k start
httpd 48610 0.0 0.2 456104 2408 ? Sl 22:36 0:00 /app/httpd/bin/httpd -k start
- 添加man幫助的地址 下面為C7京革,C6在/etc/man.config
[root@centos7 man]#cd /app/httpd/man/
[root@centos7 man]#pwd
/app/httpd/man
[root@centos7 man]#vim /etc/man_db.conf
1 #
2 #
3 # This file is used by the man-db package to configure the man and cat paths.
4 # It is also used to provide a manpath for those without one by examining
5 # their PATH environment variable. For details see the manpath(5) man page.
6 #
7 # Lines beginning with `#' are comments and are ignored. Any combination of
8 # tabs or spaces may be used as `whitespace' separators.
9 #
10 # There are three mappings allowed in this file:
11 # --------------------------------------------------------
12 # MANDATORY_MANPATH manpath_element
13 # MANPATH_MAP path_element manpath_element
14 # MANDB_MAP global_manpath [relative_catpath]
15 #---------------------------------------------------------
16 # every automatically generated MANPATH includes these fields
17 #
18 #MANDATORY_MANPATH /usr/src/pvm3/man
19 #
20 MANDATORY_MANPATH /usr/man
21 MANDATORY_MANPATH /usr/share/man
22 MANDATORY_MANPATH /usr/local/share/man
23 MANDATORY_MANPATH /app/httpd/man