System Servicessystemutilitiesdiskpartitionmountfilesystemprocessesbsd

util-linux

util-linux is a comprehensive collection of Linux system utilities for disk management, filesystem operations, process control, and hardware interaction. It provides essential tools for system maintenance, partitioning, mounting, and monitoring.

Description

util-linux contains a wide array of command-line tools essential for Linux system administration. These utilities handle core system tasks including disk partitioning (fdisk, cfdisk, sfdisk), filesystem mounting and unmounting (mount, umount), swap management (swapon, swapoff), and process control (renice, chrt, ionice). The package is divided into several sub-packages like bsdextrautils, bsdutils, fdisk, mount, and the main util-linux package, each providing specialized BSD-derived or Linux-specific functionality.

Common use cases include partitioning hard drives, managing removable media (eject), monitoring block devices (lsblk, blkid), and controlling system resources like CPU affinity (taskset) and I/O scheduling (ionice). Tools like dmesg for kernel messages and hwclock for RTC management are crucial for troubleshooting and time synchronization. The collection supports both interactive and scripted operations, making it indispensable for system maintenance and forensics.

These utilities are particularly valuable in cybersecurity contexts for disk analysis, live system manipulation, and evidence collection during forensic investigations. Many tools support verbose output, JSON formatting, and raw data modes suitable for automation and parsing in security tools.

How It Works

util-linux tools interact directly with Linux kernel interfaces via syscalls, ioctls, and /proc filesystem. Disk utilities like fdisk manipulate partition tables (MBR/GPT) by reading/writing directly to block devices. Mount/umount use kernel mount API with fstab integration and label/UUID resolution via libblkid. Process tools like taskset use sched_setaffinity() syscall for CPU binding, while ionice modifies I/O scheduler classes through block layer interfaces. Many tools leverage libsmartcols for formatted output and libmount for filesystem operations. BSD utilities provide text processing capabilities optimized for terminal output formatting.

Installation

bash
sudo apt install util-linux

Flags

-l (fdisk)List partition tables for all or specific disk devices
-f (lsblk)Show filesystem info: type, UUID, label, and mount point
-P (losetup)Scan for partition table entries when setting up loop devices
-a (script)Append to existing log file instead of overwriting
-C (hexdump)Canonical hex+ASCII display (16 bytes per line)
-n NUM (hexdump)Limit output to NUM bytes from input
-t DELIM (column)Specify input delimiter for column alignment
-n PRIORITY (renice)New nice value: -20 (highest priority) to 19 (lowest)

Examples

List all disk partitions, sizes, and partition types on the system
fdisk -l
Show block devices with filesystem types, labels, UUIDs, and mount points
lsblk -f
Mount a partition to /mnt/usb for forensic examination
mount /dev/sdb1 /mnt/usb
Record entire terminal session to session.log (including all output)
script -a session.log
Mount a disk image as loop device with partition support, then verify
losetup -fP disk.img && lsblk
Dump first 50 lines of raw disk bytes in hex+ASCII (MBR analysis)
hexdump -C /dev/sda | head -50
Increase priority of PID 1337 for performance-sensitive tasks
renice -n -5 -p 1337
Format a CSV file into aligned columns for readable terminal output
column -t -s, data.csv
Updated 2026-04-16kali.org ↗