在linux这个最睿智的系统里面,她的指令名可不是随意取的,都是经过精雕细琢的。今天讲一讲ls大家族的指令。若你的系统里面没有下文提到的命令,比如lsscsi 请执行yum whatprovides */lsscsi ,然后自己根据执行结果进行安装。
ls
首先肯定得讲到开山始祖(跟该隐一样)ls,这个命令大家都非常熟悉,就只稍微介绍一下小技巧了。
只显示目录 不显示文件
[root@di ~]# ls -l |grep ^d
drwxr-xr-x 9 mysql games 4096 Apr 9 11:04 leanote
drwxr-xr-x 2 root root 4096 Apr 9 16:33 scripts
按文件大小排序
[root@di ~]# ls -Shl
total 70M
-rw-r--r-- 1 root root 54M Jul 14 17:47 0714.tar.gz
-rw-r--r-- 1 root root 7.9M Jul 2 15:34 wordpress-4.5.3-zh_CN.tar.gz
-rw-r--r-- 1 root root 2.8M May 13 09:05 bak_2016-05-13.sql
-rw-r--r-- 1 root root 2.5M Jul 10 14:44 0710.sql
-rw-r--r-- 1 root root 2.3M Jul 14 17:46 0714.sql
drwxr-xr-x 9 mysql games 4.0K Apr 9 11:04 leanote
drwxr-xr-x 2 root root 4.0K Apr 9 16:33 scripts
by the way 中windows毒太深的同学,linux里面有个dir命令,和ls功能一样。
lscpu
指令的名字很直观,查看CPU信息的
[root@MySQL ~]# lscpu
Architecture: i686 #架构686
CPU(s): 12 #逻辑cpu
Thread(s) per core: 1 #每个核心线程数
Core(s) per socket: 6 #每个物理cpu核数
CPU socket(s): 2 #cpu插槽数
Vendor ID: GenuineIntel #cpu厂商ID是GenuineIntel
CPU family: 6 #cpu系列是6
Model: 23 #型号23
model name: Intel(R) microprocessor C4004 @ 740KHz
Stepping: 10 #步进是10
CPU MHz: 800.000 #cpu主频是800MHz
Virtualization: VT-x #cpu支持的虚拟化技术VT-x
L1d cache: 32K #一级缓存32K(google了下,这具体表示表示cpu的L1数据缓存为32k)
L1i cache: 32K #一级缓存32K(具体为L1指令缓存为32K)
L2 cache: 3072K #二级缓存3072K
lsblk
指令的名字很直观,查看块设备信息的
[root@MySQL ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 100M 0 part /boot
├─sda2 8:2 0 1G 0 part [SWAP]
└─sda3 8:3 0 464.7G 0 part /
lsusb
指令的名字很直观,查看USB信息的
[root@MySQL ~]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
lsscsi
指令的名字很直观,查看scsi设备信息的 (包括sata,fc,sas,scsi等)
[root@MySQL ~]# lsscsi
[0:0:0:0] disk ATA WDC WD5000AAKX-0 15.0 /dev/sda
lsattr
指令的名字很直观,查看文件扩展属性信息的(比如你遇到莫名其妙不能删除的文件的时候)
[root@MySQL ~]# lsattr date.log
----i--------e- date.log
lsmod
指令的名字很直观,查看当前系统已加载模块信息的(记得配合grep使用)
[root@di ~]# lsmod
Module Size Used by
iptable_filter 2173 0
ip_tables 9567 1 iptable_filter
tcp_diag 693 0
inet_diag 7334 1 tcp_diag
xenfs 4360 1
microcode 12248 0
xen_netfront 15574 0
i2c_piix4 11156 0
i2c_core 25632 1 i2c_piix4
ext4 335478 1
jbd2 76054 1 ext4
mbcache 6017 1 ext4
xen_blkfront 13842 2
pata_acpi 2513 0
ata_generic 2805 0
ata_piix 20861 0
dm_mirror 11969 0
dm_region_hash 9644 1 dm_mirror
dm_log 8322 2 dm_mirror,dm_region_hash
dm_mod 70099 2 dm_mirror,dm_log
lsof
指令的名字很直观,查看当前系统打开的所有文件
常见用法,查看80端口连接情况
[root@di ~]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
AliYunDun 2964 root 10u IPv4 5810642 0t0 TCP hqidi.com:48616->110.75.102.62:http (ESTABLISHED)
nginx 12203 www 5u IPv4 5814666 0t0 TCP hqidi.com:http->124.14.47.69:53695 (ESTABLISHED)
nginx 12203 www 6u IPv4 1917091 0t0 TCP *:http (LISTEN)
nginx 14794 root 6u IPv4 1917091 0t0 TCP *:http (LISTEN)
查看是否有文件删除,但是空间没有释放
[root@MySQL ~]# lsof | grep deleted
sh 1356 root txt REG 8,3 938832 4194393 /bin/bash (deleted)
sh 1359 root txt REG 8,3 938832 4194393 /bin/bash (deleted)
pptpd 10374 root txt REG 8,3 29264 10883888 /usr/sbin/pptpd (deleted)
mysqld_sa 12299 root txt REG 8,3 938832 4194393 /bin/bash (deleted)
mysqld_sa 12299 root 0u CHR 136,0 0t0 3 /dev/pts/0 (deleted)
mysqld_sa 12299 root 1u CHR 136,0 0t0 3 /dev/pts/0 (deleted)
mysqld_sa 12299 root 2u CHR 136,0 0t0 3 /dev/pts/0 (deleted)
lspci
指令的名字很直观,查看当前PCI总线设备信息
00:00.0 Host bridge: Intel Corporation 4 Series Chipset DRAM Controller (rev 03)
00:02.0 VGA compatible controller: Intel Corporation 4 Series Chipset Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 1 (rev 01)
00:1c.1 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 2 (rev 01)
00:1d.0 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #1 (rev 01)
00:1d.1 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #2 (rev 01)
00:1d.2 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #3 (rev 01)
00:1d.3 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #4 (rev 01)
00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge (rev 01)
00:1f.2 IDE interface: Intel Corporation NM10/ICH7 Family SATA Controller [IDE mode] (rev 01)
00:1f.3 SMBus: Intel Corporation NM10/ICH7 Family SMBus Controller (rev 01)
02:00.0 Ethernet controller: Qualcomm Atheros AR8151 v2.0 Gigabit Ethernet (rev c0)
1 条评论
还有个 lshw,能把硬件看个透彻