文件搜索壓縮 sed 軟件包管理 rpm yum 源碼編譯安裝httpd

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ù)

  1. 安裝開發(fā)工具包讨跟,此方法偷懶,生產(chǎn)中建議依賴什么裝什么
    yum grouplist
    yum groupinstall "development tools"
  2. 解壓下載的源碼后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]
  1. 創(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)
  1. 開始選擇設(shè)置
[root@centos7 httpd-2.4.39]#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
  1. 提示依賴亡资,安裝軟件
yum install apr-devel
yum install apr-util-devel
yum install pcre-devel
yum install openssl-devel
  1. 再次運行編譯
[root@centos7 httpd-2.4.39]#./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status
  1. 編譯成功生成了Makefile文件澜共,開始編譯,有可能會提示依賴
[root@centos7 httpd-2.4.39]#make
  1. 提示完成
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'
  1. 開始編譯
[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
  1. 由于此處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
  1. 啟動運行軟件
[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
  1. 此時瀏覽器打開查看頁面嗦董,頁面地址在這里
[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>
  1. 查看賬號是否被用上
[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
  1. 未用上 需要更改
[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
  1. 再次查看查看賬號是否被用上 成功瘦黑!
[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
  1. 添加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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市幸斥,隨后出現(xiàn)的幾起案子匹摇,更是在濱河造成了極大的恐慌,老刑警劉巖甲葬,帶你破解...
    沈念sama閱讀 216,544評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件廊勃,死亡現(xiàn)場離奇詭異,居然都是意外死亡经窖,警方通過查閱死者的電腦和手機坡垫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,430評論 3 392
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來钠至,“玉大人葛虐,你說我怎么就攤上這事∶蘧” “怎么了屿脐?”我有些...
    開封第一講書人閱讀 162,764評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長宪卿。 經(jīng)常有香客問我的诵,道長,這世上最難降的妖魔是什么佑钾? 我笑而不...
    開封第一講書人閱讀 58,193評論 1 292
  • 正文 為了忘掉前任西疤,我火速辦了婚禮,結(jié)果婚禮上休溶,老公的妹妹穿的比我還像新娘代赁。我一直安慰自己扰她,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,216評論 6 388
  • 文/花漫 我一把揭開白布芭碍。 她就那樣靜靜地躺著,像睡著了一般瞻讽。 火紅的嫁衣襯著肌膚如雪鸳吸。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,182評論 1 299
  • 那天速勇,我揣著相機與錄音晌砾,去河邊找鬼贡羔。 笑死,一個胖子當(dāng)著我的面吹牛个初,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播磅轻,決...
    沈念sama閱讀 40,063評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼珍逸,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了聋溜?” 一聲冷哼從身側(cè)響起谆膳,我...
    開封第一講書人閱讀 38,917評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎撮躁,沒想到半個月后漱病,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,329評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡把曼,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,543評論 2 332
  • 正文 我和宋清朗相戀三年杨帽,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片嗤军。...
    茶點故事閱讀 39,722評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡注盈,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出叙赚,到底是詐尸還是另有隱情老客,我是刑警寧澤僚饭,帶...
    沈念sama閱讀 35,425評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站胧砰,受9級特大地震影響鳍鸵,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜朴则,卻給世界環(huán)境...
    茶點故事閱讀 41,019評論 3 326
  • 文/蒙蒙 一权纤、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧乌妒,春花似錦汹想、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,671評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽辨液。三九已至辛孵,卻和暖如春敷矫,著一層夾襖步出監(jiān)牢的瞬間舞丛,已是汗流浹背踢故。 一陣腳步聲響...
    開封第一講書人閱讀 32,825評論 1 269
  • 我被黑心中介騙來泰國打工延柠, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留嗤栓,地道東北人佑刷。 一個月前我還...
    沈念sama閱讀 47,729評論 2 368
  • 正文 我出身青樓忘闻,卻偏偏與公主長得像钝计,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子齐佳,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,614評論 2 353

推薦閱讀更多精彩內(nèi)容