GNU Coreutils

From Gentoo Wiki
Jump to:navigation Jump to:search

The coreutils package contains the GNU coreutils, which provide many of the basic commands of the UNIX(like) OS.

These commands are provided for quick reference only, with some Gentoo specific notes. For up to date and in depth documentation, see the local --help options and man pages for each command.

These commands are powerful, but beware that this means that data loss may be incurred in case of misuse. Always backup important data. Pay particular attention when working with escalated privileges.

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

Installation

The coreutils package is part of the system set so it should not need installing.

Usage

Depending on the shell used, some of these commands may be pre-empted by shell builtins.

arch

Print machine hardware name (same as uname -m).

user $arch --help

b2sum

Compute and check BLAKE2 message digest.

user $b2sum --help

base32

Base32 encode/decode data and print to standard output.

user $base32 --help

base64

Base64 encode/decode data and print to standard output.

user $base64 --help

basename

Strip directory and suffix from filenames.

user $basename --help

basenc

Encode/decode data and print to standard output.

user $basenc --help

cat

Concatenate files and print on the standard output.

user $cat --help

chcon

Change file security context.

user $chcon --help

chgrp

Change group ownership.

user $chgrp --help

chmod

Change file mode bits.

user $chmod --help

chown

Change file owner and group.

user $chown --help

chroot

Run command or interactive shell with special root directory.

user $chroot --help

cksum

Checksum and count the bytes in a file.

user $cksum --help

comm

Compare two sorted files line by line.

user $comm --help

cp

Copy files and directories.

user $cp --help

csplit

Split a file into sections determined by context lines.

user $csplit --help

cut

Remove sections from each line of files.

user $cut --help

date

Print or set the system date and time.

user $date --help

dd

Convert and copy a file. See the dd article.

user $dd --help
Warning
Misuse of the dd command can easily result in severe data loss.

df

Report file system disk space usage.

user $df --help

dir

List directory contents.

user $dir --help

dircolors

Color setup for ls.

user $dircolors --help

dirname

Strip last component from file name.

user $dirname --help

du

Estimate file space usage.

user $du --help

echo

Display a line of text.

user $/bin/echo --help

n.b. Some shells have an echo command built in, which is why this needs the /bin prefix to return the help text.

env

Run a program in a modified environment.

user $env --help

expand

Convert tabs to spaces.

user $expand --help

expr

Evaluate expressions.

user $expr --help

factor

Factor numbers.

user $factor --help

false

Do nothing, unsuccessfully.

user $/bin/false --help

n.b. Some shells have a false command built in, which is why this needs the /bin prefix to return the help text.

fmt

Simple optimal text formatter.

user $fmt --help

fold

Wrap each input line to fit in specified width.

user $fold --help

head

Output the first part of files.

user $head --help

hostid

Print the numeric identifier for the current host.

user $hostid --help

id

Print real and effective user and group IDs.

user $id --help

install

Copy files and set attributes.

user $install --help

join

Join lines of two files on a common field.

user $join --help

link

Call the link function to create a link to a file.

user $link --help

ln

Make links between files.

user $ln --help

logname

Print user's login name.

user $logname --help

ls

List directory contents.

user $ls --help

md5sum

Compute and check MD5 message digest.

user $md5sum --help

mkdir

Make directories.

user $mkdir --help

mkfifo

Make FIFOs (named pipes).

user $mkfifo --help

mknod

Make block or character special files.

user $mknod --help

mktemp

Create a temporary file or directory.

user $mktemp --help

mv

Move (rename) files.

user $mv --help

nice

Run a program with modified scheduling priority.

user $nice --help

nl

Number lines of files.

user $nl --help

nohup

Run a command immune to hangups, with output to a non-tty.

user $nohup --help

nproc

Print the number of processing units available.

user $nproc --help

numfmt

Convert numbers from/to human-readable strings.

user $numfmt --help

od

Dump files in octal and other formats.

user $od --help

paste

Merge lines of files.

user $paste --help

pathchk

Check whether file names are valid or portable.

user $pathchk --help

pinky

Lightweight finger. Print user informtion.

user $pinky --help

pr

Convert text files for printing.

user $pr --help

printenv

Print all or part of environment.

user $printenv --help

printf

Display text according to a format string.

user $/usr/bin/printf --help

n.b. Some shells have a printf command built in, which is why this needs the /usr/bin prefix to return the help text.

ptx

Produce a permuted index of file contents.

user $ptx --help

pwd

Output the current working directory.

user $pwd --help

n.b. Some shells have a pwd builtin, which is why this needs the /bin prefix to return the help text.

readlink

Print resolved symbolic links or canonical file names.

user $readlink --help

realpath

Print the resolved path.

user $realpath --help

rm

Remove files or directories.

user $rm --help
Warning
The rm command is irrevocable. The --recursive option can induce massive data loss if used carelessly.

rmdir

Remove empty directories.

user $rmdir --help
Warning
The rmdir command is irrevocable. It can induce massive data loss if used carelessly.

runcon

Run command with specified security context.

user $runcon --help

seq

Print a sequence of numbers.

user $seq --help

sha1sum

Compute and check SHA1 message digest.

user $sha1sum --help

sha224sum

Compute and check SHA224 message digest.

user $sha224sum --help

sha256sum

Compute and check SHA256 message digest.

user $sha256sum --help

sha384sum

Compute and check SHA384 message digest.

user $sha384sum --help

sha512sum

Compute and check SHA512 message digest.

user $sha512sum --help

shred

Overwrite a file to hide its contents, and optionally delete it.

user $shred --help
Warning
Of course the shred command will result in permanent data loss - by design.

shuf

Generate random permutations.

user $shuf --help

sleep

Delay for a specified amount of time.

user $sleep --help

sort

Sort lines of text files.

user $sort --help

split

Split a file into pieces.

user $split --help

stat

Display file or file system status.

user $stat --help

stdbuf

Run COMMAND, with modified buffering operations for its standard streams.

user $stdbuf --help

stty

Change and print terminal line settings.

user $stty --help

sum

Checksum and count the blocks in a file.

user $sum --help

sync

Synchronize cached writes to persistent storage.

user $sync --help

tac

Concatenate and print files in reverse.

user $tac --help

tail

Output the last part of files.

user $tail --help

tee

Read from standard input and write to standard output and files.

user $tee --help

test

Perform tests on files and text.

/usr/bin/test command does not seem to have --help option.

timeout

Run a command with a time limit.

user $timeout --help

touch

Change file timestamps.

user $touch --help

tr

Translate or delete characters.

user $tr --help

true

Return a successful result.

user $/bin/true --help

n.b. Some shells have a true command built in, which is why this needs the /bin prefix to return the help text.

truncate

Shrink or extend the size of a file to the specified size.

user $truncate --help

tsort

Perform topological sort.

user $tsort --help

tty

Print the file name of the terminal connected to standard input.

user $tty --help

uname

Print system information.

user $uname --help

unexpand

Convert spaces to tabs.

user $unexpand --help

uniq

Report or omit repeated lines.

user $uniq --help

unlink

Call the unlink function to remove the specified file.

user $unlink --help

users

Print the user names of users currently logged in to the current host.

user $users --help

vdir

List directory contents.

user $vdir --help

wc

Print newline, word, and byte counts for each file.

user $wc --help

who

Show who is logged on.

user $who --help

whoami

Print effective userid.

user $whoami --help

yes

Output a string repeatedly until killed.

user $yes --help

See also

  • util-linux — contains userspace utilities for Linux-specific system management, including device control, terminal logins, process management, and tty messaging.