安装CentOS 7操作系统在VMware Workstation Pro虚拟机上
root 密码 1
[root@localhost ~]#
lcoalhost 主机名
@ 连接符
root 当前登录系统用户的用户名
~ 当前用户的家目录
# 超级用户命令提示符
$ 普通用户命令提示符
1、获取IP
启动网卡 ifup ens33
关闭网卡 ifdown ens33
2、查看IP
ip a
使用WindTerm远程连接工具
在右侧会话栏单击鼠标右键新建会话
输入主机地址(虚拟机ip)
输入标签名
保存
输入用户名root
输入密码 1
命令 选项 参数
时间:
date 查看系统时间
date -s "10:56:15" 修改时间
时间的格式化输出:
date +%F 日期
date +%T 时间
date +%u 星期
同步网络时间:
cd /etc/yum.repos.d/
1、配置阿里云yum源:
https://mirrors.aliyun.com/
1.1 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
1.2 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
1.3 运行 yum makecache 生成缓存
yum makecache
2、安装ntpdate
yum install ntpdate
3、同步时间:
ntpdate time.windows.com
ntpdate ntp.aliyun.com
配置本地yum源:
curl -o tool.sh 10.35.156.250/repo/tools.sh
sh tool.sh
安装ntpdate
yum install ntpdate
同步时间:
ntpdate time.windows.com
ntpdate ntp.aliyun.com
查看主机名:hostname
修改主机名:hostnamectl set-hostname xa2404
快捷键:
登出:ctrl+d
终止:ctrl+c
清屏:ctrl+l
重启:reboot
防火墙:
查看:systemctl status firewalld (翻译:系统防火墙状态)
关闭:systemctl stop firewalld
开机不自启:systemctl disable firewalld
SELINUX:
查看:getenforce
临时关闭:setenforce 0
永久关闭:sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
网卡开机自启动:
1、安装vim
yum -y install vim
2、修改网卡配置文件:
2.1:vim /etc/sysconfig/network-scripts/ifcfg-ens33;
2.2:将光标移动至最后一个字符上;
2.3:输入键盘上的字母a;
2.4:将ONBOOT=no这一行的no改为yes;
2.5:输入键盘上的字母Esc;
2.6:输入英文冒号:
2.7:输入英文wq
2.8:回车
3、重启网卡
systemctl restart network
echo $? 返回0是成功运行,其他皆为失败
复习
远程连接:
- IP
- 查看:ip a
- 启动网卡:ifup ens33
- 192.168.83.128 (ipv4)0.0.0.0 - 255.255.255.255 42亿
fe80::cca4:7410:40b7:c5db (ipv6)
- 用户名 root
- 密码 1
- 端口 22
时间:
查看:date
修改时间:date -s”2024-8-21 09:29:29”
格式化输出:date +%F date +%T date +%u 年月 日 星期
同步网络时间:
1、ping baidu.com --判断是否连接到网络 ctrl+c停止
2、ntpdate npt.aliyun.com
ntpdate time.windows.com 同步时间
- 安装ntpdate(如果未安装,第二步失败)
yum -y install ntpdate
- curl(系统自带,下载) -o(下载到当前路径) a.sh 10.35.156.250/repo/tools.sh
sh a.sh
- yum -y install ntpdate
命令提示符:
[root@localhost ~]#
查看用户名:
hostname
修改主机名:
hostnamectl set-hostname xa2404
快捷键:
ctrl+d 登出 ctrl+c 停止 ctrl+l 清屏
防火墙:
查看:systemctl status firewalld
关闭:systemctl stop firewalld
开机不自启:systemctl disable firewalld
selinux:
getenforce 查看
Enforcing Permissive Disabled 正在执行 临时关闭 永久关闭(状态)
setenforce 0 临时关闭
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config 永久关闭
配置网卡自启动:
vi /etc/sysconfig/network-scripts/ifcfg-ens33