Skip to main content

Managing Hardware Devices

1. Viewing Device Information

Command Description Example Output
lsblk List block devices including disks and partitions
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk 
├─sda1   8:1    0  1G  0 part /boot
└─sda2   8:2    0 49G  0 part [SWAP]
lshw Get detailed hardware information
*-cpu
     product: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
     vendor: Intel Corp.
     size: 2400MHz
lspci List PCI devices (e.g., graphics cards, network adapters)
00:00.0 Host bridge: Intel Corporation 82G33/GM31/P35/P31 Express DRAM Controller
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530
lsusb List USB devices connected to the system
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
dmidecode Access DMI/SMBIOS information (system firmware details)
Handle 0x0001, DMI type 1, length 27
Manufacturer: Dell Inc.
Product Name: Inspiron 15 3000 Series
Version: Not Specified

Example: View disk usage and partitions

lsblk -f

Example: Show detailed CPU info

lscpu
Note: Some commands like lshw may require root privileges to display full details.

2. Monitoring Hardware with sensors

Command Description Example
sensors Displays sensor data from hardware sensors sensors
sensors -u Displays sensor data in a more detailed format sensors -u
sensors -f Displays sensor data in a flat format (useful for scripting) sensors -f

Example: Displaying sensor data

sensors
ibp-isa-0000
Adapter: ISA adapter
CPU Temperature:    +45.0°C  (high = +100.0°C, critical = +120.0°C)
GPU Temperature:    +55.0°C  (high = +100.0°C, critical = +120.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:      +45.0°C  (high = +100.0°C, critical = +120.0°C)
Core 0:            +43.0°C  (high = +100.0°C, critical = +120.0°C)
Core 1:            +45.0°C  (high = +100.0°C, critical = +120.0°C)
Note: The sensors command requires the lm-sensors package to be installed.
Warning: Sensor readings may vary depending on the hardware and driver support.

3. Testing Hard Drives

Command Description Usage
dd Copy and convert files, often used for disk testing dd if=/dev/zero of=/dev/sdX bs=1M count=100
hdparm Get and set hard disk parameters hdparm -Tt /dev/sda
smartctl Control and monitor S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) smartctl -a /dev/sda

Example: Check drive health with SMART

smartctl -H /dev/sda
  

Example: Test read/write speed with dd

dd if=/dev/zero of=testfile bs=1M count=1000
  

4. Viewing Disk SMART Status

Example: Check SMART status of /dev/sda

sudo smartctl -H /dev/sda
Option Values Description
-H smartctl -H Check overall health status of the drive
-i smartctl -i Display device identification information
-A smartctl -A Display all SMART attributes
-l smartctl -l Display logs (e.g., error logs)
Note: Ensure the drive is not in use before running SMART tests.
Warning: Some drives may not support SMART or may return inaccurate data depending on the manufacturer.

SMART Status Indicators

  • PASSED: Drive is healthy and functioning properly.
  • FAILED: Drive has detected errors and should be replaced immediately.
  • UNKNOWN: SMART data is not available or cannot be read.

5. Managing USB Devices

Command Description Notes
lsusb List USB devices connected to the system Shows vendor, product, and device details
usb-devices Display detailed USB device information More verbose than lsusb, includes device hierarchy
dmesg | grep -i usb View USB-related messages in kernel log Useful for debugging connection issues

Example: Identify USB device by vendor ID

lsusb | grep -i "vendor_id"

Example: View USB device details using udevadm

udevadm info --query=all --name=/dev/bus/usb/001/002
Note: USB devices are managed by the Linux kernel's USB subsystem. Permissions for accessing USB devices can be controlled via udev rules.
Warning: Avoid unplugging USB devices while they are actively transferring data, as this can lead to data corruption or loss.

6. Configuring Sound Devices

Device Configuration File Description
/etc/asound.conf /etc/asound.conf Global ALSA configuration file for sound device settings
~/.asoundrc ~/.asoundrc User-specific ALSA configuration file

Example: Basic ALSA Configuration

pcm.!default {
    type plug
    slave.pcm "hw:0,0"
}

ctl.!default {
    type hw
    card 0
}

Example: Setting Default Audio Device

sudo nano /etc/asound.conf
Note: Use alsamixer to adjust volume levels and mute settings interactively.
Warning: Modifying ALSA configurations can affect audio output. Always backup configuration files before changes.
Command Description Usage
alsamixer Interactive audio mixer alsamixer
amixer Command-line audio mixer amixer sset Master 70%
aplay List available audio devices aplay -l
arecord Record audio from a device arecord -d 10 test.wav

7. Managing Graphics Drivers

Driver Support Status Notes
nvidia NEW Supported Latest NVIDIA drivers for GeForce and Quadro series
amdgpu NEW Supported Open-source driver for AMD GPUs (Radeon VII and newer)
intel Stable Intel integrated graphics support (HD Graphics 500 series and newer)
vmwgfx Legacy VMware SVGA driver, deprecated in favor of newer versions

Example: Install NVIDIA Driver

sudo apt update
sudo apt install nvidia-driver-535

Example: Check Driver Status

nvidia-smi
Note: Ensure the system has sufficient power supply and cooling for high-performance GPUs.
Warning: Avoid mixing proprietary and open-source drivers for the same GPU.

8. Controlling Laptop Brightness

Method Description Notes
/sys/class/backlight/ Virtual filesystem for brightness control Available on most modern Linux systems
xbacklight Command-line tool to adjust backlight Part of x11-xbacklight package
brightnessctl Modern tool to control brightness More reliable than xbacklight, supports multiple devices

Example: Using brightnessctl to adjust brightness

brightnessctl set 50%

Example: Increasing brightness by 10%

brightnessctl set +10%

Example: Getting current brightness level

brightnessctl | grep -o '[0-9]*%'\n
Note: On some systems, you may need to run brightnessctl with sudo if the device is not accessible to regular users.
Warning: Setting brightness too high or too low can cause display issues or damage the screen.

9. Managing Power Settings

Setting Description Command
power state Current power state of the system cat /sys/class/power_supply/BAT0/online
battery level Current battery percentage upower -i /org/freedesktop/UPower/devices/battery_BAT0
suspend mode System suspend modes (e.g., S3, S4) cat /sys/power/mem_sleep

Example: Check power usage

upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "percentage|state"

Example: Set CPU governor

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Note: Some power settings may require root privileges to modify.
Warning: Incorrect power settings can cause system instability or unexpected shutdowns.

10. Configuring Bluetooth

Configuration File Path Description
/etc/bluetooth/main.conf /etc/bluetooth/main.conf Global Bluetooth configuration file for daemon settings
/etc/bluetooth/autoconnect.conf /etc/bluetooth/autoconnect.conf Defines automatic connection rules for paired devices

Example: Enable Bluetooth on Boot

# Enable Bluetooth service to start on boot
sudo systemctl enable bluetooth

# Start the Bluetooth service immediately
sudo systemctl start bluetooth

Example: Pairing a Bluetooth Device

# Launch Bluetoothctl
bluetoothctl

# Scan for devices
[bluetooth]# scan on

# Pair with device (replace MAC address)
[bluetooth]# pair AA:BB:CC:DD:EE:FF

# Trust the device
[bluetooth]# trust AA:BB:CC:DD:EE:FF

# Connect to device
[bluetooth]# connect AA:BB:CC:DD:EE:FF
Note: Ensure the bluetoothctl utility is installed via bluez-tools package.
Warning: Some Bluetooth devices may require specific drivers or firmware to function properly.
Command Description Usage
bluetoothctl Interactive Bluetooth management tool bluetoothctl
hciconfig Configure Bluetooth adapter settings hciconfig -a
bluetoothctl Control Bluetooth services and devices bluetoothctl show

11. Viewing Battery Status

Command Description Example Output
acpi Displays battery status and power source information Battery 0: discharging, 85%, 02:15:42 remaining
upower Provides detailed power management information
Energy full: 5200 mWh
Energy now: 4420 mWh
cat /sys/class/power_supply/BAT0/capacity Reads battery capacity directly from sysfs 85
cat /sys/class/power_supply/BAT0/status Reads battery status (charging, discharging, full) Discharging

Example: Check battery status with acpi

$ acpi
Battery 0: discharging, 85%, 02:15:42 remaining

Example: Read battery capacity directly

$ cat /sys/class/power_supply/BAT0/capacity
85
Note: The battery device path may vary (e.g., BAT1, BAT2) depending on the system configuration.

Was this article helpful?