util-linux

From Gentoo Wiki
Jump to:navigation Jump to:search

The util-linux suite contains userspace utilities for Linux-specific system management, including device control, terminal logins, process management, and tty messaging. It is a fundamental block of userspace utilities for Linux systems.

Gentoo includes the util-linux package in the @system set.

Installation

USE flags

Warning
Some of these USE flags provide core system functionality, and may be relied upon by users, or software. Some of these USE flags install commands that may conflict with commands provided by other packages. For example disabling the su USE flag could leave a system without the su command, and kill could conflict with sys-process/procps.

USE flags for sys-apps/util-linux Various useful Linux utilities

+cramfs build mkfs/fsck helpers for cramfs filesystems
+hardlink build hardlink program
+logger build the logger program
+readline Enable support for libreadline, a GNU line-editing library that almost everyone wants
+su build the su program
+suid Install some programs with suid bit set to provide additional functionality. mount/umount: non-root users may mount/umount devices wall/write: non-root users can notify other users su: non-root users may become root
audit Use sys-process/audit to emit audit messages about system changes
build !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1]
caps build setpriv helper (run programs with diff capabilities)
cryptsetup Use sys-fs/cryptsetup to have built-in dm-verity in libmount
fdformat build fdformat (floppy disk format)
kill build the kill program
magic Add support for file type detection via magic bytes (usually via libmagic from sys-apps/file)
ncurses Add ncurses support (console display library)
nls Add Native Language Support (using gettext - GNU locale utilities)
pam build runuser helper
python Add optional support/bindings for the Python language
rtas Add support for the Run Time Abstraction Services (RTAS)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
slang Add support for the slang text display library (it's like ncurses, but different)
static-libs Build static versions of dynamic libraries as well
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
tty-helpers install the mesg/wall/write tools for talking to local users
udev Enable virtual/udev integration (device discovery, power and storage device support, etc)
unicode Add support for Unicode
uuidd build uuidd daemon
verify-sig Verify upstream signatures on distfiles

kill

Enabling the kill USE flag will typically creates a conflict between the sys-process/procps and sys-apps/util-linux packages. Both packages include the kill command, and both packages are capable of conditionally building the kill utility by setting the kill USE flag (in fact, sys-apps/coreutils also includes support for a kill command).

Gentoo toolchain developers have decided the sys-process/procps package will be the default provider of the kill utility for the @system set.

tty-helpers

The mesg, wall, and write utilities are installed using the tty-helpers USE flag. This can be viewed by scrolling down in USE flags section above.

For security reasons, these utilities are disabled by default.

Emerge

root #emerge --ask --oneshot sys-apps/util-linux
Note
--oneshot is used in the above command because util-linux is included in the @system set, so it should not be added to the @selected set (/var/lib/porage/world file).

Usage

There are many utilities included in the util-linux package.

addpart

Tell the kernel about the existence of a specified partition.

user $addpart --help

agetty

Open a tty and prompt for login - acts as an alternative Linux getty.

user $agetty --help

blkdiscard

Discard the content of sectors on a device.

user $blkdiscard --help

blkid

Print block device information.

user $blkid --help

blkzone

Run zone command on the given block device.

user $blkzone --help

blockdev

Call block device ioctls from the command line.

user $blockdev --help

cal

Display a calendar, or some part of it.

user $cal --help

cfdisk

Display or manipulate a disk partition table.

user $cfdisk --help

chcpu

Configure CPUs in a multi-processor system.

user $chcpu --help

chfn

Change finger informaiton.

user $chfn --help

chmem

Set a particular size or range of memory online or offline.

user $chmem --help

choom

Display and adjust OOM-killer score.

user $choom --help

chrt

Show or change the real-time scheduling attributes of a process.

user $chrt --help

chsh

Change login shell for a user.

user $chsh --help

col

Filter out reverse line feeds from standard input.

user $col --help

colcrt

Filter nroff output for CRT previewing.

user $colcrt --help

colrm

Filter out the specified columns.

user $colrm --help

column

Columnate lists.

user $column --help

ctrlaltdel

Set the function of the Ctrl-Alt-Del combination.

user $ctrlaltdel --help

date

Display the current time in the given FORMAT, or set the system date.

user $date --help

delpart

Tell the kernel to forget about a specified partition.

user $delpart --help

dmesg

Print or control the kernel messaging buffer.

user $dmesg --help

eject

Eject removable media via software control.

user $eject --help

fallocate

Preallocate space to, or deallocate space from a file.

user $fallocate --help

fdformat

Low-level format a floppy disk.

Command only available if the fdformat USE flag is set.

fdisk

Manipulate partition table.

user $fdisk --help

fincore

Count pages of file contents in core.

user $fincore --help

findfs

Find a filesystem by label or UUID.

user $findfs --help

findmnt

Find a (mounted) filesystem: list or search mounted filesystems.

user $findmnt --help

flock

Utilize serialization using file locks.

user $flock --help

fsck

Perform a file system check and repair.

Note
Other fsck.* tools may be provided by sys-fs/e2fsprogs (ext4), or sys-fs/dosfstools (fat), or other user space "helper" packages.
user $fsck --help

fsck.cramfs

Check and repair a compressed ROM filesystem.

Command only available if the cramfs USE flag is set.

Note
Other fsck.* tools may be provided by sys-fs/e2fsprogs, or sys-fs/dosfstools, or other packages.
user $fsck.cramfs --help

fsck.minix

Check the consistency of a Minix filesystem.

Note
Other fsck.* tools may be provided by sys-fs/e2fsprogs, or sys-fs/dosfstools, or other packages.
user $fsck.minix --help

fsfreeze

Suspend access to a filesystem.

user $fsfreeze --help

fstrim

Discard/trim unused blocks on a filesystem - useful for solid-state drives.

user $fstrim --help

getopt

Parse command options.

user $getopt --help

hardlink

Consolidate duplicate files using hardlinks.

Command only available if the hardlink USE flag is set.

user $hardlink --help

hexdump

Display file contents in hexadecimal, decimal, octal, or ascii. See also hex editor.

user $hexdump --help

hwclock

Time clocks utility.

user $hwclock --help

ionice

Show or change the I/O-scheduling class and priority of a process.

user $ionice --help

ipcmk

Create various IPC resources.

user $ipcmk --help

ipcrm

Remove certain IPC resources.

user $ipcrm --help

ipcs

Show information on IPC facilities.

user $ipcs --help

irqtop

Interactive utility to display kernel interrupt information.

user $irqtop --help

isosize

Show the length of an ISO-9660 filesystem.

user $isosize --help

kill

Send a signal to a process.

Command only available if the kill USE flag is set. See section at top of article.

last

Show a listing of last logged in users.

user $last --help

ldattach

Attach a line discipline to a serial line.

user $ldattach --help

line

Read one line.

user $line --help

logger

Enter messages into the system log.

Command only available if the logger USE flag is set.

user $logger --help

login

May belong to sys-apps/shadow. Begin session on the system. See man login, and login.

look

Display lines beginning with a specified string.

user $look --help

losetup

Control loop devices.

user $losetup --help

lsblk

List information about block devices.

user $lsblk --help

lscpu

Display information about the CPU architecture. See also hardware detection.

user $lscpu --help

lsfd

List file descriptors. See changelog on introduction of this command.

user $lsfd --help

lsipc

List System V inter-process communication (IPC) resources.

user $lsipc --help

lsirq

Utility to display kernel interrupt information.

user $lsirq --help

lslocks

List local system locks.

user $lslocks --help

lslogins

Display information about known users in the system.

user $lslogins --help

lsmem

List the ranges of available memory with their online status.

user $lsmem --help

lsns

List system namespaces.

user $lsns --help

mcookie

Generate magic cookies for xauth.

user $mcookie --help

mesg

Display (or do not display) messages from other users.

Command only available if the tty-helpers USE flag is set.

mkfs

Make a Linux filesystem.

user $mkfs --help

mkfs.bfs

Make an SCO bfs filesystem.

user $mkfs.bfs --help

mkfs.cramfs

Make cramfs compressed ROM file system.

user $mkfs.cramfs --help

mkfs.minix

Make a Minix filesystem.

user $mkfs.minix --help

mkswap

Create a swap area.

user $mkswap --help

more

A file perusal filter for CRT viewing. See pager.

user $more --help

mount

See mount.

mountpoint

Check whether a directory or file is a mountpoint.

user $mountpoint --help

namei

Follow a pathname until a terminal point is found.

user $namei --help

nsenter

Run a program with namespaces of other processes.

user $nsenter --help

partx

Tell the kernel about the presence and numbering of partitions.

user $partx --help

pg

Browse pagewise through text files.

user $pg --help

pivot_root

Change the root filesystem.

user $pivot_root --help

prlimit

Show or change the resource limits of a process.

user $prlimit --help

readprofile

Display kernel profiling information.

user $readprofile --help

rename

Rename files.

user $rename --help

renice

Alter the priority of running processes.

user $renice --help

resizepart

Tell the kernel about the new size of a partition.

user $resizepart --help

rev

Reverse lines characterwise.

user $rev --help

rfkill

Tool for enabling and disabling wireless devices.

user $rfkill --help

rtcwake

Enter a system sleep state until a specified wakeup time.

user $rtcwake --help

runuser

Run <command> with the effective user ID and group ID of <user>.

user $runuser --help

script

Make a typescript of a terminal session.

user $script --help

scriptlive

Execute terminal typescript.

user $scriptlive --help

scriptreplay

Play back terminal typescripts, using timing information.

user $scriptreplay --help

setarch

Change the reported architecture and set personality flags.

user $setarch --help

setpriv

Run a program with different Linux privilege settings.

Command only available if the caps USE flag is set.

setsid

Run a program in a new session.

user $setsid --help

setterm

Set the attributes of a terminal.

user $setterm --help

sfdisk

Display or manipulate a disk partition table.

user $sfdisk --help

su

Adopt the privileges of other users from the system. See su.

sulogin

Single-user login.

user $sulogin --help

swaplabel

Display or change the label or UUID of a swap area.

user $swaplabel --help

swapoff

Disable devices and files for paging and swapping.

user $swapoff --help

swapon

Enable devices and files for paging and swapping.

user $swapon --help

switch_root

Switch to another filesystem as the root of the mount tree.

user $switch_root --help

taskset

Show or change the CPU affinity of a process.

user $taskset --help

uclampset

Show or change the utilization clamping attributes.

user $uclampset --help

ul

Do underlining.

user $ul --help

umount

Unmount filesystems. See unmount a filesystem.

unshare

Run a program with some namespaces unshared from the parent.

user $unshare --help

utmpdump

Dump UTMP and WTMP files in raw format.

user $utmpdump --help

uuid

A daemon for generating UUIDs.

user $uuid --help

uuidgen

Create a new UUID value.

user $uuidgen --help

uuidparse

Parse unique identifiers.

user $uuidparse --help

wall

Write a message to all users.

Command only available if the tty-helpers USE flag is set.

wdctl

Show the status of the hardware watchdog.

user $wdctl --help

whereis

Locate the binary, source, and manual-page files for a command. See also sys-apps/which.

user $whereis --help

wipefs

Wipe signatures from a device.

user $wipefs --help

write

Send a message to another user.

Command only available if the tty-helpers USE flag is set.

zramctl

Set up and control zram devices.

user $zramctl --help

Listing commands

Installed utilities can be obtained by the following command:

user $cat /var/db/pkg/sys-apps/util-linux*/CONTENTS | grep bin | awk '{print $NF}' FS=/ | cut -d " " -f 1 | sort

Alternatively the following command can be used if the app-portage/portage-utils suite is installed:

user $qlist sys-apps/util-linux | grep bin | awk '{print $NF}' FS=/ | sort

Or if app-portage/gentoolkit is installed:

user $equery f util-linux | grep /bin

Troubleshooting

See also

  • GNU Coreutils — provide many of the basic commands of the UNIX(like) OS.