最近在使用CentOS 7,发现很多命令等和CentOS 6不一样,所以这里列出来方便参考。
一、网卡、配置静态IP
二、常用的systemctl命令
CentOS 7开始使用systemd来代替init 系统父进程,因此熟练systemctl很有必要。
| CentOS 7 | CentOS 6 | 作用 |
| systemctl start sshd.service | service sshd start | 启动ssh服务 |
| systemctl stop sshd.service | service sshd stop | 停止ssh服务 |
| systemctl restart sshd.service | service sshd restart | 重启ssh服务 |
| systemctl status sshd.service | service sshd status | 查看ssh服务状态 |
| systemctl reload sshd.service | service sshd reload | 重新加载ssh服务 |
| systemctl enable sshd.service | chkconfig --level 3 sshd on | 开机自启动ssh服务 |
| systemctl disable sshd.service | chkconfig --level 3 sshd off | 开机禁止启动ssh服务 |
| systemctl list-unit-files --type=service | chkconfig --list | 列出所有的服务状态 |
| systemctl list-units | chkconfig --list、ntsysv | 列出允许中的服务单元 |
| systemctl is-active sshd.service | chkconfig --list sshd | 查看ssh服务是否运行 |
| systemctl mask sshd.service | 屏蔽(不能启用)ssh服务 | |
| systemctl unmask sshd.service | 解放屏蔽ssh服务 | |
| systemctl show sshd.service | 显示SSH服务的配置信息 | |
| systemctl get-default | 获取当前使用的运行等级 |
| systemctl set-default runlevel3.target | vi /etc/inittab | 修改默认的运行等级 |
| systemctl isolate runlevel3.target | init 3 | 启用运行等级3 |
三、配置文件
1、启动配置
centos6:修改/etc/inittab
centos7:systemctl set-default runlevel3.target
2、修改主机名
centos6:修改/etc/sysconfig/network
centos7:修改/etc/hostname
3、网卡信息
4、开启启动文件/etc/rc.d/rc.local
centos6:不需要任何修改
centos7:chmod +x /etc/rc.d/rc.local
5、默认防火墙
centos6:iptables
centos7:firewall
6、文件方式启动服务
centos6:/etc/rc.d/rc3.d/ 修改K开头的文件为S
centos7:/usr/lib/systemd/system/下的某服务做一条软连接到/etc/systemd/system目录下
7、路由转发
centos6:编辑/etc/sysctl.conf 添加 net.ipv4.ip_forward = 1或者echo “1” > /proc/sys/net/ipv4/ip_forward
centos7:编辑/etc/sysctl.conf 添加 net.ipv4.ip_forward = 1或者echo “1” > /proc/sys/net/ipv4/ip_forward
编辑/usr/lib/sysctl.d/50-default.conf 添加 net.ipv4.ip_forward = 1
8、语言设置
centos6:vim /etc/sysconfig/i18n 修改 LANG="zh_CN.UTF-8"
centos7:localectl set-locale LANG=zh_CN.UTF-8
沒有留言:
張貼留言