第二verything 是一個 Linux 文件,它可以幫助 ls* 和朋友從您的系統中挖掘出比您最初想像的更多的信息。當您需要在不通過 /proc 或 sysfs 的情況下快速查找信息時,這些 Linux 技巧很有用。
#1:lsscsi
列出 Linux 操作系統中的 SCSI 設備(或主機)及其屬性。$ lsscsi -g
示例輸出:
[0:0:0:0] disk Adaptec RAID1-A V1.0 /dev/sda /dev/sg0 [0:1:0:0] disk SEAGATE ST373455SS 0006 - /dev/sg1 [0:1:1:0] disk SEAGATE ST373455SS 0006 - /dev/sg2 [1:0:0:0] cd/dvd TEAC DV-28E-R 1.8A /dev/sr0 /dev/sg3
#2:lsblk
使用此命令列出塊設備# lsblk
示例輸出:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 1 68.3G 0 disk ├─sda1 8:1 1 716M 0 part /boot ├─sda2 8:2 1 8G 0 part [SWAP] └─sda3 8:3 1 59.6G 0 part / sr0 11:0 1 1024M 0 rom
檢查文件系統類型。# lsblk -f
示例輸出:
NAME FSTYPE LABEL MOUNTPOINT sda ├─sda1 ext2 /boot ├─sda2 swap [SWAP] └─sda3 ext4 / sr0
要打印有關權限的信息:# lsblk -m
示例輸出:
NAME SIZE OWNER GROUP MODE sda 68.3G root disk brw-rw---- ├─sda1 716M root disk brw-rw---- ├─sda2 8G root disk brw-rw---- └─sda3 59.6G root disk brw-rw---- sr0 1024M root cdrom brw-rw----
#3:lsb_release
要使用此命令顯示特定於 Linux 發行版的信息,請輸入:# lsb_release
# lsb_release -a
示例輸出:
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 5.8 (Final) Release: 5.8 Codename: Final
#4:lsusb
使用以下命令在基於 Linux 的系統上查看 USB 總線和連接到它的設備。$ lsusb
示例輸出:
Bus 002 Device 004: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0 Bus 002 Device 003: ID 046d:c52f Logitech, Inc. Wireless Mouse M305 Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 007: ID 413c:8160 Dell Computer Corp. Wireless 365 Bluetooth Bus 001 Device 006: ID 413c:8162 Dell Computer Corp. Integrated Touchpad [Synaptics] Bus 001 Device 005: ID 413c:8161 Dell Computer Corp. Integrated Keyboard Bus 001 Device 004: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) Bus 001 Device 003: ID 0a5c:5800 Broadcom Corp. BCM5880 Secure Applications Processor Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
#5:lscpu
lscpu 命令顯示有關 CPU 架構信息的信息,例如 Linux 上的 CPU、線程和內核數。$ lscpu
示例輸出:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit CPU(s): 8 Thread(s) per core: 2 Core(s) per socket: 4 CPU socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 30 Stepping: 5 CPU MHz: 1199.000 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 8192K
#6:lspci
lspci 命令顯示有關係統中 PCI 總線和連接到它們的設備的信息。$ lspci
示例輸出:
00:00.0 Host bridge: VIA Technologies, Inc. VX800 Host Bridge (rev 14) 00:00.1 Host bridge: VIA Technologies, Inc. VX800/VX820 Error Reporting 00:00.2 Host bridge: VIA Technologies, Inc. VX800/VX820 Host Bus Control 00:00.3 Host bridge: VIA Technologies, Inc. VX800 PCI to PCI Bridge 00:00.4 Host bridge: VIA Technologies, Inc. VX800/VX820 Power Management Control 00:00.5 PIC: VIA Technologies, Inc. VX800/VX820 APIC and Central Traffic Control 00:00.6 Host bridge: VIA Technologies, Inc. VX800/VX820 Scratch Registers 00:00.7 Host bridge: VIA Technologies, Inc. VX800/VX820 North-South Module Interface Control 00:01.0 VGA compatible controller: VIA Technologies, Inc. VX800/VX820 Chrome 9 HC3 Integrated Graphics (rev 11) 00:02.0 PCI bridge: VIA Technologies, Inc. VX800/VX820 PCI Express Root Port 00:03.0 PCI bridge: VIA Technologies, Inc. VX800/VX820 PCI Express Root Port 00:03.1 PCI bridge: VIA Technologies, Inc. VX800/VX820 PCI Express Root Port 00:0f.0 IDE interface: VIA Technologies, Inc. VX800 Serial ATA and EIDE Controller 00:10.0 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.1 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.2 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.4 USB controller: VIA Technologies, Inc. USB 2.0 (rev 90) 00:11.0 ISA bridge: VIA Technologies, Inc. VX800/VX820 Bus Control and Power Management 00:11.7 Host bridge: VIA Technologies, Inc. VX8xx South-North Module Interface Control 00:13.0 PCI bridge: VIA Technologies, Inc. VX855/VX875/VX900 PCI to PCI Bridge 02:00.0 Ethernet controller: VIA Technologies, Inc. VT6120/VT6121/VT6122 Gigabit Ethernet Adapter (rev 82) 03:00.0 Ethernet controller: VIA Technologies, Inc. VT6120/VT6121/VT6122 Gigabit Ethernet Adapter (rev 82)
您可以使用 lspci 命令來確定當前運行的 Linux 內核是否支持特定的 PCI 硬件。在本例中,我們將檢查是否支持威盛科技的以太網控制器 VT6120/VT6121/VT6122。# lspci | grep VT6120
示例輸出:02:00.0 Ethernet controller: VIA Technologies, Inc. VT6120/VT6121/VT6122 Gigabit Ethernet Adapter (rev 82)
03:00.0 Ethernet controller: VIA Technologies, Inc. VT6120/VT6121/VT6122 Gigabit Ethernet Adapter (rev 82)
第一個字段 02:00.0 和 03:00.0 的標識符。使用 lspci -n 獲取設備 02:00.0 和 03:00.0 的結果,如下所示:# lspci -n | grep '0[2|3]:00.0'
示例輸出:
02:00.0 0200: 1106:3119 (rev 82) 03:00.0 0200: 1106:3119 (rev 82)
使用型號 ID#3119 搜索驅動程序,如下所示:# grep 3119 /lib/modules/$(uname -r)/modules.alias
示例輸出:
alias pci:v00001106d00003119sv*sd*bc*sc*i* via_velocity
威盛網速系列千兆網卡需要via_velocity驅動。# modinfo via_velocity
示例輸出:
filename: /lib/modules/2.6.32-5-amd64/kernel/drivers/net/via-velocity.ko description: VIA Networking Velocity Family Gigabit Ethernet Adapter Driver license: GPL author: VIA Networking Technologies, Inc. alias: pci:v00001106d00003119sv*sd*bc*sc*i* depends: crc-ccitt vermagic: 2.6.32-5-amd64 SMP mod_unload modversions parm: RxDescriptors:Number of receive descriptors (array of int) parm: TxDescriptors:Number of transmit descriptors (array of int) parm: rx_thresh:Receive fifo threshold (array of int) parm: DMA_length:DMA length (array of int) parm: IP_byte_align:Enable IP header dword aligned (array of int) parm: txcsum_offload:Enable transmit packet checksum offload (array of int) parm: flow_control:Enable flow control ability (array of int) parm: speed_duplex:Setting the speed and duplex mode (array of int) parm: ValPktLen:Receiving or Drop invalid 802.3 frame (array of int) parm: wol_opts:Wake On Lan options (array of int) parm: int_works:Number of packets per interrupt services (array of int) parm: rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
#7: lshw/lshw-gtk
lshw 命令檢索有關服務器或機器的硬件配置的詳細信息。
lshw ### See hardware in a compact format## lshw -short ### Only see disks and storage controllers in the system ### lshw -class disk -class storage ### Only show all network interfaces in HTML fomrat ### lshw -html -class network ## Graphical information about hardware configuration ### lshw-gtk
示例輸出(取自 lshw -short 命令):
了解如何使用 lshw 命令查找有關硬盤驅動器、內存速度、pci 設備等的詳細信息。您還可以使用這些 Linux 命令來收集有關您的 Linux 系統和硬件的信息。
#8:我
使用 ls 命令列出目錄的內容。
## common examples of ls, see man page more info ## ls ls -l ## long format ls -F ## appends a character revealing the nature of a file ls -a ## Show all files including hidden files ls -R ## recursively lists subdirectories ls -d ## Get info about a symbolic link or directory ls -t ## Sort the list of files by modification time ls -h ## Show sizes in human readable format ls -B ## In directories, ignore files that end with ‘~’ (backup files) ls -Z ## Display the SELinux security context ls --group-directories-first -l ## Show directories first (group directories). Useful on server. ls --color ## Colorize the ls output ls --hide='*.txt' -l ## Hide or ignore files whose names ends with .txt
#9:lsof
使用此命令列出打開的文件、網絡端口、活動進程 L 等。
### command lsof command examples ## lsof | less # List all open file lsof -u vivek -i # See all files opened by user "vivek" lsof -i 4 -a -p 7007 # List all open IPv4 network files in use by the process whose PID is 7007 lsof -i TCP:80 # Find process running on tcp port 80 lsof -i 6 # List only open IPv6 network files lsof -i 4 # List only open IPv4 network files lsof -i TCP:1-1024 # List process open in port range 1 to 1024 lsof -i @server1.cyberciti.biz:2000-2005 # List all files using any protocol on ports 2000 to 2005 of host server1.cyberciti.biz, use: lsof /dev/sr0 # List all open files on device /dev/sr0 lsof /dev/dvd # Find out why my DVD drive does not eject? lsof -i -u^root # See all files open by all users except root lsof /etc/foobar # Find out who's looking at the /etc/foobar file?
#10:lsattr
使用 lsattr 列出第二個擴展文件系統的文件屬性。 連root都不能編輯或刪除文件?使用 lsattr 列出文件。$ lsattr /etc/passwd
示例輸出:
------------------- /etc/passwd
要在 Linux 操作系統上寫保護文件,請使用 chattr 命令。# echo 'Test' > foobar
# chattr +i foobar
# lsattr foobar
示例輸出:
----i-------------- foobar
嘗試以 root 身份刪除(刪除)foobar:# rm foobar
示例輸出:
rm: cannot remove `foobar': Operation not permitted
刪除 IMMUTABLE 功能。即無法更改文件。您不能刪除或重命名文件、創建文件鏈接或將數據寫入文件。# chattr -i foobar
#11:伊薩爾
使用 lshal 命令列出 HAL(硬件抽象層)設備數據庫中的項目。 HAL 為應用程序檢測系統上的硬件提供了一種簡單的方法。# lshal | less
### get info about your hardware
# lshal -u /org/freedesktop/Hal/devices/computer
示例輸出:
udi = '/org/freedesktop/Hal/devices/computer' info.addons = {'hald-addon-cpufreq', 'hald-addon-acpi'} (string list) info.callouts.add = {'hal-storage-cleanup-all-mountpoints'} (string list) info.interfaces = {'org.freedesktop.Hal.Device.SystemPowerManagement'} (string list) info.product="Computer" (string) info.subsystem = 'unknown' (string) info.udi = '/org/freedesktop/Hal/devices/computer' (string) org.freedesktop.Hal.Device.SystemPowerManagement.method_argnames = {'num_seconds_to_sleep', 'num_seconds_to_sleep', '', '', '', 'enable_power_save'} (string list) org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths = {'hal-system-power-suspend', 'hal-system-power-suspend-hybrid', 'hal-system-power-hibernate', 'hal-system-power-shutdown', 'hal-system-power-reboot', 'hal-system-power-set-power-save'} (string list) org.freedesktop.Hal.Device.SystemPowerManagement.method_names = {'Suspend', 'SuspendHybrid', 'Hibernate', 'Shutdown', 'Reboot', 'SetPowerSave'} (string list) org.freedesktop.Hal.Device.SystemPowerManagement.method_signatures = {'i', 'i', '', '', '', 'b'} (string list) org.freedesktop.Hal.version = '0.5.14' (string) org.freedesktop.Hal.version.major = 0 (0x0) (int) org.freedesktop.Hal.version.micro = 14 (0xe) (int) org.freedesktop.Hal.version.minor = 5 (0x5) (int) power_management.acpi.linux.version = '20110623' (string) power_management.can_hibernate = true (bool) power_management.can_suspend = true (bool) power_management.can_suspend_hybrid = true (bool) power_management.is_powersave_set = false (bool) power_management.quirk.dpms_on = true (bool) power_management.quirk.vbe_post = true (bool) power_management.type="acpi" (string) system.board.product="0R1203" (string) system.board.serial=".XXXXXXX.CN4864304M0335." (string) system.board.vendor="Dell Inc." (string) system.board.version = '' (string) system.chassis.manufacturer="Dell Inc." (string) system.chassis.type="Portable" (string) system.firmware.release_date="12/06/2011" (string) system.firmware.vendor="Dell Inc." (string) system.firmware.version = 'A08' (string) system.formfactor="laptop" (string) system.hardware.primary_video.product = 1567 (0x61f) (int) system.hardware.primary_video.vendor = 4318 (0x10de) (int) system.hardware.product="Precision M6500" (string) system.hardware.serial="XXXXXXX" (string) system.hardware.uuid = 'ZZZZC-XXXXXXX-104C-XXXXXXX-YYYYY' (string) system.hardware.vendor="Dell Inc." (string) system.hardware.version = '' (string) system.kernel.machine="x86_64" (string) system.kernel.name="Linux" (string) system.kernel.version = '3.2.0-0.bpo.1-amd64' (string) system.kernel.version.major = 3 (0x3) (int) system.kernel.version.micro = 0 (0x0) (int) system.kernel.version.minor = 2 (0x2) (int)
#12: lsinitramfs
使用此命令顯示指定的 initramfs 映像的內容。允許您快速檢查一個(或多個)指定的 initramfs 文件的內容。這對於找出特定驅動程序(例如 RAID 設備驅動程序)是否包含在 initramfs 映像中很有用。
# See initramfs content of current running Linux kernel lsinitramfs /boot/initrd.img-$(uname -r) ## See if nvme driver included or not using the grep command ## lsinitramfs /boot/initrd.img-$(uname -r) | grep nvme ## long and verbose mode ## lsinitramfs -l /boot/initrd.img-$(uname -r) # Find out if transparent encryption / decryption driver included or not lsinitramfs /boot/initrd.img-$(uname -r) | grep 'dm-'
示例輸出(意味著 Linux 可以加密整個硬盤並在啟動時包含支持):
lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-snapshot.ko lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-crypt.ko lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-mirror.ko lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-region-hash.ko lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-mod.ko lib/modules/2.6.32-5-amd64/kernel/drivers/md/dm-log.ko
#13:lsmod
要列出當前加載到 Linux 內核中的所有設備驅動程序,請使用以下命令:# lsmod
示例輸出(取自在開源 Tomato 固件上運行的 ASUS RT-16 路由器)
Module Size Used by Tainted: P ohci_hcd 21552 0 ehci_hcd 40752 0 ext2 67712 0 ext3 136576 0 jbd 62080 1 ext3 mbcache 7280 2 ext2,ext3 usb_storage 50048 0 sd_mod 27440 0 scsi_wait_scan 960 0 scsi_mod 105376 3 usb_storage,sd_mod,scsi_wait_scan usbcore 147344 4 ohci_hcd,ehci_hcd,usb_storage nf_nat_pptp 2592 0 nf_conntrack_pptp 6000 1 nf_nat_pptp nf_nat_proto_gre 2128 1 nf_nat_pptp nf_conntrack_proto_gre 4160 1 nf_conntrack_pptp wl 1884144 0 igs 17936 1 wl emf 22720 2 wl,igs et 59744 0
要確定您是否正在運行名為 ath_pci 的模塊(確保為您的特定設備加載了該模塊):# lsmod | grep ath_pci
#14:lspcmcia
請參閱有關基於 Linux 的系統上的 PCMCIA 套接字和設備的信息。# lspcmcia
示例輸出:
Socket 0 Bridge: [yenta_cardbus] (bus ID: 0000:03:01.0)
#15:木頭
使用此命令檢測新的 wiimote(Wii Remote),它是 Nintendo Wii 控制台的主控制器。 可以和 X 一起使用來控制光標之類的東西。# lswm
#16:LSDVD
使用此命令讀取 DVD 的內容,將內容打印到顯示器,然後轉儲它們以在外部應用程序中進一步處理。
lsdvd # Default output, show info in human readable lsdvd -a # See information about audio streams lsdvd -c # See chapter information lsdvd -s # See subpicture information (e.g. subtitles) lsdvd -s -t track-number lsdvd -a -t 1
示例輸出:
libdvdread: Using libdvdcss version 1.2.10 for DVD access Disc Title: DVD_VIDEO Title: 01, Length: 00:22:01.000 Chapters: 06, Cells: 06, Audio streams: 04, Subpictures: 21 Audio: 1, Language: en - English, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 2, AP: 0, Content: Undefined, Stream id: 0x80 Audio: 2, Language: fr - Francais, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 2, AP: 0, Content: Undefined, Stream id: 0x81 Audio: 3, Language: de - Deutsch, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 2, AP: 0, Content: Undefined, Stream id: 0x82 Audio: 4, Language: en - English, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 2, AP: 0, Content: Undefined, Stream id: 0x83
您可以使用 mplayer 播放 DVD。$ mplayer dvd://1 -dvd-device /dev/dvd
#17:lslk
使用以下命令列出與系統本地文件關聯的所有鎖:# lslk
示例輸出:
SRC PID DEV INUM SZ TY M ST WH END LEN NAME portmap 1354 254,1 4309006 5 w 0 0 0 0 0 /var/run/portmap.pid atd 2124 254,1 4309014 5 w 0 0 0 0 0 /var/run/atd.pid mysqld 2404 254,1 6824038 5242880 w 0 0 0 0 0 /var/lib/mysql/ib_logfile1 mysqld 2404 254,1 6824037 5242880 w 0 0 0 0 0 /var/lib/mysql/ib_logfile0 mysqld 2404 254,1 6824036 27262976 w 0 0 0 0 0 /var/lib/mysql/ibdata1 (unknown) 2807 254,1 4309033 w 0 0 0 0 0 / (rootfs) compiz 3398 254,1 7815224 81090 w 0 0 0 0 0 /home/vivek/.nv/GLCache/a147bc5d819e1646d5baf3c8f0a017e4/8bdcca7527c339d4/736353d788902c9e.bin compiz 3398 254,1 7815223 7668 w 0 0 0 0 0 /home/vivek/.nv/GLCache/a147bc5d819e1646d5baf3c8f0a017e4/8bdcca7527c339d4/736353d788902c9e.toc python 3427 254,1 4030467 0 w 0 0 0 0 0 /home/vivek/.hplip/hp-systray.lock chrome 3567 254,1 3956948 12288 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Login Data chrome 3567 254,1 3957700 135782400 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/History Index 2012-06 chrome 3567 254,1 3957049 120713216 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/History Index 2012-07 chrome 3567 254,1 3956937 15605760 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Favicons chrome 3567 254,1 3957883 1155072 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Shortcuts chrome 3567 254,1 3957138 61657088 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/History Index 2012-08 chrome 3567 254,1 3956932 24100864 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/History chrome 3567 254,1 3957892 3702784 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Network Action Predictor chrome 3567 254,1 3956926 552960 w 0 1073741824 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Web Data chrome 3567 254,1 3956809 57344 r 0 1073741826 0 1073742335 0 /home/vivek/.config/google-chrome/Default/Archived History firefox 3575 254,1 3964960 425984 w 0 1073741824 0 1073742335 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/addons.sqlite firefox 3575 254,1 3964948 1114112 r 0 1073741826 0 1073742335 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/extensions.sqlite firefox 3575 254,1 3973490 983040 r 0 1073741826 0 1073742335 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/StumbleUpon/user6896004.sqlite firefox 3575 254,1 8364042 32768 r 0 128 0 128 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/places.sqlite-shm firefox 3575 254,1 3964949 20971520 r 0 1073741826 0 1073742335 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/places.sqlite firefox 3575 254,1 8364040 32768 r 0 128 0 128 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/cookies.sqlite-shm firefox 3575 254,1 3964961 1048576 r 0 1073741826 0 1073742335 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/cookies.sqlite firefox 3575 254,1 3964944 0 w 0 0 0 0 0 /home/vivek/.mozilla/firefox/j7nk7e8h.default/.parentlock chrome 6326 254,1 7815216 88822 w 0 0 0 0 0 /home/vivek/.nv/GLCache/a147bc5d819e1646d5baf3c8f0a017e4/8bdcca7527c339d4/bc35a2d21bc47b1d.bin chrome 6326 254,1 7815215 2676 w 0 0 0 0 0 /home/vivek/.nv/GLCache/a147bc5d819e1646d5baf3c8f0a017e4/8bdcca7527c339d4/bc35a2d21bc47b1d.toc transmission 10465 254,1 11468802 0 w 0 0 0 0 0 /home/vivek/.config/transmission/lock
#18:lsmbox
使用此命令可顯示郵箱中的郵件數。 對於一個或多個郵箱文件,您可以列出所有未讀但不包括舊郵件和新郵件。
lsmbox ! # Get information about your inbox lsmbox spam support family # Get information about the mailboxes spam, support, and family lsmbox ~/foo # Get information about the mailbox foo which resides in your home directory
#19:LSC 集團
使用此命令列出所有 cgroup(控制組)。這是一個 Linux 內核特性,用於限制、說明和隔離進程組的資源使用(CPU、內存、磁盤 I/O 等)。# lscgroup
#20:lsdiff
使用此命令查看補丁修改的文件。 o 要對補丁中文件的修改順序進行排序,您可以使用:$ lsdiff patch | sort -u | xargs -rn1 filterdiff patch -i
要僅顯示添加到補丁的文件:$ lsdiff -s patch | grep '^+' | cut -c2- | xargs -rn1 filterdiff patch -i
要顯示所有文件塊的標題:$ lsdiff -n patch | (while read n file do sed -ne "$n,$(($n+1))p" patch done)
#21:lspst
使用此命令列出 PST(MS Outlook 個人文件夾)文件數據。生成一個簡單的數據列表(聯繫人、電子郵件主題等)。$ lspst mypst-file
#22: lsdnssec
使用 lsdnssec 命令匯總有關 DNSSEC 相關文件的信息。這些文件可以在命令行中指定,也可以在命令行指定的目錄中找到。 -d 標誌控制 lsdnssec 輸出中的詳細信息量。# lsdnssec file
lsdnssec 為其收集信息的每個區域顯示以下信息。
keys Key information is shown about the keys currently in use. A bar graph is included that shows the age of the key with respect to the configured expected key-life time. This information is collected from any .krf files lsdnssec finds. rolling status If any zone keys are being rolled via rollerd, then the status of the rolling state is shown. The time needed to reach the next state is also displayed. This information is collected from any .rollrec files found by lsdnssec.
#23:lsmem
lsmem 命令列出可用內存範圍及其在線狀態。列出的內存塊對應於 sysfs 內存塊表示。語法是:
lsmem ## List each individual memory block ## lsmem -a ## Print the SIZE column in bytes rather than in a human-readable format ## lsmem -b
#24:lsdev
lsdev 命令從 /proc 目錄中的中斷、ioport 和 dma 文件中獲取有關計算機上安裝的硬件的信息。這使您可以快速查看哪個硬件正在使用哪個 I/O 地址以及哪個 IRQ 和 DMA 通道。
lsdev lsdev | more
#25:lslocks
想要列出當前在您的 Linux 系統上持有的所有文件鎖的信息嗎?嘗試:lslocks
輸出包含以下數據:
- 命令 : 持有鎖的進程的命令名。
- PID : 持有鎖的進程的進程 ID,或 -1 表示 OFDLCK。
- 類型 :鎖的類型;FLOCK(由flock(2)創建)、POSIX(由fcntl(2)和lockf(3)創建)或OFDLCK(由fcntl(2)創建)。
- 尺寸 : 鎖定文件的大小。
- 模型 : 鎖定訪問權限(讀、寫)。如果進程被阻塞等待鎖定,則模式將以“*”(星號)結束。
- 米 : 是否強制鎖定。 0 表示否(表示鎖定只是建議性的),1 表示是。 (參見 fcntl(2))。
- 開始 : 鎖的相對字節偏移量。
- 結尾 : 鎖的結束偏移量。
- 小路 : 鎖的完整路徑。如果找不到路徑或者您沒有讀取路徑的權限,請退回到設備掛載點並將“…”附加到路徑中。路徑可能會被截斷。使用 –notruncate 獲取完整路徑。
- 阻滯劑 :阻塞鎖的進程的PID。
#26:伊薩爾
想要查看/列出存檔文件的內容?試試 lsar:lsar file.tar.gz
lsar docs.zip
以 JSON 格式輸出清單。lsar -j data.tar.gz
您還可以測試存檔中文件的完整性:lsar -t bar.tgz
您可以指定用於解密受保護檔案的密碼。lsar -p MY_PASSWORD /path/to/arhive.file
#27:登錄
Linux 系統管理員和開發人員可以看到有關係統上已知用戶的信息。lslogins
只能打印有關指定用戶的所有可用詳細信息。例如,要顯示有關名為“vivek”的用戶的信息:lslogins vivek
#28:lsgpu
列出系統中的 GPU。lsgpu
有關更多信息,請參閱前 7 個 Linux GPU 監控和診斷命令行工具。
#29:伊斯托波
想查看你的 Linux 系統的拓撲結構嗎?試試:lstopo
#30:lsipc
lsipc 命令顯示有關調用進程具有讀取訪問權限的進程間通信設施的信息。lsipc
RESOURCE DESCRIPTION LIMIT USED USE% MSGMNI Number of message queues 32000 0 0.00% MSGMAX Max size of message (bytes) 8192 - - MSGMNB Default max size of queue (bytes) 16384 - - SHMMNI Shared memory segments 4096 27 0.66% SHMALL Shared memory pages 18446744073692774399 27868 0.00% SHMMAX Max size of shared memory segment (bytes) 18446744073692774399 - - SHMMIN Min size of shared memory segment (bytes) 1 - - SEMMNI Number of semaphore identifiers 32000 2 0.01% SEMMNS Total number of semaphores 1024000000 2 0.00% SEMMSL Max semaphores per semaphore set. 32000 - - SEMOPM Max number of operations per semop(2) 500 - - SEMVMX Semaphore max value 32767 - -
添加
本文的目的是介紹 Linux 系統的已知和未知 ls* 命令。當然,您應該使用手冊頁來獲取有關語法和命令行選項的完整信息。 人命令例子:man lsipc
man lslogins
你有最喜歡的 Linux ls* 命令或腳本嗎?在下面的評論中分享。