Linux基础-软件仓库/服务管理/守护进程

2022/1/30 7:12:32

本文主要是介绍Linux基础-软件仓库/服务管理/守护进程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

linux软件仓库

软件仓库的名称叫yum/ dnf   

红帽系列操作系统软件仓库位置在  /etc/yum.repos.d/

 

配置软件仓库两种方法:

已知软件仓库的基础url位置  自己编辑配置文件  (考试考这个)

[root@rhel8-server yum.repos.d]# vim  /etc/yum.repos.d/rhel_dvd.repo

 

[baseos]

name = Red Hat Enterprise Linux 8.2 BaseOS

baseurl = http://content.example.com/rhel8.2/x86-64/dvd/BaseOS

enabled = 0

gpgcheck = 1

gpgkey = http://content.example.com/rhel8.2/gpgkey-base

 

[appstream]

name = Red Hat Enterprise Linux 8.2 AppStream

baseurl = http://content.example.com/rhel8.2/x86_64/dvd/AppStream

enabled = 0

gpgcheck = 1

gpgkey =  http://content.example.com/rhel8.2/gpgkey-base

 

直接从各大网站现有提供软件仓库配置文件,直接下载即可 

curl -o /etc/yum.repos.d/CentOS-Base.repo  HYPERLINK "https://mirrors.aliyun.com/repo/Centos-8.repo" https://mirrors.aliyun.com/repo/Centos-8.repo

 

接下来需要先清除历史软件仓库缓存

[root@rhel8-server yum.repos.d]# yum clean all 

Updating Subscription Management repositories.

Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

0 files removed

 

接下来需要建立新[root@rhel8-server yum.repos.d]# yum repolist all

Updating Subscription Management repositories.

Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

CentOS-8 - AppStream - mirrors.aliyun.com                         3.0 MB/s | 8.4 MB     00:02    

CentOS-8 - Base - mirrors.aliyun.com                              1.3 MB/s | 4.6 MB     00:03    

CentOS-8 - Extras - mirrors.aliyun.com                            4.7 kB/s |  10 kB     00:02    

Last metadata expiration check: 0:00:01 ago on Wed 12 Jan 2022 02:00:30 PM CST.

repo id                   repo name                                                 status

AppStream                 CentOS-8 - AppStream - mirrors.aliyun.com                 enabled: 5,596

PowerTools                CentOS-8 - PowerTools - mirrors.aliyun.com                disabled

appstream                 Red Hat Enterprise Linux 8.2 AppStream                    disabled

base                      CentOS-8 - Base - mirrors.aliyun.com                      enabled: 1,896

baseos                    Red Hat Enterprise Linux 8.2 BaseOS                       disabled

centosplus                CentOS-8 - Plus - mirrors.aliyun.com                      disabled

extras                    CentOS-8 - Extras - mirrors.aliyun.com                    enabled:    38仓库缓存

 

 

 

注意: EPEL (Extra Packages for Enterprise Linux) 为红帽系操作系统提供了额外的软件包

yum  install -y  epel-release

 

 

关于软件的安装  更新  卸载    软件查找

yum  install  -y  httpd      软件仓库安装httpd

yum update httpd        软件仓库更新httpd

yum remove   -y   httpd   卸载httpd

 

yum list  httpd    软件仓库查找叫httpd的软件列表

yum list  installed   软件仓库查询已经下载的软件列表

yum info  httpd    软件仓库查询已经安装的httpd软件信息

yum history        软件仓库历史命令

yum history info 4   查找软件仓库历史命令4谁干的 干了什么

yum list            显示所有软件仓库可安装的软件

yum list |grep locate  显示所有软件仓库可安装的软件查找名字叫locate的

yum search locate      软件仓库中去搜寻名字带有locate的软件

yum provides   /etc/ssh/sshd_config    软件仓库中查找 哪个软件提供了这个配置文件的功能

yum provides ifconfig    软件仓库查找谁提供了命令  ifconfig

yum provides pstree     软件仓库查找谁提供了命令  pstree

yum search gnome      软件仓库搜索带有桌面功能的软件

yum groupinfo   "gnome"    查找软件包租 桌面这个功能一共要安装多少软件

 

软件包组的安装:

yum gourp install gnome  -y    通过软件包组,直接安装整个桌面的需要的所有软件包

 

 

 

 

 

 

 

关于软件仓库本身的更新

yum update         更新最新的软件仓库目录,如果有新的软件加入软件仓库,不执行这个命令就来安装,有可能会显示这个软件找不到。一般在安装最新的有些工具的时候,需要先yum update完成软件仓库本身的更新

因为我们系统属于未注册  yum update --allowerasing   允许擦除不兼容的部分  防止多个软件之间冲突

 

 

rpm:  用来安装软件包

rpm  -i  安装

rpm   -v    查看详细信息

rpm   -e   删除移除

rpm   -U  升级

 

首先可以下载qq for linux版本   

wget   https://down.qq.com/qqweb/LinuxQQ/linuxqq_2.0.0-b2-1089_x86_64.rpm  

rpm  -i   linuxqq_2.0.0-b2-1089_x86_64.rpm  

rpm -e  linuxqq  卸载qqfor linux 

 

服务管理和守护进程

systemd守护进程   会伴随着linux系统启动。在系统引导的时候,守护进程会激活系统资源启动。

在红帽系中。systemd守护进程的pid是1  

systemd提供了:激活进程和自动启动服务

有以下服务单元:

service      .service       定义系统服务

target        .target         模拟运行级别

device        .device        定义内核识别的设备

mount        .mount        挂载的文件

socket         .socket        标识进程间的通信

swap           .swap            管理swap设备

automount    .automount    实现文件开机自动挂载

path              .path        定义文件系统目录路径

 

 

systemctl list-units  --type=service    列出所有的service的模块

UNIT:服务单元名称

LOAD: systemd是否正确解析了单元的配置,并将该单元加载到内存中

ACTIVE:单元的高级别激活,此信息表明是否成功启动

SUB:单元的低级别激活状态  ,以单元的方式在执行的

DES:描述  

 

 

target systemctl   系统运行级别管理

graphical.target   系统支持多用户,多图形化和文本的登录

multi-user.target    系统支持多用户,基于文本的登录

rescue.target      系统初始化   需要root登录

emergency.target     只读挂载文件系统   需要用root登录    

 

systemctl  get-defaut     查看当前系统的默认运行级别

systemctl  set-default    multi-user.target  将系统运行级别设置为基于文本登录的方式

 

紧急模式下,我们不能对系统做任何操作,那怎么回复正常模式呢?

首先重新启动

然后把光标移到需要启动的内核(第一个)

然后按e进行编辑

然后移动到linux开头的行  在末尾输入

systemd.unit=graphical.target

然后ctrl +  x

就可以正常开机了

注意:这只是打断了当前本次开机进程  

此时你的默认target还是emergency

所以尽快修改为graphical.target

 

服务管理:

systemctl start name.service

启动服务

systemctl stop name.service

停止服务

systemctl restart name.service

重启服务(没启动的服务会启动)

systemctl try-restart name.service

只重启正在运行的服务

systemctl reload name.service

重载配置文件

systemctl status name.service systemctl is-active name.service

检查服务状态检查服务是否启动

systemctl list-units --type service --all

显示所有的服务状态

systemctl enable name.service

启用开机自启服务

systemctl disable name.service

停用自启服务

systemctl status name.service systemctl is-enabled name.service

检查服务状态查看服务是否自启

systemctl list-unit-files --type service

查看所有服务

systemctl list-dependencies --after

列出在指定服务之前启动的服务(依赖)

systemctl list-dependencies --before

列出在指定服务之后启动的服务(被依赖

 

 

服务屏蔽 为了防止系统之间服务冲突,所以可以屏蔽某些服务,防止别人意外启动

systemctl mask 服务名      屏蔽某个服务

systemctl unmask  服务名   取消屏蔽服务

 

说明:disable 的服务是可以手动启动的,因为他只是不让开机启动,

mask的服务,是没法手动启动的,更不会开机启动

 



这篇关于Linux基础-软件仓库/服务管理/守护进程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程