3 ls* Commands You Should Know

If you have even a small amount of Linux experience, you have probably used the “ls” command to list the contents of a directory. What you may not know is that there are numerous other ls-based commands that are extremely useful for server management. The following are 3 you should know:

1. lsblk – lists block devices, such as your hard drives and their partitions. Sample output would look like this:

sda 8:0 0 232.9G 0 disk
├─sda1 8:1 0 100M 0 part
└─sda2 8:2 0 232.8G 0 part
sdb 8:16 0 465.8G 0 disk
├─sdb1 8:17 0 8.4G 0 part [SWAP]
└─sdb2 8:18 0 457.4G 0 part /

2. lsb_release – This command will give you information about your Linux distribution, useful if you need to verify upgrades or confirm architecture settings. Sample output:

LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.1 (Final)
Release: 6.1
Codename: Final

3. lscpu – Lists information about your CPUs. Sample output:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 42
Stepping: 7
CPU MHz: 1600.000
BogoMIPS: 6185.65
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3