查看路由 |
route -n |
ip route / ip r |
查看ip地址 |
ifconfig |
ip address / ip a |
查看端口信息 |
netstat -anlt |
ss -ltna |
服务管理 |
service sshd restart / start / stop |
systemctl restart / start / stop sshd |
服务自启动查看 |
chkconfig –list |
systemctl list-units –type=service |
服务自启动关闭 |
chkconfig sshd off |
systemctl disable sshd |
服务自启动开启 |
chkconfig sshd on |
systemctl enable sshd |
系统启动级别 |
vi /etc/inittab |
systemctl set-default runlevel3.target |
主机名 |
vi /etc/sysconfig/network |
vi /etc/hostname / hostnamectl |
字符集 |
vi /etc/sysconfig/i18n |
vi /etc/locale.conf / localectl |
默认文件系统 |
ext4 |
xfs |
默认mysql |
mysql |
mariadb |
防火墙 |
iptables |
firewalld |
防火墙允许ip |
iptables -A INPUT -s x.x.x.x -j ACCEPT |
firewall-cmd –add-source=x.x.x.x |
防火墙允许port |
iptables -A INPUT -p tcp –dport xx -j ACCEPT |
firewall-cmd –add-port=xx/tcp |
查看防火墙 |
iptables -nL |
firewall-cmd –list-all / iptables -nL |
时区 |
vi /etc/sysconfig/clock |
timedatectl |
查看时间列表 |
ls -l /usr/share/zoneinfo/ |
timedatectl list-timezones |
设置时区 |
echo ‘ZONE=”Asia/Tokyo”‘> /etc/sysconfig/clock |
timedatectl set-timezone “Asia/xxx” |
单用户模式 |
开机在kernel版本的菜单,按e,再在kernel一行的最后加上空格single |
开机在kernel版本的菜单,按e,再在linux 16的那一行,把ro改成 “rw init=/sysroot/bin/sh”. 完成之后按 “Ctrl+x”进入单用户模式。; chroot /sysroot/; passwd root; touch / .autorelabel(如果有开selinux,必须touch这个文件) |