linux 命令
1、linux用netstat查看服务及监听端口
centos 如果没有 使用 yum install net-tools 安装
[root@localhost ~]# netstat -nlp
netstat命令各个参数说明如下:
-t : 指明显示TCP端口
-u : 指明显示UDP端口
-l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)
-p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序。
-n : 不进行DNS轮询(可以加速操作)
即可显示当前服务器上所有端口及进程服务,于grep结合可查看某个具体端口及服务情况··
[root@localhost ~]# netstat -nlp |grep LISTEN //查看当前所有监听端口·
[root@localhost ~]# netstat -nlp |grep 80 //查看所有80端口使用情况·
[root@localhost ~]# netstat -an | grep 3306 //查看所有3306端口使用情况·
lsof
lsof(list open files)是一个列出当前系统打开文件的工具。
netstat -anp |grep 3306
netstat -an 查看网络端口
lsof -i :port,使用lsof -i :port就能看见所指定端口运行的程序,同时还有当前连接。
2、看磁盘空间大小命令
df -h Df命令是linux系统以磁盘分区为单位查看文件系统,可以加上参数查看磁盘剩余空间信息,
df -hl 查看磁盘剩余空间
df -h 查看每个根路径的分区大小
du -sh [目录名] 返回该目录的大小
du -sm [文件夹] 返回该文件夹总M数
du -h [目录名] 查看指定文件夹下的所有文件大小(包含子文件夹)
更多功能可以输入一下命令查看:
df --help
du --help
3、查看CPU
转自:http://www.jb51.net/article/97157.htm
1.1 查看CPU个数
cat /proc/cpuinfo | grep "physical id" | uniq | wc -l
2 uniq命令:删除重复行;wc –l命令:统计行数
1.2 查看CPU核数
cat /proc/cpuinfo | grep "cpu cores" | uniq
cpu cores : 4
1.3 查看CPU型号
cat /proc/cpuinfo | grep 'model name' |uniq
model name : Intel(R) Xeon(R) CPU E5630 @ 2.53GHz
总结:该服务器有2个4核CPU,型号Intel® Xeon® CPU E5630 @ 2.53GHz
2 查看内存
2.1 查看内存总数
cat /proc/meminfo | grep MemTotal
MemTotal: 32941268 kB //内存32G
2.2 查看内存条数
本节内容引自新浪博文《Linux查看内存条数》
查看原文:
# dmidecode |grep -A16 "Memory Device$"
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB //1条2G内存
Form Factor: DIMM
Set: 1
Locator: DIMM1
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Manufacturer: 7F7F7F7F7F510000
Serial Number: 0403E324
Asset Tag: 450721
Part Number: 72T256220HR3SA
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 2048 MB //1条2G内存
Form Factor: DIMM
Set: 1
Locator: DIMM2
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Manufacturer: 7F7F7F7F7F510000
Serial Number: 0403E324
Asset Tag: 450721
Part Number: 72T256220HR3SA
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed //1个内存空槽
Form Factor: DIMM
Set: 2
Locator: DIMM3
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: Unknown
Manufacturer:
Serial Number:
Asset Tag:
Part Number:
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed //1个内存空槽
Form Factor: DIMM
Set: 2
Locator: DIMM4
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: Unknown
Manufacturer:
Serial Number:
Asset Tag:
Part Number:
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed //1个内存空槽
Form Factor: DIMM
Set: 3
Locator: DIMM5
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: Unknown
Manufacturer:
Serial Number:
Asset Tag:
Part Number:
--
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: No Module Installed //1个内存空槽
Form Factor: DIMM
Set: 3
Locator: DIMM6
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: Unknown
Manufacturer:
Serial Number:
Asset Tag:
Part Number:
总结:该服务器有两条2G内存 ,空余4个插槽
3 查看硬盘
3.1 查看硬盘大小
fdisk -l | grep Disk
Disk /dev/cciss/c0d0: 146.7 GB, 146778685440 bytes
总结:硬盘大小146.7G,即厂商标称的160G