Linux命令细节全记录

压缩:

例如: 将wwwroot目录,全部压缩成一个名为20180816backup的备份文件

zip -r 20180816backup.zip wwwroot


查看内存使用情况:

free -mh

[root@vwhm.net]# free -mh
              total        used        free      shared  buff/cache   available
Mem:           992M        714M         85M         66M        192M         69M
Swap:            0B          0B          0B


释放内存

echo 1 > /proc/sys/vm/drop_caches

[root@vwhm.net]# echo 1 > /proc/sys/vm/drop_caches
[root@vwhm.net]# free -mh
              total        used        free      shared  buff/cache   available
Mem:           992M        714M        149M         66M        127M        102M
Swap:            0B          0B          0B


查看端口

netstat


[root@vwhm.net ~][ # netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:48818         localhost:mysql         TIME_WAIT  
tcp        0      0 izj6c90yicge6f4tqn:http 59.63.216.224:15947     ESTABLISHED
tcp        0     36 izj6c90yicge6f4tqnc:ssh 59.63.216.224:6018      ESTABLISHED
tcp        0      0 localhost:cslistener    localhost:48668         TIME_WAIT  
tcp        0      0 izj6c90yicge6f4tqnc:ssh 59.63.216.224:5530      ESTABLISHED
tcp        0      0 izj6c90yicge6f4tq:39904 106.11.228.229:http     ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    9622     /run/systemd/shutdownd
unix  2      [ ]         DGRAM                    6872     /run/systemd/notify
unix  2      [ ]         DGRAM                    6874     /run/systemd/cgroups-agent
unix  5      [ ]         DGRAM                    6891     /run/systemd/journal/socket
unix  9      [ ]         DGRAM                    6893     /dev/log
unix  3      [ ]         STREAM     CONNECTED     14631    /run/systemd/journal/stdout



读内核信息,并解释​

cat /proc/meminfo

[root@vwhm.net ~]# cat /proc/meminfo
MemTotal:        1016168 kB
MemFree:          114820 kB
MemAvailable:      82532 kB
Buffers:            7852 kB
Cached:           122732 kB
SwapCached:            0 kB
Active:           734324 kB
Inactive:          87228 kB
Active(anon):     726436 kB
Inactive(anon):    32376 kB
Active(file):       7888 kB
Inactive(file):    54852 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        691016 kB
Mapped:            68676 kB
Shmem:             67828 kB
Slab:              33380 kB
SReclaimable:      15632 kB
SUnreclaim:        17748 kB
KernelStack:        2592 kB
PageTables:        25068 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      508084 kB
Committed_AS:    1733276 kB
VmallocTotal:   34359738367 kB
VmallocUsed:        8804 kB
VmallocChunk:   34359719676 kB
HardwareCorrupted:     0 kB
AnonHugePages:     96256 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       53120 kB
DirectMap2M:      995328 kB
DirectMap1G:           0 kB


​​

MemTotal:     1016168 kB  #所有可用RAM大小 (即物理内存减去一些预留位和内核的二进制代码大小)
MemFree:      114820 kB  #LowFree与HighFree的总和,被系统留着未使用的内存
Buffers:         7852 kB  #用来给文件做缓冲大小 
Cached:         122732 kB  #被高速缓冲存储器(cache memory)用的内存的大小(等于 diskcache minus SwapCache)
SwapCached:          0 kB  #被高速缓冲存储器(cache memory)用的交换空间的大小 已经被交换出来的内存,但仍然被存放在swapfile中。用来在需要的时候很快的被替换而不需要再次打开I/O端口。
Active:        734324 kB  #在活跃使用中的缓冲或高速缓冲存储器页面文件的大小,除非非常必要否则不会被移作他用. 
Inactive:       87228 kB  #在不经常使用中的缓冲或高速缓冲存储器页面文件的大小,可能被用于其他途径.


查看内存条数

dmidecode |grep -A16 “Memory Device$”

[root@vwhm.net ~]# dmidecode |grep -A16 "Memory Device$"
Memory Device
	Array Handle: 0x1000
	Error Information Handle: Not Provided
	Total Width: Unknown
	Data Width: Unknown
	Size: 1024 MB
	Form Factor: DIMM
	Set: None
	Locator: DIMM 0
	Bank Locator: Not Specified
	Type: RAM
	Type Detail: Other
	Speed: Unknown
	Manufacturer: Alibaba Cloud
	Serial Number: Not Specified
	Asset Tag: Not Specified
	Part Number: Not Specified