CentOS7的基本配置

1、修改主机名
[root@localhost ~]# cat /etc/hostname
localhost.localdomain
[root@localhost ~]# hostnamectl set-hostname server28.example.com
[root@localhost ~]# cat /etc/hostname
server28.example.com
注:在centos7中主机名的信息存储在/etc/hostname中,而不再是/etc/sysconfig/network

2、启动/关闭/重启/查看服务(systemctl start/stop/restart/status services)
[root@localhost ~]# systemctl start firewalld 启动防火墙
[root@localhost ~]# systemctl stop firewalld 关闭防火墙
[root@localhost ~]# systemctl restart firewalld 重启防火墙
[root@localhost ~]# systemctl status firewalld 查看防火墙状态
[root@localhost ~]# systemctl list-unit-files 查看系统所有服务的状态
3、设置服务的自启动
[root@localhost ~]# systemctl enable sshd 设置sshd开机自动
[root@localhost ~]# systemctl disable sshd 设置sshd不开机自启

4、进入紧急/图形/单用户/拯救模式
[root@localhost ~]# systemctl isolate
emergency.targer graphical.target multi-user.target rescue.target

5、关机/重启
[root@localhost ~]# systemctl halt 关机
[root@localhost ~]# systemctl reboot 重启

猜你喜欢

转载自blog.51cto.com/11293100/2545005