网站开发专家,在家来料加工,能利用双股铜芯电话线做网站吗,于都网站建设文章目录 二、基础配置操作1、网络管理#xff08;配置静态地址并进行ssh远程连接#xff09;#xff08;1.#xff09;静态地址配置#xff08;2.#xff09;IP配置注释#xff08;3.#xff09;配置SSH远程连接 2、包管理#xff08;1.#xff09;yum软件包管理器1… 文章目录 二、基础配置操作1、网络管理配置静态地址并进行ssh远程连接1.静态地址配置2.IP配置注释3.配置SSH远程连接 2、包管理1.yum软件包管理器1. yum clean all - 清理YUM缓存和临时文件2. yum install - 安装指定的软件包及其依赖项3. yum search - 搜索指定名称或关键字的软件包列出所有相关软件包的详细信息4. yum update - 更新指定的软件包及其依赖项到最新版本5. yum remove - 卸载指定的软件包及其依赖项 2.rpm软件包管理1. rpm -qa - 列出所有已安装的RPM包2. rpm -q - 查询一个已安装的RPM包的信息3. rpm -qi - 显示一个已安装的RPM包的详细信息4. rpm -ql - 列出一个已安装的RPM包的所有文件5. rpm -qf - 查找包含特定文件的RPM包6. rpm -ivh - 安装一个RPM包7. rpm -e - 卸载一个已安装的RPM包 3、注释总结 4、权限管理用户、文本等 二、基础配置操作
1、网络管理配置静态地址并进行ssh远程连接
1.静态地址配置
ip地址的配置文件存于etc/sysconfig/network-scripts/下
[rootcentos /]# cd /etc/sysconfig/network-scripts/
[rootcentos network-scripts]# ls
ifcfg-eth0 ifdown-post ifup-aliases ifup-post init.ipv6-global
ifcfg-lo ifdown-ppp ifup-bnep ifup-ppp network-functions
ifdown ifdown-routes ifup-eth ifup-routes network-functions-ipv6
ifdown-bnep ifdown-sit ifup-ippp ifup-sit test.txt
ifdown-eth ifdown-Team ifup-ipv6 ifup-Team
ifdown-ippp ifdown-TeamPort ifup-isdn ifup-TeamPort
ifdown-ipv6 ifdown-tunnel ifup-plip ifup-tunnel
ifdown-isdn ifup ifup-plusb ifup-wireless查看一下ip地址的网口然后查看一下配置
[rootcentos network-scripts]# ip a
1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: eth0: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:16:3e:0c:2c:e6 brd ff:ff:ff:ff:ff:ffinet 172.31.79.129/20 brd 172.31.79.255 scope global dynamic eth0valid_lft 315005508sec preferred_lft 315005508secinet6 fe80::216:3eff:fe0c:2ce6/64 scope link valid_lft forever preferred_lft forever
[rootcentos network-scripts]# cat ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
# If you dont want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg
# For more information, please refer to: https://help.aliyun.com/document_detail/57803.html
#
BOOTPROTOdhcp
DEVICEeth0
ONBOOTyes
STARTMODEauto
TYPEEthernet
USERCTLno
# 注释
# ip a用于显示当前系统中所有网络接口的详细信息包括每个接口的IP地址、MAC地址、状态、以及其他配置参数 进行修改静态IP地址可以参考我另一篇centos-静态ip及修改主机名
[rootcentos network-scripts]# vi ifcfg-eth0
[rootcentos network-scripts]# systemctl restart network
[rootcentos network-scripts]# ip a
1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: eth0: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:16:3e:0c:2c:e6 brd ff:ff:ff:ff:ff:ffinet 172.31.79.129/24 brd 172.31.79.255 scope global eth0valid_lft forever preferred_lft foreverinet6 fe80::216:3eff:fe0c:2ce6/64 scope link valid_lft forever preferred_lft forever
[rootcentos network-scripts]# cat ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
# If you dont want cloud-init genrated automatically,you can disable it in /etc/cloud/cloud.cfg
# For more information, please refer to: https://help.aliyun.com/document_detail/57803.html
#
BOOTPROTOstatic
DEVICEeth0
ONBOOTyes
STARTMODEauto
TYPEEthernet
USERCTLno
IPADDR172.31.79.129
NETMASK255.255.255.0
GATEWAY172.31.79.1
DNS1202.102.227.68
DNS2202.102.224.68到此静态IP配置完成
2.IP配置注释
以下是在物理机上的IP配置中的参数注释上面的是在阿里云ECS中配置的
参数注释TYPE“Ethernet”表示这是一个使用以太网协议的网络接口PROXY_METHOD “none”指定不使用代理BROWSER_ONLY“no”表示不仅限于浏览器使用BOOTPROTO“static”指定使用静态 IP 地址配置DEFROUTE“yes”指定设置默认路由IPV4_FAILURE_FATAL“no”指定 IPv4 连接失败不会导致致命错误IPV6INIT“yes”启用 IPv6IPV6_AUTOCONF“yes”启用 IPv6 自动配置IPV6_DEFROUTE“yes”指定设置 IPv6 默认路由IPV6_FAILURE_FATAL“no”指定 IPv6 连接失败不会导致致命错误IPV6_ADDR_GEN_MODE“stable-privacy”指定使用稳定的隐私地址生成模式NAME“ens33”指定接口的名称UUID“3d078699-517f-44e9-a42c-fc38144e522d”接口的唯一标识符DEVICE“ens33”指定设备的名称ONBOOT“yes”指定在启动时激活该接口IPADDR192.168.101.101指定 IP 地址为 192.168.101.101NETMASK255.255.255.0指定网络子网掩码为 255.255.255.0GATEWAY192.168.101.1指定网关的 IP 地址为 192.168.101.1DNS1192.168.101.1指定首选 DNS 服务器的 IP 地址为 192.168.101.1DNS28.8.8.8指定备用 DNS 服务器的 IP 地址为 8.8.8.8
3.配置SSH远程连接
SSH全称为Secure Shell即安全外壳协议是一种用于在不安全的网络中提供安全通信的网络协议。
它的主要功能包括
加密传输SSH通过加密客户端和服务器之间的通信来保证数据的安全性防止数据在传输过程中被截获或篡改。 身份认证SSH允许用户通过密码或者密钥对进行身份验证确保只有授权的用户才能访问系统。 远程登录SSH最常见的用途之一是作为远程登录工具用户可以通过SSH从本地计算机登录到远程服务器上进行操作和管理。 端口转发SSH还支持端口转发这允许用户将本地端口上的连接转发到远程服务器的端口从而在需要时绕过防火墙的限制。
CentOS系统默认已经安装了SSH服务当你安装CentOS时系统会自动安装好所有必要的服务和依赖包以便用户能够进行远程登录和管理
有些特殊情况是需要安装openssh-server的
OpenSSH-server是OpenSSH项目的一部分而OpenSSH是SSH协议的免费开源实现它包括客户端和服务器两部分
查看SSH版本
[rootcentos /]# rpm -qa | grep ssh
libssh2-1.8.0-3.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssh-7.4p1-21.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
# 注释
#rpmPM代表Red Hat Package Manager它是一种软件包管理工具。RPM文件通常包含了软件的预编译二进制程序、配置文件、文档等用于在CentOS系统上安装、升级或删除软件
# rpm -qarpm -qa用于列出系统上已安装的所有软件包的名称qa代表查询
# grep用于在文本文件中搜索指定的模式字符串关闭防火墙或者方通SSH协议的22端口
# 永久关闭防火墙
[rootcentos /]# systemctl stop firewalld
[rootcentos /]# systemctl disable firewalld
# 开启防火墙
[rootcentos /]# systemctl start firewalld
[rootcentos /]# systemctl enable firewalld
# 放通22端口
[rootcentos /]# firewall-cmd --zonepublic --add-port22/tcp --permanent
success
[rootcentos /]# firewall-cmd --reload
success
# 查看防火墙方通的端口
[rootcentos /]# firewall-cmd --list-ports
22/tcp当然SElinux也是需要关闭的
SELinuxSecurity-Enhanced Linux是一个安全子系统它为Linux操作系统提供了额外的安全性层通过强制访问控制 (MAC) 来限制进程的能力以减少系统遭受内核级攻击的风险
[rootcentos /]# cat /etc/selinux/config # This file controls the state of SELinux on the system.
# SELINUX can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUXdisabled
# SELINUXTYPE can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPEtargeted查看SSH服务状态开启和关闭状态
[rootcentos /]# systemctl status sshd
● sshd.service - OpenSSH server daemonLoaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)Active: active **(running)** since Mon 2024-03-25 12:30:46 CST; 4 days agoDocs: man:sshd(8)man:sshd_config(5)Main PID: 1193 (sshd)CGroup: /system.slice/sshd.service└─1193 /usr/sbin/sshd -DMar 29 15:12:45 centos sshd[18243]: Accepted password for root from 118.31.243.250 por...sh2
Mar 29 15:12:46 centos sshd[18251]: Accepted password for root from 118.31.243.110 por...sh2
Mar 29 15:13:17 centos sshd[18315]: Accepted password for root from 118.31.243.243 por...sh2
Mar 29 15:13:18 centos sshd[18683]: Accepted password for root from 118.31.243.122 por...sh2
Mar 29 15:13:21 centos sshd[18694]: Accepted password for root from 118.31.243.252 por...sh2
Mar 29 15:13:22 centos sshd[18703]: Accepted password for root from 118.31.243.78 port...sh2
Mar 29 15:13:23 centos sshd[18712]: Accepted password for root from 118.31.243.153 por...sh2
Mar 29 15:13:26 centos sshd[18722]: Accepted password for root from 118.31.243.235 por...sh2
Mar 29 15:13:27 centos sshd[18731]: Accepted password for root from 118.31.243.19 port...sh2
Mar 29 15:13:28 centos sshd[18740]: Accepted password for root from 118.31.243.197 por...sh2
Hint: Some lines were ellipsized, use -l to show in full.
# 注释
# systemctl status用于显示系统的状态信息包括当前正在运行的服务的状态[rootcentos /]# systemctl status sshd
● sshd.service - OpenSSH server daemonLoaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)Active: inactive **(dead)** since Fri 2024-03-29 15:38:12 CST; 4s agoDocs: man:sshd(8)man:sshd_config(5)Process: 1193 ExecStart/usr/sbin/sshd -D $OPTIONS (codeexited, status0/SUCCESS)Main PID: 1193 (codeexited, status0/SUCCESS)Mar 29 15:27:24 centos sshd[19433]: Accepted password for root from 118.31.243.108 port 62066 ssh2
Mar 29 15:27:25 centos sshd[19441]: Accepted password for root from 118.31.243.180 port 42932 ssh2
Mar 29 15:28:14 centos sshd[19491]: Accepted password for root from 118.31.243.212 port 20182 ssh2
Mar 29 15:28:16 centos sshd[19500]: Accepted password for root from 118.31.243.55 port 49097 ssh2
Mar 29 15:28:17 centos sshd[19509]: Accepted password for root from 118.31.243.119 port 44536 ssh2
Mar 29 15:28:19 centos sshd[19520]: Accepted password for root from 118.31.243.3 port 47648 ssh2
Mar 29 15:28:20 centos sshd[19530]: Accepted password for root from 118.31.243.154 port 2575 ssh2
Mar 29 15:28:21 centos sshd[19539]: Accepted password for root from 118.31.243.35 port 49280 ssh2
Mar 29 15:38:12 centos systemd[1]: Stopping OpenSSH server daemon...
Mar 29 15:38:12 centos systemd[1]: Stopped OpenSSH server daemon.需要修改SSH配置的可以在/etc/sysconfig/sshd下修改
[rootcentos /]# cat /etc/sysconfig/sshd
# Configuration file for the sshd service.# The server keys are automatically generated if they are missing.
# To change the automatic creation uncomment and change the appropriate
# line. Accepted key types are: DSA RSA ECDSA ED25519.
# The default is RSA ECDSA ED25519# AUTOCREATE_SERVER_KEYS
# AUTOCREATE_SERVER_KEYSRSA ECDSA ED25519# Do not change this option unless you have hardware random
# generator and you REALLY know what you are doingSSH_USE_STRONG_RNG0
# SSH_USE_STRONG_RNG1阿里云ECS和物理机的配置是不一样的还是要看现场实际情况的
2、包管理
1.yum软件包管理器
在CentOS中yum是一个软件包管理器用于安装、升级、删除和管理系统中的软件包
它可以从预配置的软件存储库中获取软件包并自动解决依赖关系
yum还可以快速、方便地安装所需的软件、更新系统以及管理软件包
在CentOS 8及更新版本中“dnf” 已经成为了yum的替代者但是在很多系统中yum命令仍然可用
1. yum clean all - 清理YUM缓存和临时文件
[rootcentos /]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates2. yum install - 安装指定的软件包及其依赖项
这里以ntp时间同步服务举例 从安装到启动
# yum安装ntp服务
[rootcentos /]# yum install -y ntp
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(3/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(4/7): epel/x86_64/group_gz | 100 kB 00:00:00
(5/7): epel/x86_64/primary_db | 7.0 MB 00:00:00
(6/7): extras/7/x86_64/primary_db | 254 kB 00:00:00
(7/7): updates/7/x86_64/primary_db | 26 MB 00:00:00
Resolving Dependencies
-- Running transaction check
--- Package ntp.x86_64 0:4.2.6p5-29.el7.centos.2 will be installed
-- Processing Dependency: ntpdate 4.2.6p5-29.el7.centos.2 for package: ntp-4.2.6p5-29.el7.centos.2.x86_64
-- Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-29.el7.centos.2.x86_64
-- Running transaction check
--- Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
--- Package ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2 will be installed
-- Finished Dependency ResolutionDependencies ResolvedPackage Arch Version Repository SizeInstalling:ntp x86_64 4.2.6p5-29.el7.centos.2 base 549 k
Installing for dependencies:autogen-libopts x86_64 5.18-5.el7 base 66 kntpdate x86_64 4.2.6p5-29.el7.centos.2 base 87 kTransaction SummaryInstall 1 Package (2 Dependent packages)Total download size: 701 k
Installed size: 1.6 M
Downloading packages:
(1/3): ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm | 549 kB 00:00:00
(2/3): ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm | 87 kB 00:00:00
(3/3): autogen-libopts-5.18-5.el7.x86_64.rpm | 66 kB 00:00:00
--------------------------------------------------------------------------------------------
Total 3.9 MB/s | 701 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : autogen-libopts-5.18-5.el7.x86_64 1/3 Installing : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 2/3 Installing : ntp-4.2.6p5-29.el7.centos.2.x86_64 3/3
warning: /etc/ntp.conf created as /etc/ntp.conf.rpmnewVerifying : ntpdate-4.2.6p5-29.el7.centos.2.x86_64 1/3 Verifying : ntp-4.2.6p5-29.el7.centos.2.x86_64 2/3 Verifying : autogen-libopts-5.18-5.el7.x86_64 3/3 Installed:ntp.x86_64 0:4.2.6p5-29.el7.centos.2 Dependency Installed:autogen-libopts.x86_64 0:5.18-5.el7 ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2 Complete!# systemctl三连启动开机自启查看状态
[rootcentos /]# systemctl start ntpd
[rootcentos /]# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
[rootcentos /]# systemctl status ntpd
● ntpd.service - Network Time ServiceLoaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)Active: active (running) since Fri 2024-03-29 16:16:45 CST; 13s agoMain PID: 22650 (ntpd)CGroup: /system.slice/ntpd.service└─22650 /usr/sbin/ntpd -u ntp:ntp -gMar 29 16:16:45 centos systemd[1]: Starting Network Time Service...
Mar 29 16:16:45 centos systemd[1]: Started Network Time Service.
Mar 29 16:16:45 centos ntpd[22650]: proto: precision 0.044 usec
Mar 29 16:16:45 centos ntpd[22650]: 0.0.0.0 c01d 0d kern kernel time sync enabled3. yum search - 搜索指定名称或关键字的软件包列出所有相关软件包的详细信息
这里以sshd服务为例
[rootcentos /]# yum search sshd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfileMatched: sshd
fail2ban.noarch : Daemon to ban hosts that cause multiple authentication errors
gsi-openssh-server.x86_64 : SSH server daemon with GSI authentication
jsch.noarch : Pure Java implementation of SSH2
libnss-mysql.x86_64 : NSS library for MySQL
openssh-server.x86_64 : An open source SSH server daemon4. yum update - 更新指定的软件包及其依赖项到最新版本
# 查看可用于更新的软件包
[rootcentos /]# yum check-update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfileNetworkManager.x86_64 1:1.18.8-2.el7_9 updates
NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9 updates
NetworkManager-team.x86_64 1:1.18.8-2.el7_9 updates
NetworkManager-tui.x86_64 1:1.18.8-2.el7_9 updates# 更新zlib到最新版本
[rootcentos /]# yum update zlib
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
-- Running transaction check
--- Package zlib.x86_64 0:1.2.7-18.el7 will be updated
--- Package zlib.x86_64 0:1.2.7-21.el7_9 will be an update
-- Finished Dependency ResolutionDependencies ResolvedPackage Arch Version Repository SizeUpdating:zlib x86_64 1.2.7-21.el7_9 updates 90 kTransaction SummaryUpgrade 1 PackageTotal download size: 90 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
zlib-1.2.7-21.el7_9.x86_64.rpm | 90 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionUpdating : zlib-1.2.7-21.el7_9.x86_64 1/2 Cleanup : zlib-1.2.7-18.el7.x86_64 2/2 Verifying : zlib-1.2.7-21.el7_9.x86_64 1/2 Verifying : zlib-1.2.7-18.el7.x86_64 2/2 Updated:zlib.x86_64 0:1.2.7-21.el7_9 Complete!5. yum remove - 卸载指定的软件包及其依赖项
这里还是以ntp为例
[rootcentos /]# yum remove ntp
Loaded plugins: fastestmirror
Resolving Dependencies
-- Running transaction check
--- Package ntp.x86_64 0:4.2.6p5-29.el7.centos.2 will be erased
-- Finished Dependency ResolutionDependencies ResolvedPackage Arch Version Repository SizeRemoving:ntp x86_64 4.2.6p5-29.el7.centos.2 base 1.4 MTransaction SummaryRemove 1 PackageInstalled size: 1.4 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionErasing : ntp-4.2.6p5-29.el7.centos.2.x86_64 1/1
warning: /etc/ntp.conf saved as /etc/ntp.conf.rpmsaveVerifying : ntp-4.2.6p5-29.el7.centos.2.x86_64 1/1 Removed:ntp.x86_64 0:4.2.6p5-29.el7.centos.2 Complete!2.rpm软件包管理
在CentOS中“rpm代表Red Hat Package Manager”它是一个用于在Red Hat系统和基于Red Hat的发行版如CentOS中安装、升级和管理软件包的命令行工具
rpm可以通过预编译的二进制软件包文件后缀为.rpm来安装软件并提供了一系列选项和参数来管理系统中的软件包例如查询、升级、卸载等操作
1. rpm -qa - 列出所有已安装的RPM包
[rootcentos /]# rpm -qa
kbd-1.15.5-15.el7.x86_64
setup-2.8.71-11.el7.noarch
ncurses-base-5.9-14.20130511.el7_4.noarch
parted-3.1-32.el7.x86_64
nspr-4.21.0-1.el7.x86_64
bash-4.2.46-34.el7.x86_64
iwl6050-firmware-41.28.5.1-76.el7.noarch
iwl2030-firmware-18.168.6.1-76.el7.noarch
libuuid-2.23.2-63.el7.x86_64
iwl135-firmware-18.168.6.1-76.el7.noarch
chkconfig-1.7.4-1.el7.x86_64
iwl105-firmware-18.168.6.1-76.el7.noarch这里只列出一小部分的rpm包
2. rpm -q - 查询一个已安装的RPM包的信息
[rootcentos /]# rpm -q bash
bash-4.2.46-34.el7.x86_643. rpm -qi - 显示一个已安装的RPM包的详细信息
[rootcentos /]# rpm -qi bash
Name : bash
Version : 4.2.46
Release : 34.el7
Architecture: x86_64
Install Date: Mon 14 Sep 2020 03:14:34 PM CST
Group : System Environment/Shells
Size : 3667724
License : GPLv3
Signature : RSA/SHA256, Sat 04 Apr 2020 04:49:07 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : bash-4.2.46-34.el7.src.rpm
Build Date : Wed 01 Apr 2020 10:19:58 AM CST
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem http://bugs.centos.org
Vendor : CentOS
URL : http://www.gnu.org/software/bash
Summary : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.4. rpm -ql - 列出一个已安装的RPM包的所有文件
[rootcentos /]# rpm -ql bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/alias
/usr/bin/bash
/usr/bin/bashbug
/usr/bin/bashbug-64
/usr/bin/bg
/usr/bin/cd
/usr/bin/command
/usr/bin/fc
/usr/bin/fg
/usr/bin/getopts
/usr/bin/jobs
/usr/bin/read
/usr/bin/sh5. rpm -qf - 查找包含特定文件的RPM包
# 只列出rpm包名称
[rootcentos /]# rpm -qf /bin/ls
coreutils-8.22-24.el7.x86_64# 列出 /usr/bin/ 目录下每个文件的提供软件包
[rootcentos /]# rpm -qf /usr/bin/*
coreutils-8.22-24.el7.x86_64
python3-devel-3.6.8-13.el7.x86_64
python3-devel-3.6.8-13.el7.x86_64
perl-5.16.3-295.el7.x86_64
binutils-2.27-43.base.el7_8.1.x86_64
bash-4.2.46-34.el7.x86_64
man-db-2.6.3-11.el7.x86_64
binutils-2.27-43.base.el7_8.1.x86_64
coreutils-8.22-24.el7.x86_64
binutils-2.27-43.base.el7_8.1.x86_646. rpm -ivh - 安装一个RPM包
# 首先下载nginx的rpm包可以wget直接下载可以连接外网的情况下否则只能现在有网的电脑上下载然后cp到这台主机上
[rootcentos ~]# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
--2024-03-29 18:20:52-- http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:5c0:2601::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4680 (4.6K) [application/x-redhat-package-manager]
Saving to: ‘nginx-release-centos-7-0.el7.ngx.noarch.rpm’100%[] 4,680 --.-K/s in 0s 2024-03-29 18:20:54 (382 MB/s) - ‘nginx-release-centos-7-0.el7.ngx.noarch.rpm’ saved [4680/4680][rootcentos ~]# ls
nginx-release-centos-7-0.el7.ngx.noarch.rpm ntpsec-1.2.3 ntpsec-1.2.3.tar.gz# 进行安装下载好的nginx.rpm包
[rootcentos ~]# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
warning: nginx-release-centos-7-0.el7.ngx.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...1:nginx-release-centos-7-0.el7.ngx ################################# [100%]
# 注释nginx-release-centos-7-0.el7.ngx.noarch.rpm 是一个用于安装NGINX的官方存储库配置包。它将NGINX的官方存储库添加到您的CentOS系统中以便您可以使用yum或dnf来安装NGINX并获得自动更新。当安装 nginx-release-centos-7-0.el7.ngx.noarch.rpm 后系统将接受NGINX官方存储库的签名并使系统能够通过yum或dnf来安装NGINX软件包# 安装nginx
[rootcentos ~]# yum install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
-- Running transaction check
--- Package nginx.x86_64 1:1.24.0-1.el7.ngx will be installed
-- Finished Dependency ResolutionDependencies ResolvedPackage Arch Version Repository SizeInstalling:nginx x86_64 1:1.24.0-1.el7.ngx nginx 804 kTransaction SummaryInstall 1 PackageTotal download size: 804 k
Installed size: 2.8 M
Is this ok [y/d/N]: y
Downloading packages:
nginx-1.24.0-1.el7.ngx.x86_64.rpm | 804 kB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : 1:nginx-1.24.0-1.el7.ngx.x86_64 1/1
----------------------------------------------------------------------Thanks for using nginx!Please find the official documentation for nginx here:
* https://nginx.org/en/docs/Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* https://nginx.org/en/support.htmlCommercial subscriptions for nginx are available on:
* https://nginx.com/products/----------------------------------------------------------------------Verifying : 1:nginx-1.24.0-1.el7.ngx.x86_64 1/1 Installed:nginx.x86_64 1:1.24.0-1.el7.ngx Complete!# systemctl四连启动自启状态停止
[rootcentos ~]# systemctl start nginx
[rootcentos ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[rootcentos ~]# systemctl status nginx
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since Fri 2024-03-29 21:14:47 CST; 14s agoDocs: http://nginx.org/en/docs/Main PID: 7276 (nginx)CGroup: /system.slice/nginx.service├─7276 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf├─7277 nginx: worker process└─7278 nginx: worker processMar 29 21:14:47 centos systemd[1]: Starting nginx - high performance web server...
Mar 29 21:14:47 centos systemd[1]: Started nginx - high performance web server.
[rootcentos ~]# systemctl stop nginx
[rootcentos ~]# systemctl status nginx
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: inactive (dead) since Fri 2024-03-29 21:15:10 CST; 2s agoDocs: http://nginx.org/en/docs/Process: 7400 ExecStop/bin/sh -c /bin/kill -s TERM $(/bin/cat /var/run/nginx.pid) (codeexited, status0/SUCCESS)Main PID: 7276 (codeexited, status0/SUCCESS)Mar 29 21:14:47 centos systemd[1]: Starting nginx - high performance web server...
Mar 29 21:14:47 centos systemd[1]: Started nginx - high performance web server.
Mar 29 21:15:10 centos systemd[1]: Stopping nginx - high performance web server...
Mar 29 21:15:10 centos systemd[1]: Stopped nginx - high performance web server.7. rpm -e - 卸载一个已安装的RPM包
[rootcentos ~]# rpm -e nginx
[rootcentos ~]# rpm -qa | grep nginx
nginx-release-centos-7-0.el7.ngx.noarch
[rootcentos ~]# systemctl status nginx
Unit nginx.service could not be found.3、注释总结 文章目录 二、基础配置操作1、网络管理配置静态地址并进行ssh远程连接1.静态地址配置2.IP配置注释3.配置SSH远程连接 2、包管理1.yum软件包管理器1. yum clean all - 清理YUM缓存和临时文件2. yum install - 安装指定的软件包及其依赖项3. yum search - 搜索指定名称或关键字的软件包列出所有相关软件包的详细信息4. yum update - 更新指定的软件包及其依赖项到最新版本5. yum remove - 卸载指定的软件包及其依赖项 2.rpm软件包管理1. rpm -qa - 列出所有已安装的RPM包2. rpm -q - 查询一个已安装的RPM包的信息3. rpm -qi - 显示一个已安装的RPM包的详细信息4. rpm -ql - 列出一个已安装的RPM包的所有文件5. rpm -qf - 查找包含特定文件的RPM包6. rpm -ivh - 安装一个RPM包7. rpm -e - 卸载一个已安装的RPM包 3、注释总结 4、权限管理用户、文本等 4、权限管理用户、文本等
ip a用于显示当前系统中所有网络接口的详细信息包括每个接口的IP地址、MAC地址、状态、以及其他配置参数cat用于查看文本文件内容vi是一种编辑工具一般自带与系统之中有的系统是systemctl stop停止运行服务systemctl restart重新启动服务systemctl start启动服务systemctl disable永久关闭服务systemctl enable开机自启服务rpmPM代表Red Hat Package Manager它是一种软件包管理工具。RPM文件通常包含了软件的预编译二进制程序、配置文件、文档等用于在CentOS系统上安装、升级或删除软件rpm -qa用于列出系统上已安装的所有软件包的名称qa代表查询grep用于在文本文件中搜索指定的模式字符串systemctl status用于显示系统的状态信息包括当前正在运行的服务的状态TYPE“Ethernet”表示这是一个使用以太网协议的网络接口PROXY_METHOD “none”指定不使用代理BROWSER_ONLY“no”表示不仅限于浏览器使用BOOTPROTO“static”指定使用静态 IP 地址配置DEFROUTE“yes”指定设置默认路由IPV4_FAILURE_FATAL“no”指定 IPv4 连接失败不会导致致命错误IPV6INIT“yes”启用 IPv6IPV6_AUTOCONF“yes”启用 IPv6 自动配置IPV6_DEFROUTE“yes”指定设置 IPv6 默认路由IPV6_FAILURE_FATAL“no”指定 IPv6 连接失败不会导致致命错误IPV6_ADDR_GEN_MODE“stable-privacy”指定使用稳定的隐私地址生成模式NAME“ens33”指定接口的名称UUID“3d078699-517f-44e9-a42c-fc38144e522d”接口的唯一标识符DEVICE“ens33”指定设备的名称ONBOOT“yes”指定在启动时激活该接口IPADDR192.168.101.101指定 IP 地址为 192.168.101.101NETMASK255.255.255.0指定网络子网掩码为 255.255.255.0GATEWAY192.168.101.1指定网关的 IP 地址为 192.168.101.1DNS1192.168.101.1指定首选 DNS 服务器的 IP 地址为 192.168.101.1DNS28.8.8.8指定备用 DNS 服务器的 IP 地址为 8.8.8.8