• Root/
  • Linux/
  • Helpful commands
  • It's best to search distribution's manual/official help pages before trying commands found on Internet, including ones here. Certain seemingly short commands can instantly break your installation and - rarely - command parameters differ, leading to behavior different from expected.

    In all examples, cat could be replaced with less with few crucial considerations:

    Notes regarding easy of use

    General info

    Getting information about shell built-in functions and commands.

    help

    Shows help page for built-in help command

    man

    Shows manual entry page for command man command

    Persistent sessions

    Preventing programs terminating due to connectivity issues.

    tmux

    Disk and space

    Checking space usage and available disks.

    Information about disk devices (script-friendly, verbose)

    cat /proc/diskstats

    df

    lsblk

    Lists block devices excluding loop device (for example, snap devices) lsblk -e 7 Lists block devices with serial number (if any) lsblk -o +SERIAL

    System info

    htop

    Start program listing system CPU/memory loads and list of processes htop

    free

    Memory and swap info (sizes in human-friendly format) free -h

    swapon

    swap info (human-friendly) swapon --show

    uptime

    Current hour, uptime then load averages over 1/5/15 minutes uptime

    dmidecode

    DMI - Desktop Management Interface (SMBIOS - System Management BIOS) table content in human-readable format (description of hardware components, serial numbers, BIOS revision sudo dmidecode Display value of DMI string identified by KEYWORD: -s, --string (skipping KEYWORD prints available options). Most of those can be read directly from sysfs at /sys/devices/virtual/dmi/id sudo dmidecode --string KEYWORD Display entries of type TYPE: -t, --type (skipping TYPE prints available options) sudo dmidecode --type TYPE DMI types:
    TypeInformation
    0BIOS
    1System
    2Baseboard
    3Chassis
    4Processor
    5Memory Controller
    6Memory Module
    7Cache
    8Port Connector
    9System Slots
    10On Board Devices
    11OEM Strings
    12System Configuration Options
    13BIOS Language
    14Group Associations
    15System Event Log
    16Physical Memory Array
    17Memory Device
    1832-bit Memory Error
    19Memory Array Mapped Address
    20Memory Device Mapped Address
    21Built-in Pointing Device
    22Portable Battery
    23System Reset
    24Hardware Security
    25System Power Controls
    26Voltage Probe
    27Cooling Device
    28Temperature Probe
    29Electrical Current Probe
    30Out-of-band Remote Access
    31Boot Integrity Services
    32System Boot
    3364-bit Memory Error
    34Management Device
    35Management Device Component
    36Management Device Threshold Data
    37Memory Channel
    38IPMI Device
    39Power Supply
    40Additional Information
    41Onboard Devices Extended Information
    42Management Controller Host Interface
    Keyword - type table:
    KeywordType
    bios0, 13
    system1, 12, 15, 23, 32
    baseboard2, 10, 41
    chassis3
    processor4
    memory5, 6, 16, 17
    cache7
    connector8
    slot9

    Logs

    journalctl

    Continuously display logs of service sudo journalctl -u SERVICE_NAME -f Further details: page about systemd

    dmesg

    Checking kernel logs sudo dmesg Log file less /var/log/dmesg

    tail

    Print file content and continue printing it as it comes tail -f path_to_file

    Searching for things

    find

    Helps find file based on its properties or name.

    grep

    Helps locate file containing specific content.

    Other

    Last update: 2024-08-10