热门标签 | HotTags
当前位置:  开发笔记 > 运维 > 正文

Linux系统基本管理

实验环境为Centos7.91、自建yum仓库,分别为网络源和本地源1)网络源[root@OurLab~]#vimetcyum.repos.dCentos-7.repo[base]

实验环境为Centos 7.9


1、自建yum仓库,分别为网络源和本地源

1)网络源

[root@OurLab ~]# vim /etc/yum.repos.d/Centos-7.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/

​ 验证

[root@OurLab ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
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 498
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,543
repolist: 17,134

2)本地源

​ 选择光盘镜像作为本地源,挂载光盘镜像

[root@OurLab ~]# mount /dev/cdrom /mnt/cdrom/
mount: /dev/sr0 is write-protected, mounting read-only

​ 编辑repo文件

[root@OurLab ~]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1

​ 验证

[root@OurLab ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
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 498
local local 4,021
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,543
repolist: 17,134

2、编译安装http2.4,实现可以正常访问

1).下载http 2.4

​ 进入https://httpd.apache.org/download.cgi,下载http2.4


2).查看是否安装http

[root@OurLab ~]# rpm -qa | grep http
httpd-tools-2.4.6-93.el7.centos.x86_64
http-parser-2.7.1-8.el7_7.2.x86_64
httpd-2.4.6-93.el7.centos.x86_64

​ 卸载http

[root@OurLab ~]# yum remove httpd httpd-tools http-parser

3).源码包安装环境依赖的包

yum install apr-devel apr-util-devel openssl-devel pcre-devel gcc -y

4).解包

[root@OurLab data]# ls
httpd-2.4.48.tar.bz2
[root@OurLab data]# tar -jxvf httpd-2.4.48.tar.bz2

5).编译安装httpd

[root@OurLab httpd-2.4.48]# ./configure --prefix=/usr/local/httpd24 --syscOnfdir=/etc/httpd/ --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[root@OurLab httpd-2.4.48]# make && make install

6).配置环境变量,启动httpd服务

[root@OurLab httpd-2.4.48]# cd /usr/local/httpd24/bin/
[root@OurLab bin]# echo 'PATH=$PATH:/usr/local/httpd24/bin' > /etc/profile.d/httpd.sh
[root@OurLab bin]# . /etc/profile.d/httpd.sh
[root@OurLab bin]# apachectl start
[root@OurLab bin]# curl 127.0.0.1
It works!

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@OurLab bin]# ifconfig ens33 | sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)##gp'
192.168.1.59

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

[root@OurLab bin]# cat /etc/fstab |sed -r 's/^#\ ?(.*)//'|sed '/^$/d'
/etc/fstab
Created by anaconda on Fri May 17 05:52:23 2019
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
/dev/mapper/centos-root / xfs defaults 0 0
UUID=89dbf7a6-b689-4b3b-9a2e-2c56613dcecf /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0

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

目录名

[root@OurLab bin]# ls -d /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@@p'
/etc

基名

[root@OurLab bin]# ls -d /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@@p'
fstab

6、列出ubuntu软件管理工具apt的一些用法(以vim软件包为例)

1).安装软件包

gw@node2:~$ sudo apt-get install vim -y
Reading package lists... Done
Building dependency tree
......

2).卸载软件包

gw@node2:~$ sudo apt-get remove vim -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
......

3).更新软件包列表

gw@node2:~$ sudo apt-get update
0% [Connecting to mirrors.aliyun.com]
......

4).升级有可用更新的系统(慎用)

gw@node2:~$ sudo apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
......

5).搜索

gw@node2:~$ apt search vim
Sorting... Done
Full Text Search... Done
acr/bionic,bionic 1.2-1 all
autoconf like tool
......

6).获取包信息

gw@node2:~$ apt show vim
Package: vim
Version: 2:8.0.1453-1ubuntu1.4
Priority: optional
Section: editors
......

7).了解使用依赖

gw@node2:~$ apt depends vim
vim
Depends: vim-common (= 2:8.0.1453-1ubuntu1.4)
Depends: vim-runtime (= 2:8.0.1453-1ubuntu1.4)
Depends: libacl1 (>= 2.2.51-8)
......

8).查看被那些包依赖

gw@node2:~$ apt-cache rdepends vim
vim
Reverse Depends:
byobu
vim-athena
vim-gtk
vim-gtk3
......

9).安装相关的编译环境

gw@node2:~$ sudo apt-get build-dep vim
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
......

10).下载源代码

gw@node2:~$ apt-get source vim
Reading package lists... Done
NOTICE: 'vim' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/vim-team/vim.git
......

11).清理无用包

gw@node2:~$ sudo apt-get clean
gw@node2:~$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done

12).检查是否有损坏的依赖

gw@node2:~$ sudo apt-get check
Reading package lists... Done
Building dependency tree
Reading state information... Done


推荐阅读
  • 本文介绍了在CentOS 6.4系统中更新源地址的方法,包括备份现有源文件、下载163源、修改文件名、更新列表和系统,并提供了相应的命令。 ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • 本文介绍了使用CentOS7.0 U盘刻录工具进行安装的详细步骤,包括使用USBWriter工具刻录ISO文件到USB驱动器、格式化USB磁盘、设置启动顺序等。通过本文的指导,用户可以轻松地使用U盘安装CentOS7.0操作系统。 ... [详细]
  • 在CentOS/RHEL 7/6,Fedora 27/26/25上安装JAVA 9的步骤和方法
    本文介绍了在CentOS/RHEL 7/6,Fedora 27/26/25上安装JAVA 9的详细步骤和方法。首先需要下载最新的Java SE Development Kit 9发行版,然后按照给出的Shell命令行方式进行安装。详细的步骤和方法请参考正文内容。 ... [详细]
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • mac php错误日志配置方法及错误级别修改
    本文介绍了在mac环境下配置php错误日志的方法,包括修改php.ini文件和httpd.conf文件的操作步骤。同时还介绍了如何修改错误级别,以及相应的错误级别参考链接。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 本文介绍了在Linux系统中设置文件ACL权限的方法和使用说明,包括在centos7.3和centos6.9中开启ACL权限的两种方法:在挂载时指定打开ACL权限和修改默认的属性信息。同时提供了对ACL权限的详细解释和应用场景。 ... [详细]
  • Vagrant虚拟化工具的安装和使用教程
    本文介绍了Vagrant虚拟化工具的安装和使用教程。首先介绍了安装virtualBox和Vagrant的步骤。然后详细说明了Vagrant的安装和使用方法,包括如何检查安装是否成功。最后介绍了下载虚拟机镜像的步骤,以及Vagrant镜像网站的相关信息。 ... [详细]
  • Linux下安装依赖包版本高解决方法
    本文介绍了在Linux系统下,当已安装的依赖包版本高于需要安装的依赖包版本时,解决方法包括欺骗安装程序和修改相关配置文件等操作。针对不同情况,提供了不同的解决方案。 ... [详细]
  • centos安装Mysql的方法及步骤详解
    本文介绍了centos安装Mysql的两种方式:rpm方式和绿色方式安装,详细介绍了安装所需的软件包以及安装过程中的注意事项,包括检查是否安装成功的方法。通过本文,读者可以了解到在centos系统上如何正确安装Mysql。 ... [详细]
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
  • Centos7搭建ELK(Elasticsearch、Logstash、Kibana)教程及注意事项
    本文介绍了在Centos7上搭建ELK(Elasticsearch、Logstash、Kibana)的详细步骤,包括下载安装包、安装Elasticsearch、创建用户、修改配置文件等。同时提供了使用华为镜像站下载安装包的方法,并强调了保证版本一致的重要性。 ... [详细]
  • Linux下安装免费杀毒软件ClamAV及使用方法
    本文介绍了在Linux系统下安装免费杀毒软件ClamAV的方法,并提供了使用该软件更新病毒库和进行病毒扫描的指令参数。同时还提供了官方安装文档和下载地址。 ... [详细]
author-avatar
幸福taishanvv_660
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有