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

    ##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

    du -sh /path/to/my/dir
    

    list directories, one level only

    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

    you can add hard drive space to augment RAM. This is usually set up when you install ubuntu, but it can be changed.

    1. Turn off existing swap processes

      sudo swapoff -a
      
    2. Resize swap

      #sudo fallocate -l <swapsize> /swap.img 
      sudo fallocate -l 1G /swap.img
      

      you can use whatever size you want in place of 1G

      if that doesn’t work, use

      sudo dd if=/dev/zero of=/swap.img bs=1M count=4096 
      
    3. ensure swap has the right permissions

      sudo chmod 600 /swap.img

    4. pass the new swapfile to swap

      sudo mkswap /swap.img
      
    5. Activate the swap file

      swapon /swap.img
      
    6. check /etc/fstab, and ensure it has this line:

      /swap.img none swap sw 0 0 
      
    7. verify your swap size:

      free -h
      

    Read from Serial

    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

    External Resources