Centos7系统中使用到的一些命令和其他版本的linux命令有所不同,所以我在这里记录一下我在工作中使用过的Centos7命令。

1.虚拟机搭建比较简单,只是需要在选择网络的时候注意选择为桥接模式就好了

Centos7虚拟光驱:

链接:https://pan.baidu.com/s/1I9qQPwRn_ku1YUD2NtoFVw 
提取码:5b9c 
2.搭建好之后需要一些常用的软件安装:

sudo yum install net-tools  #用来管理和排查各种网络配置
yum install -y lrzsz        #一款在linux里可代替ftp上传和下载的程序
yum install -y vim          #(编辑器工具软件,可选)
yum -y install wget         #wget 是一个从网络上自动下载文件的自由工具
yum install -y unzip zip    #压缩和解压

3.防火墙的一些命令:

1、firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
 
那怎么开启一个端口呢
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent

4.Centos7命令变化

1、service -> systemctl命令
systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

CentOS 6 service命令与CentOS 7 systemctl 命令
以httpd 为例:
任务 旧指令 新指令
---------------------------------------------------------------------------------------------------------------------------------------------
使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.service
使某服务不自动启动         chkconfig --level 3 httpd off systemctl disable httpd.service
检查服务状态 service httpd status systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务         service httpd start systemctl start httpd.service
停止某服务         service httpd stop systemctl stop httpd.service
重启某服务         service httpd restart systemctl restart httpd.service
2、ifconfig -> ip 命令
CentOS 7最小化系统,使用“ipaddr”和“ip link”命令来查找网卡详情。要知道统计数据,可以使用“ip -s link”

3、netstat -> ss命令

ss命令用来显示处于活动状态的套接字信息。ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息,而且比netstat更快速更高效。

4、route -> ip route命令

5.安装java环境与tomcat

yum install java-1.8.0-openjdk-devel.x86_64
tomcat地址:
链接:https://pan.baidu.com/s/1K99Fp2849ojmMtGTUKWpYA 
提取码:d9pv
解压tomcat
修改bin目录下shell的文件权限:chmod u+x ./*.sh

6.创建shell脚本

1.创建shell脚本
touch xxx.sh
2.编辑shell脚本
vi xxx.sh
#!/bin/sh        shell脚本第一行必须这样写
sudo yum install net-tools
yum install -y lrzsz
yum install -y vim
yum -y install wget
yum install -y unzip zip
cd /etc/
echo '{"abc":"xxx"}' >ss.json    #切换到etc目录下,创建一个ss.json文件,并写入json字符串
echo "xxxxxxx" >>ss.json         #把xxxxxxxxx追加到ss.json文件后面