记录学习云计算第二天

1、查看ip地址

ifup ens33  开启网卡
ifdown ens33  关闭网卡

网卡开机启动:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
输入: i  进入编辑模式
将   ONBOOT=no  改为   ONBOOT=yes
按 esc[键盘左上角]  退出编辑模式
输入: :wq  保存并退出
 

查看windows IP:ipconfig

查看Linux IP:ifconfig(需要安装)/ ip a

# 重启网卡,使上面的配置生效
[root@localhost ~]# systemctl restart network

systemctl {start/stop/restart/enable/disable} network

2、命令提示符

[root@localhost ~]#

root指的是当前所登陆的用户

localhost指的是本机的主机名

~ 代表当前所在的目录

#  当前登录的用户为超级管理员 root

$ 当前登陆的用户是非root用户

3、远程连接工具的使用

WindTerm、Xshell、FinaShell

4、时间管理

# 查看当前服务器时间
[root@localhost ~]# date
[root@localhost ~]# date -R


# 修改系统时间
[root@localhost ~]# date -s '2023-12-12 23:10:12'
Tue Dec 12 23:10:12 CST 2023

# 查看硬件时间[bios时间]
[root@localhost ~]# hwclock -r

# 修改硬件时间
[root@localhost ~]# hwclock --set --date '2022-11-11 11:11:11'
[root@localhost ~]# hwclock -r
Fri 11 Nov 2022 11:11:15 AM CST  -0.628665 seconds

# 判断服务器是否能连接网络
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (110.242.68.3) 56(84) bytes of data.
64 bytes from www.baidu.com (110.242.68.3): icmp_seq=1 ttl=54 time=21.2 ms
64 bytes from www.baidu.com (110.242.68.3): icmp_seq=2 ttl=54 time=21.4 ms
64 bytes from www.baidu.com (110.242.68.3): icmp_seq=3 ttl=54 time=21.3 ms
64 bytes from www.baidu.com (110.242.68.3): icmp_seq=4 ttl=54 time=21.1 ms
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3028ms
rtt min/avg/max/mdev = 21.119/21.288/21.419/0.209 ms

# 终止命令 ctrl + c

安装阿里yum源

# 切换到/etc/yum.repos.d/目录下
[root@localhost ~]# cd /etc/yum.repos.d/
# 删除当前目录中所有的文件
[root@localhost yum.repos.d]# rm -rf *
# 下载阿里云的yum源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 安装ntpdate服务
[root@localhost ~]# yum install ntpdate -y 

# 时间同步[同步网络时间至系统时间]
[root@localhost ~]# ntpdate time.windows.com

# 将系统时间同步至硬件时间
[root@localhost ~]# hwclock --systohc

# 将硬件时间同步至系统时间
[root@localhost ~]# hwclock --hctosys

# 将硬件时间写入到主板中
[root@localhost ~]# hwclock -w

国内网络时间服务器域名
阿里云ntp.aliyun.com
微软time.windows.com
中国国家授时中心ntp.ntsc.ac.cn

5、关闭防火墙

# 查看防火墙状态
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2024-03-13 16:01:44 CST; 1s ago
     Docs: man:firewalld(1)
 Main PID: 15430 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─15430 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Mar 13 16:01:43 bogon systemd[1]: Starting firewalld - dynamic firewall daemon...
Mar 13 16:01:44 bogon systemd[1]: Started firewalld - dynamic firewall daemon.
Mar 13 16:01:44 bogon firewalld[15430]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be ...g it now.
Hint: Some lines were ellipsized, use -l to show in full.
# 关闭系统防火墙
[root@localhost ~]# systemctl stop firewalld

# 再次查看防火墙状态
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Oct 17 20:02:19 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 17 20:02:24 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Oct 17 20:02:24 localhost.localdomain firewalld[838]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option... it now.
Oct 17 20:04:38 bogon systemd[1]: Stopping firewalld - dynamic firewall daemon...
Oct 17 20:04:43 bogon systemd[1]: Stopped firewalld - dynamic firewall daemon.
Mar 13 16:01:43 bogon systemd[1]: Starting firewalld - dynamic firewall daemon...
Mar 13 16:01:44 bogon systemd[1]: Started firewalld - dynamic firewall daemon.
Mar 13 16:01:44 bogon firewalld[15430]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be ...g it now.
Mar 13 16:02:38 bogon systemd[1]: Stopping firewalld - dynamic firewall daemon...
Mar 13 16:02:42 bogon systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.

# 重启服务器
[root@localhost ~]# reboot
# 查看防火墙状态
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2024-03-13 16:01:44 CST; 1s ago
     Docs: man:firewalld(1)
 Main PID: 15430 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─15430 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Mar 13 16:01:43 bogon systemd[1]: Starting firewalld - dynamic firewall daemon...
Mar 13 16:01:44 bogon systemd[1]: Started firewalld - dynamic firewall daemon.
Mar 13 16:01:44 bogon firewalld[15430]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be ...g it now.
Hint: Some lines were ellipsized, use -l to show in full.

# 关闭防火墙的开机自启
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

6、关闭Selinux

SElinux,管理文件上下文
安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统。
SELinux 主要由美国国家安全局开发。2.6 及以上版本的 Linux 内核都已经集成了 SELinux 模块。


# 查看SELinux状态
[root@localhost ~]# getenforce 
Enforcing

# 临时关闭SELinux
[root@localhost ~]# setenforce 0

# 临时开启SELinux
[root@localhost ~]# setenforce 1

# 查看SELinux状态
[root@localhost ~]# getenforce 
Permissive

# 永久关闭SELinux
[root@localhost ~]# vi /etc/selinux/config
……
#     enforcing - SELinux security policy is enforced.  # 在 Enforcing 模式中, SELinux 被启动,并强制执行所有的安全策略规则。
#     permissive - SELinux prints warnings instead of enforcing.  # 在 Permissive 模式中,SELinux 被启用,但安全策略规则并没有被强制执行。
#     disabled - No SELinux policy is loaded. # 在 Disable 模式中,SELinux 被关闭,默认的 DAC 访问控制方式被使用。
SELINUX=enforcing
……
修改为
SELINUX=disabled

# 永久关闭SElinux只有重启服务器才会生效,所以在不重启服务器的情况下,我们修改完配置文件之后还需要执行"setenforce 0",先临时关闭Selinux

# 重启服务器
[root@localhost ~]# reboot
# 查看SELinux状态
[root@localhost ~]# getenforce 
Disabled

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值