Linux常见配置
防火墙配置
1、查看服务状态
[root@CentOS ~]# 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 五 2020-07-17 12:50:46 CST; 10s ago
Docs: man:firewalld(1)
Main PID: 8352 (firewalld)
CGroup: /system.slice/firewalld.service
└─8352 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
7月 17 12:50:46 CentOS systemd[1]: Starting firewalld - dynamic firewall d.....
7月 17 12:50:46 CentOS systemd[1]: Started firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
2、查看防火墙状态
[root@CentOS ~]# firewall-cmd --state
running
3、关闭防火墙服务
[root@CentOS ~]# systemctl stop firewalld
关闭使用
start
指令即可
4、关闭防火墙开机自启动
[root@CentOS ~]# systemctl disable firewalld
开机使用
systemctl enable firewalld
IP地址配置信息
1、查看IP信息
在配置网络之前我们先要知道centos的网卡名称是什么,CentoS7不再使用ifconfig命令,可通过命令 IP Addr查看.
[root@CentOS ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ab:c7:54 brd ff:ff:ff:ff:ff:ff
inet 192.168.52.137/24 brd 192.168.52.255 scope global noprefixroute dynamic ens33
valid_lft 1195sec preferred_lft 1195sec
inet6 fe80::ebc:2617:583c:edfb/64 scope link noprefixroute
valid_lft forever preferred_lft forever
2、重启网络服务
[root@CentOS ~]# systemctl restart network
主机名修改
1、修改主机名配置文件,并且重启系统
[root@CentOS ~]# vi /etc/hostname
CentOS
Linux资源配置
linux资源限制配置文件是/etc/security/limits.conf;限制用户进程的数量对于linux系统的稳定性非常重要。limits.conf文件限制着用户可以使用的最大文件数,最大线程,最大内存等资源使用量。
[root@CentOS ~]# vi /etc/security/limits.conf
* soft nofile 204800 #任何用户可以打开的最大文件IO数
* hard nofile 204800
* soft nproc 204800 # #任何用户可以打开的最大进程数
* hard nproc 204800
soft是一个警告值,而hard则是一个真正意义的阀值,超过就会报错
配置IP映射关系
[root@CentOS ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.52.134 CentOS