Linux常用系统管理命令
-
netstat-
-n或--numeric直接使用IP地址,而不通过域名服务器。 -
-t或--tcp显示TCP传输协议的连线状况。 -
-u或--udp显示UDP传输协议的连线状况。 -
-l或--listening显示监控中的服务器的Socket。 -
-p或--programs显示正在使用Socket的程序识别码和程序名称;-
netstat -ntulp查看开放了哪些端口 -
netstat -a显示详细网络状况 -
netstat -nu查看当前活跃UDP连接状况 -
netstat -apu显示UDP端口号使用情况 -
netstat -i显示网卡列表 -
netstat -g显示组播组的关系 -
netstat -s显示网络统计信息 -
netstat -l显示监听的套接字接口
-
-
-
lsof -i:80显示与指定端口相关的网络信息
lsof -i 用以显示符合条件的进程情况
lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 --> IPv4 or IPv6
protocol --> TCP or UDP
hostname --> Internet host name
hostaddr --> IPv4地址
service --> /etc/service中的 service name (可以不止一个)
port --> 端口号 (可以不止一个)
-
lsof -i 显示所有打开的端口
-
lsof -i:80显示所有打开80端口的进程 -
lsof -i -U 显示所有打开的端口和UNIX domain文件
服务管理:
-
service ngix start-
service apache2 start启动服务 -
service apache2 restart重启服务 -
service apache2 stop停止服务 -
service apache2 reload重新加载配置文件(不终止服务) -
service apache2 status查看服务状态
-
-
systemctlsystemd是linux系统中最新的初始化系统(init),systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。
-
systemctl start ngix.service启动服务 -
systemctl restart mysql重启服务 -
systemctl stop mysql停止服务 -
systemctl reload apache2重新加载配置文件(不终止服务) -
systemctl status apache2查看服务状态 -
systemctl enable mysql开机自动启动 -
systemctl disable mysql开机不自动启动 -
systemctl is-enabled apache2查看特定服务是否为开机自动启动 -
systemctl list-unit-files --type=service查看各个级别下服务的启动与禁用情况
-
-
/etc/ini.d/ngix startinit.d目录包含许多系统各种服务的启动和停止脚本。为了能够使用init.d目录下的脚本,需要有root权限或sudo权限。每个脚本都将被作为一个命令运行,该命令的结构大致如下:/etc/init.d/command 选项command是实际运行的命令,选项有如下几种:
startstopreloadrestartforce-reload
例子:
-
关闭网络
/etc/init.d/networking stop -
改变网络设置,需要重启网络
/etc/init.d/networking restart -
init.d目录下常用初始化脚本- networking
- samba
- apache2
- ftpd
- sshd
- dovecot
- mysql
理解Linux系统/etc/init.d目录和/etc/rc.local脚本
-
ps
ps aux可以查看系统中所有的进程ps -le可以查看系统中所有的进程,而且还能看到进程的父进程的PID和进程的优先级ps -l只能看到当前Shell产生的进程
本文介绍了Linux系统中常用的网络管理命令如netstat和lsof的使用方法,并详细阐述了如何利用service和systemctl进行服务的启动、重启、停止及状态检查等操作。
9544

被折叠的 条评论
为什么被折叠?



