[root@centos ~]# nmcli connection add con-name company ifname ens160 autoconnect no type ethernet ip4 192.168.2.20/24 gw4 192.168.2.1
连接 "company"(e8d5aa3a-6b79-431e-b6de-129901166e9d) 已成功添加。
(2)、创建指定家庭使用的网络会话
[root@centos ~]# nmcli connection add con-name house type ethernet ifname ens160
连接 "house"(a6271d4d-4cc4-4cb4-8bc4-eea6a918ca42) 已成功添加。
(3)、查看网络会话
[root@centos ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 3d3dbf95-38c6-4045-92cb-0e2c12c52346 ethernet ens160
virbr0 e56d42a5-ca28-48ed-b5a5-9fa225e4fb3c bridge virbr0
company e8d5aa3a-6b79-431e-b6de-129901166e9d ethernet --
house a6271d4d-4cc4-4cb4-8bc4-eea6a918ca42 ethernet --
(4)、激活company网络会话
[root@centos ~]# nmcli connection up company
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5)
(5)、激活house网络会话
[root@centos ~]# nmcli connection up house
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/7)
(6)、删除网络会话
//删除company网络会话[root@centos ~]# nmcli connection delete company
成功删除连接 "company"(e8d5aa3a-6b79-431e-b6de-129901166e9d)。
//删除house网络会话[root@centos ~]# nmcli connection delete house
成功删除连接 "house"(a6271d4d-4cc4-4cb4-8bc4-eea6a918ca42)。
3、绑定两块网卡
(1)、创建出一个bond网卡
[root@centos ~]# nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=balance-rr"
连接 "bond0"(0fe88e8a-fdd2-4ecb-9b00-e90e5e321b2f) 已成功添加。
(2)、向bond0添加从属网卡
[root@centos ~]# nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname ens160 master bond0
连接 "bond0-port1"(e86c8dbb-21ec-487f-964f-87a13699c092) 已成功添加。
[root@centos ~]# nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname ens192 master bond0
连接 "bond0-port2"(50195351-cf26-441d-ac66-a922d00d9183) 已成功添加。
┌──(kali㉿kali)-[~]
└─$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key(/home/kali/.ssh/id_rsa)://按回车键或设置密钥的存储路径
Created directory '/home/kali/.ssh'.
Enter passphrase(empty for no passphrase)://按回车键或设置密钥的密码
Enter same passphrase again://再次按回车键或设置密钥的密码
Your identification has been saved in /home/kali/.ssh/id_rsa
Your public key has been saved in /home/kali/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ulKB+iTXu2HYj6hLkFGBLvEwKSNNknumiRNfzMkF5g8 kali@kali
The key's randomart image is:+---[RSA 3072]----+|.*+.o.||@o.o .||=B +E+||+++ Bo.||=B o ...S ||=.+ ooo.||..=..=.||. oo.=|| oo..+..|+----[SHA256]-----+
(2)、把客户机生成的公钥文件传送至服务器
┌──(kali㉿kali)-[~]
└─$ ssh-copy-id root@192.168.2.20/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:"/home/kali/.ssh/id_rsa.pub"/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO:1key(s) remain to be installed --if you are prompted now it is to install the new keys
//管理员密码
root@192.168.2.20's password:
Number of key(s) added:1
Now try logging into the machine, with:"ssh 'root@192.168.2.20'"
and check to make sure that only the key(s) you wanted were added.
(3)、对服务器设置只允许密钥验证,拒绝传统口令验证,并重启服务
//编辑文件[root@centos ~]# vim /etc/ssh/sshd_config
68 #PasswordAuthentication yes
69 #PermitEmptyPasswords no
70 PasswordAuthentication yes
//重启服务[root@centos ~]# systemctl restart sshd
(4)、客户端登录
┌──(kali㉿kali)-[~]
└─$ ssh root@192.168.2.20
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed May 317:11:322023 from 192.168.2.44[root@centos ~]#
[root@centos ~]# journalctl -n 5-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>5月 0317:45:27 centos systemd[1]: Starting Network Manager Script >5月 0317:45:27 centos dbus-daemon[981]:[system] Successfully acti>5月 0317:45:27 centos systemd[1]: Started Network Manager Script D>5月 0317:45:37 centos systemd[1]: NetworkManager-dispatcher.servic>5月 0317:51:05 centos cupsd[1158]: REQUEST localhost -- "POST / H>
6、实时刷新日志内容
[root@centos ~]# journalctl -f
-- Logs begin at Wed 2023-05-0316:48:16 CST.--5月 0317:41:03 centos systemd[1]: session-12.scope: Succeeded.5月 0317:41:03 centos systemd-logind[1105]: Session 12 logged out. Waiting for processes to exit.5月 0317:41:03 centos systemd-logind[1105]: Removed session 12.5月 0317:45:27 centos NetworkManager[1145]:<info>[1683107127.7531]dhcp6(ens160): state changed bound -> bound, address=240e:3a1:3a82:21e1:20c:29ff:fe21:f72d
7、日志分类等级
日志等级
说明介绍
emerg
系统出现严重故障,内核崩溃等情况
alert
应立即修复的故障,数据库损坏等情况
crit
危险较高的故障,硬盘损坏导致程序运行失败的情况
err
一般危险的故障,某个服务启动或运行时阿比的情况
warning
警告信息,某个服务参数或功能错误的情况
notice
一般无危险的故障,只是需要处理的情况
info
通用性消息,给用户提示一些有用信息
debug
调试程序所产生的信息
none
没有优先级,不做日志记录
8、查看危险较高的故障
[root@centos ~]# journalctl -p crit
-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>-- No entries --
9、仅查询今日的日志信息
[root@centos ~]# journalctl --since today
-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>5月 0316:48:16 centos kernel: Linux version 4.18.0-348.7.1.el8_5.x>5月 0316:48:16 centos kernel: Command line: BOOT_IMAGE=(hd0,msdos1>5月 0316:48:16 centos kernel: Disabled fast string operations
5月 0316:48:16 centos kernel: x86/fpu: Supporting XSAVE feature 0x>5月 0316:48:16 centos kernel: BIOS-provided physical RAM map:
10、查看最近一小时的日志信息
[root@centos ~]#
[root@centos ~]# journalctl --since "-1 hour"-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>5月 0317:01:25 centos dbus-daemon[2383]:[session uid=0 pid=2383]>5月 0317:10:54 centos rz[3496]:[root] no.name/ZMODEM: got error
11、查询上午8点整到10点整的日志信息
[root@centos ~]# journalctl --since "8:00"--until "12:00"-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>
12、查询指定服务的日志信息
语法格式:journalctl _SYSTEMD_UNIT=服务名称.service
[root@centos ~]# journalctl _SYSTEMD_UNIT=sshd.service
-- Logs begin at Wed 2023-05-0316:48:16 CST, end at Wed 2023-05-03>5月 0316:48:24 centos sshd[1163]: Server listening on 0.0.0.0 port>5月 0316:48:24 centos sshd[1163]: Server listening on :: port 22.5月 0317:05:55 centos sshd[3347]: Connection reset by 192.168.2.44>5月 0317:06:06 centos sshd[3349]: Connection reset by 192.168.2.44>5月 0317:06:42 centos sshd[3360]: Accepted password for root from >
1.概要
1.1可重载运算符
可重载运算符说明 x, -x, !x, ~x, , --, true, falsetrue和 false 运算符必须一起重载。 x y, x - y, x * y, x / y, x % y, x & y, x | y, x ^ y, x << y, x >> y, x >>> y x y, x ! y, x < y, x > y, x < y,…