Hardware and Devices

    Device / driver info

    lsmod
    lspci -k
    dmesg
    

    Devices

    sudo libinput --list-devices
    

    Learn about your hardware

    Get DMI/BIOS information

    sudo dmidecode 
    sudo dmidecode -t0 # BIOS
    sudo dmidecode -t1 # System
    sudo dmidecode -t2 # Board
    sudo dmidecode -t3 # Enclosure or Chassis
    sudo dmidecode -t4 # Processor
    sudo dmidecode -t1 # System
    

    Drives

    Hard drive information

    list disks with lsblk

    lsblk -f #list filesystem details
    lsblk -t #show topology
    lsblk -i # use ascii
    lsblk -o NAME,UUID # show specific columns
    sudo lshw -class disk
    sudo fdisk -l
    sudo hwinfo --disk
    ls -l /dev/disk/by-path
    ls -l /dev/disk/by-id
    

    get drive information:

    sudo hdparm -I /dev/sda
    

    if you have an NVMe device…

    sudo apt install -y nvme-cli
    nvme list
    #sudo nvme smart-log <node_name> 
    sudo nvme smart-log /dev/nvme0n1 
    sudo nvme id-ctrl /dev/nvme0n1
    

    Mounting

    From here

    ##list disks
    sudo fdisk -l
    #if you know the disk you want info about:
    sudo fdisk -l /dev/sdd 
    sudo mount /dev/sdd1 /media/backup
    # unmount
    sudo umount /media/backup
    # unmount all
    sudo umount -a
    # force unmount
    sudo umount -f /media/backup
    

    mounting with fstab

    you can get most information from lsblk if you have temporarily mounted it…

    #UUID=<yourUUID>                           <mount_location> <filesystem>  <options>  <dump(use 0)>  <order(use 2)>
    UUID=24df9215-550f-4ca0-a9f1-8f0efd2  /media/backup    ext4          defaults   0       2
    

    once you have edited, check by running

    mount -a
    

    Recursively find storage space of a directory

    from here

    du -sh /path/to/my/dir
    

    list directories, one level only, from here

    du -h  --max-depth 1 /path/to/my/dir
    

    Find the free space of a drive

    df -H
    

    Disk Cloning

    check out dd

    sudo fdisk -l /dev/sdb
    
    sudo dd if=/dev/sda of=~/sda.dd bs=128k status=progress conv=noerror,sync
    sudo dd if=/dev/sda bs=128k status=progress conv=noerror,sync | gzip -c > /sda.gz
    sudo dd if=/dev/sda of=/media/danaukes/24df9215-550f-4ca0-a9f1-8f0d666befd2/sda.dd bs=128k status=progress conv=noerror,sync
    

    Change Swap

    mount information

    information on nautilus-aware mount locations

    Read from Serial

    from here

    sudo apt install -y cu
    cu -l /dev/ttyACM0 -s 9600
    

    To exit enter tilde dot (~.)

    sudo apt install -y screen
    screen /dev/ttyACM0 9600
    

    Identifying and locating USB devices

    These widely used commands can be used to list and learn about connected USB devices in Linux.

    lsusb
    dmesg
    dmesg | less
    dmesg | grep ttyUSB
    usb-devices
    lsblk
    sudo blkid.
    sudo fdisk -l
    

    lsusb

    list the device tree to get port:device

    lsusb -t
    

    list all the details about a device at port 1: device 3

    lsusb -v -s 1:3
    

    Permissions