Cheat sheets of Linux commands - toge510/homelab GitHub Wiki

journalctl

: Query the systemd journal

  • journalctl path/to/executable: Show all messages by a specific executable.
    ex) journalctl /bin/sudo
  • journalctl -u unit: Show all messages by a specific [u]nit.
    ex) journalctl -u sshd.service
  • journalctl -e: Immediately jump to the end of the journal inside the implied pager tool (-e = --pager-end).
  • journalctl -f: Show only the most recent journal entries, and continuously print new entries as they are appended to the journal (-f = --follow).
  • journalctl -p: Filter output by message priorities or priority ranges(emerg,alert,crit,err,warning,notice,info,debug).
  • journalctl -k: Show only kernel messages.
  • journalctl -S <datetime> -U <datetime>: Start showing entries on or newer than the specified date, or on or older than the specified date, respectively. Date specifications should be of the format "2012-10-30 18:17:16".
    ex) journalctl -S "2023-02-19 02:05:00" -U "2023-02-19 02:20:30"
  • journalctl -g <regex>: Filter output to entries where the MESSAGE= field matches the specified regular expression.
    ex) journalctl -g '^b'
  • journalctl -b <all>: Show messages from a specific boot.
    ex) journalctl -b 0

last,lastlog

  • last: View the last logged in users.
  • lastlog: Display the most recent login of all users.

Storage management

  • df: Gives an overview of the filesystem disk space usage.
  • findmnt: Find your filesystem.
  • lsblk: Lists information about devices.
  • blkid: Lists all recognized partitions and their Universally Unique Identifier (UUID).
  • fdisk: A program for managing partition tables and partitions on a hard disk.
  • cfdisk: A program for managing partition tables and partitions on a hard disk using a curses UI.
  • chattr: Change attributes of files or directories.
  • lsattr: List file attributes on a Linux filesystem.
  • quota: Display users' disk space usage and allocated limits.
⚠️ **GitHub.com Fallback** ⚠️