rpm命令管理软件包需要手动解决包之间的依赖关系
命令格式:rpm 选项... 软件包全名
常用选项:
#挂载镜像文件 [root@localhost /]# mount /dev/cdrom /centos/ mount: /dev/sr0 写保护,将以只读方式挂载 #安装vsftpd服务(此服务无依赖) [root@localhost ~]# rpm -q vsftpd 未安装软件包 vsftpd [root@localhost ~]# rpm -ivh /centos/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm 警告:/centos/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:vsftpd-3.0.2-22.el7 ################################# [100%] [root@localhost ~]# [root@localhost ~]# rpm -q vsftpd vsftpd-3.0.2-22.el7.x86_64 [root@localhost ~]# [root@localhost ~]# rpm -qa |grep vsftpd vsftpd-3.0.2-22.el7.x86_64 [root@localhost ~]# #查询vsftpd的安装位置 [root@localhost ~]# rpm -ql vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd_conf_migrate.sh /usr/lib/systemd/system-generators/vsftpd-generator /usr/lib/systemd/system/vsftpd.service /usr/lib/systemd/system/vsftpd.target /usr/lib/systemd/system/vsftpd@.service /usr/sbin/vsftpd /usr/share/doc/vsftpd-3.0.2 /usr/share/doc/vsftpd-3.0.2/AUDIT /usr/share/doc/vsftpd-3.0.2/BENCHMARKS /usr/share/doc/vsftpd-3.0.2/BUGS /usr/share/doc/vsftpd-3.0.2/COPYING /usr/share/doc/vsftpd-3.0.2/Changelog /usr/share/doc/vsftpd-3.0.2/EXAMPLE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow /usr/share/doc/vsftpd-3.0.2/EXAMPLE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2 /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README /usr/share/doc/vsftpd-3.0.2/FAQ /usr/share/doc/vsftpd-3.0.2/INSTALL /usr/share/doc/vsftpd-3.0.2/LICENSE /usr/share/doc/vsftpd-3.0.2/README /usr/share/doc/vsftpd-3.0.2/README.security /usr/share/doc/vsftpd-3.0.2/REWARD /usr/share/doc/vsftpd-3.0.2/SECURITY /usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN /usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION /usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW /usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST /usr/share/doc/vsftpd-3.0.2/SIZE /usr/share/doc/vsftpd-3.0.2/SPEED /usr/share/doc/vsftpd-3.0.2/TODO /usr/share/doc/vsftpd-3.0.2/TUNING /usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd /usr/share/man/man5/vsftpd.conf.5.gz /usr/share/man/man8/vsftpd.8.gz /var/ftp /var/ftp/pub #查询vsftpd的详细信息 [root@localhost ~]# rpm -qi vsftpd Name : vsftpd Version : 3.0.2 Release : 22.el7 Architecture: x86_64 Install Date: 2022年08月20日 星期六 00时26分42秒 Group : System Environment/Daemons Size : 356236 License : GPLv2 with exceptions Signature : RSA/SHA256, 2017年08月11日 星期五 04时17分26秒, Key ID 24c6a8a7f4a80eb5 Source RPM : vsftpd-3.0.2-22.el7.src.rpm Build Date : 2017年08月03日 星期四 14时10分20秒 Build Host : c1bm.rdu2.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : https://security.appspot.com/vsftpd.html Summary : Very Secure Ftp Daemon Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch. [root@localhost ~]# #查看ls文件由那个软件包产生 [root@localhost ~]# rpm -qf /usr/bin/ls coreutils-8.22-21.el7.x86_64 [root@localhost ~]#
yum软件仓库:提供众多软件包的仓库,自动解决软件包之间复杂的依赖关系
yum常用命令
本地yum源配置
[root@localhost ~]# cat /etc/yum.repos.d/local.repo [local] #仓库名称,名称自定义,但具有唯一性 name=local #仓库描述 baseurl=file:///centos #指定软件仓库地址,file://用于指定本地软件包存放位置 enabled=1 #软件仓库是否启动,1启动,0不启动 gpgcheck=0 #是否检测软件包签名,0不检测,1检测 [root@localhost ~]# #检测仓库可用性 [root@localhost ~]# yum repolist 已加载插件:fastestmirror, langpacks Determining fastest mirrors local | 3.6 kB 00:00:00 (1/2): local/group_gz | 166 kB 00:00:00 (2/2): local/primary_db | 3.1 MB 00:00:00 源标识 源名称 状态 local local 3,971 repolist: 3,971 [root@localhost ~]#
网络yum源配置
#阿里源配置 [root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 664 100 664 0 0 992 0 --:--:-- --:--:-- --:--:-- 992 [root@localhost yum.repos.d]# cat epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=http://mirrors.aliyun.com/epel/7/$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=0 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source baseurl=http://mirrors.aliyun.com/epel/7/SRPMS failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=0 [root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2523 100 2523 0 0 7901 0 --:--:-- --:--:-- --:--:-- 7884 [root@localhost yum.repos.d]# yum clean 已加载插件:fastestmirror, langpacks 错误:清理命令需要参数:headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all [root@localhost yum.repos.d]# yum clean all 已加载插件:fastestmirror, langpacks 正在清理软件源: base epel extras local updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors #生成缓存 [root@localhost yum.repos.d]# yum makecache 已加载插件:fastestmirror, langpacks Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 local | 3.6 kB 00:00:00 updates | 2.9 kB 00:00:00 base/7/x86_64/primary_db FAILED http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error" 正在尝试其它镜像。 (1/20): epel/x86_64/group_gz | 97 kB 00:00:00 (2/20): base/7/x86_64/group_gz | 153 kB 00:00:00 (3/20): epel/x86_64/updateinfo | 1.0 MB 00:00:01 (4/20): epel/x86_64/prestodelta | 332 B 00:00:00 (5/20): base/7/x86_64/other_db | 2.6 MB 00:00:04 (6/20): epel/x86_64/primary_db | 7.0 MB 00:00:12 (7/20): extras/7/x86_64/primary_db | 247 kB 00:00:00 (8/20): extras/7/x86_64/other_db | 148 kB 00:00:00 (9/20): local/group_gz | 166 kB 00:00:00 (10/20): local/filelists_db | 3.1 MB 00:00:00 (11/20): local/primary_db | 3.1 MB 00:00:00 (12/20): local/other_db | 1.3 MB 00:00:00 base/7/x86_64/filelists_db FAILED s | 33 MB 00:00:24 ETA http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 正在尝试其它镜像。 (13/20): epel/x86_64/other_db | 3.4 MB 00:00:06 (14/20): epel/x86_64/filelists_db | 12 MB 00:00:22 (15/20): updates/7/x86_64/other_db | 1.1 MB 00:00:02 (16/20): base/7/x86_64/primary_db | 6.1 MB 00:00:10 (17/20): base/7/x86_64/filelists_db | 7.2 MB 00:00:12 extras/7/x86_64/filelists_db FAILED s | 57 MB 00:00:13 ETA http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/ceff3d07ce71906c0f0372ad5b4e82ba2220030949b032d7e63b7afd39d6258e-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 正在尝试其它镜像。 (18/20): extras/7/x86_64/filelists_db | 277 kB 00:00:00 updates/7/x86_64/filelists_db FAILED s | 58 MB 00:00:13 ETA http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/d821157a06efe1d225c819283a0cd00d4fdeabb5bba66b537cf0428940c0f771-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" 正在尝试其它镜像。 (19/20): updates/7/x86_64/primary_db | 17 MB 00:00:31 (20/20): updates/7/x86_64/filelists_db | 9.4 MB 00:00:17 元数据缓存已建立 [root@localhost yum.repos.d]#
-a 显示所有端口信息
-n 以数字格式显示端口号
-t 显示TCP连接的端口
-u 显示UDP连接的端口
-l 显示服务正在监听的端口信息
-p 显示监听端口的服务名称
#查看ssh服务端口信息 [root@localhost yum.repos.d]# ss -anptul |grep ssh tcp LISTEN 0 128 127.0.0.1:6012 *:* users:(("sshd",pid=14968,fd=9)) tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=1308,fd=3)) tcp LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",pid=13813,fd=9)) tcp LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",pid=14804,fd=9)) tcp LISTEN 0 128 ::1:6012 :::* users:(("sshd",pid=14968,fd=8)) tcp LISTEN 0 128 :::22 :::* users:(("sshd",pid=1308,fd=4)) tcp LISTEN 0 128 ::1:6010 :::* users:(("sshd",pid=13813,fd=8)) tcp LISTEN 0 128 ::1:6011 :::* users:(("sshd",pid=14804,fd=8)) [root@localhost yum.repos.d]#
[root@localhost ~]# cat /etc/yum.repos.d/local.repo [local] name=local baseurl=file:///centos enabled=1 gpgcheck=0 priority=1 #优先级为1-99之间,数字越小越优先 [root@localhost ~]#
systemd是内核第一个加在的进程(pid=1),systemd负责整个liunx系统的运行与服务控制,systemd为用户提供了systemctl来管理rpm包安装的服务,如:启动,关闭,查看服务状态,服务随机自启
服务的启动有两个阶段,一是系统开机是随着系统的启动而启动(随机自启),二是系统启动以后用户手动将服务启动
常用命令:
#查看防火墙的服务状态 [root@localhost yum.repos.d]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: inactive (dead) since 三 2022-08-24 07:34:51 CST; 6h left Docs: man:firewalld(1) Process: 944 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) Main PID: 944 (code=exited, status=0/SUCCESS) 8月 24 07:22:40 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... 8月 24 07:22:41 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. 8月 24 07:34:50 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon... 8月 24 07:34:51 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon. [root@localhost yum.repos.d]# #启动防火墙并重启防火墙 [root@localhost yum.repos.d]# systemctl start firewalld.service [root@localhost yum.repos.d]# systemctl restart firewalld.service #停止防火墙 [root@localhost yum.repos.d]# systemctl stop firewalld.service #设置随机自启 [root@localhost yum.repos.d]# systemctl enable firewalld.service #设置不随机启动 [root@localhost yum.repos.d]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. #查看服务是否随机自启 [root@localhost yum.repos.d]# systemctl is-enabled firewalld.service disabled [root@localhost yum.repos.d]#