Here are 10 Linux command to know the system and increase your productivity quickly.
10 Linux commands to know the system
Open the terminal application and then start typing these commands to know your Linux desktop or cloud server/VM.
1. free – get free and used memory
Are you running out of memory? Use the free command to show the total amount of free and used physical (RAM) and swap memory in the Linux system. It also displays the buffers and caches used by the kernel:free
# human readable outputs
free -h
# use the cat command to find geeky details
cat /proc/meminfo
However, the free command will not give information about memory configurations, maximum supported memory by the Linux server, and Linux memory speed. Hence, we must use the dmidecode command:sudo dmidecode -t memory
Want to determine the amount of video memory under Linux, try:lspci | grep -i vga
glxinfo | egrep -i 'device|memory'
See “Linux Find Out Video Card GPU Memory RAM Size Using Command Line” and “Linux Check Memory Usage Using the CLI and GUI” for more information.
2. hwinfo – probe for hardware
We can quickly probe for the hardware present in the Linux server or desktop:# Find detailed info about the Linux box
hwinfo
# Show only a summary #
hwinfo --short
# View all disks #
hwinfo --disk
# Get an overview #
hwinfo --short --block
# Find a particular disk #
hwinfo --disk --only /dev/sda
hwinfo --disk --only /dev/sda
# Try 4 graphics card ports for monitor data #
hwprobe=bios.ddc.ports=4 hwinfo --monitor
# Limit info to specific devices #
hwinfo --short --cpu --disk --listmd --gfxcard --wlan --printer
Alternatively, you may find the lshw command and inxi command useful to display your Linux hardware information:sudo lshw -short
inxi -Fxz
3. id – know yourself
Display Linux user and group information for the given USER name. If user name omitted show information for the current user:id
uid=1000(vivek) gid=1000(vivek) groups=1000(vivek),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),116(sambashare),998(lxd)
See who is logged on your Linux server:who
who am i
4. lsblk – list block storage devices
All Linux block devices give buffered access to hardware devices and allow reading and writing blocks as per configuration. Linux block device has names. For example, /dev/nvme0n1 for NVMe and /dev/sda for SCSI devices such as HDD/SSD. But you don’t have to remember them. You can list them easily using the following syntax:lsblk
# list only #
lsblk -l
# filter out loop devices using the grep command #
lsblk -l | grep '^loop'
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT md0 9:0 0 3.7G 0 raid1 /boot md1 9:1 0 949.1G 0 raid1 md1_crypt 253:0 0 949.1G 0 crypt nixcraft-swap 253:1 0 119.2G 0 lvm [SWAP] nixcraft-root 253:2 0 829.9G 0 lvm / nvme1n1 259:0 0 953.9G 0 disk nvme1n1p1 259:1 0 953M 0 part nvme1n1p2 259:2 0 3.7G 0 part nvme1n1p3 259:3 0 949.2G 0 part nvme0n1 259:4 0 953.9G 0 disk nvme0n1p1 259:5 0 953M 0 part /boot/efi nvme0n1p2 259:6 0 3.7G 0 part nvme0n1p3 259:7 0 949.2G 0 part
5. lsb_release – Linux distribution information
Want to get distribution-specific information such as, description of the currently installed distribution, release number and code name:lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal
6. lscpu – display info about the CPUs
The lscpu command gathers and displays CPU architecture information in an easy-to-read format for humans including various CPU bugs:lscpu
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 39 bits physical, 48 bits virtual CPU(s): 12 On-line CPU(s) list: 0-11 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 158 Model name: Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz Stepping: 13 CPU MHz: 976.324 CPU max MHz: 4600.0000 CPU min MHz: 800.0000 BogoMIPS: 5199.98 Virtualization: VT-x L1d cache: 192 KiB L1i cache: 192 KiB L2 cache: 1.5 MiB L3 cache: 12 MiB NUMA node0 CPU(s): 0-11 Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling Vulnerability Srbds: Mitigation; TSX disabled Vulnerability Tsx async abort: Mitigation; TSX disabled Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_g ood nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes x save avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities |
Cpu can be listed using the lshw command too:sudo lshw -C cpu
7. lstopo – display hardware topology
Want to see the topology of the Linux server or desktop? Try:lstopo
lstopo-no-graphics
You will see information about:
- NUMA memory nodes
- shared caches
- CPU packages
- Processor cores
- processor “threads” and more
8. lsusb – list usb devices
We all use USB devices, such as external hard drives and keyboards. Run the NA command for displaying information about USB buses in the Linux system and the devices connected to them.lsusb
# Want a graphical summary of USB devices connected to the system? #
sudo usbview
lspci – list PCI devices
We use the lspci command for displaying information about PCI buses in the system and devices connected to them:lspci
9. timedatectl – view current date and time zone
Typically we use the date command to set or get date/time information on the CLI:date
However, modern Linux distro use the timedatectl command to query and change the system clock and its settings, and enable or disable time synchronization services (NTPD and co):timedatectl
Local time: Sun 2020-07-26 16:31:10 IST Universal time: Sun 2020-07-26 11:01:10 UTC RTC time: Sun 2020-07-26 11:01:10 Time zone: Asia/Kolkata (IST, +0530) System clock synchronized: yes NTP service: active RTC in local TZ: no
10. w – who is logged in
Run the w command on Linux to see information about the Linux users currently on the machine, and their processes:
$ w
Conclusion
And this concluded our ten Linux commands to know the system to increase your productivity quickly to solve problems. Let me know about your favorite tool in the comment section below.