2023-12-04 10:02:23 +00:00
---
obj: application
website: https://www.gnu.org/software/coreutils/
repo: https://git.savannah.gnu.org/git/coreutils.git
wiki: https://en.wikipedia.org/wiki/GNU_Core_Utilities
---
# GNU Core Utils
The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.
## base64
2024-01-17 08:00:45 +00:00
[base64 ](../../../files/Base64.md ) encode/decode data and print to standard output
2023-12-04 10:02:23 +00:00
Usage: `base64 [OPTION]... [FILE]`
### Flags
| Flag | Description |
| ---------------------- | --------------------------------------------- |
| `-d, --decode` | Decode Input |
| `-i, --ignore-garbage` | when decoding, ignore non-alphabet characters |
## basename
strip directory and suffix from filenames
Usage: `basename NAME`
## cat
concatenate files and print on the standard output
Usage: `cat [OPTION]... [FILE]...`
### Flags
| Flag | Description |
| ----------------------- | -------------------------------------------- |
| `-b, --number-nonblank` | number nonempty output lines, overrides `-n` |
| `-n, --number` | number all output lines |
## chmod
change file mode (permissions) bits
Usage: `chmod [OPTION]... OCTAL-MODE FILE...`
### Options
| Option | Description |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| `-c, --changes` | like verbose but report only when a change is made |
| `-f, --silent, --quiet` | suppress most error messages |
| `-v, --verbose` | output a diagnostic for every file processed |
| `--reference=RFILE` | use RFILE's mode instead of specifying MODE values. RFILE is always dereferenced if a symbolic link. |
| `-R, --recursive` | change files and directories recursively | |
## chown
change file owner and group
Usage: `chown [OPTION]... [OWNER][:[GROUP]] FILE...`
### Options
| Option | Description |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| `-c, --changes` | like verbose but report only when a change is made |
| `-f, --silent, --quiet` | suppress most error messages |
| `-v, --verbose` | output a diagnostic for every file processed |
| `--reference=RFILE` | use RFILE's owner and group rather than specifying OWNER:GROUP values. RFILE is always dereferenced. |
| `-R, --recursive` | operate on files and directories recursively |
## chroot
run command or interactive shell with special root directory
Usage: `chroot [OPTION] NEWROOT [COMMAND [ARG]...]`
## cksum
compute and verify file checksums
Usage: `cksum [OPTION]... [FILE]...`
### Options
| Option | Description |
| ---------------------- | ----------------------------- |
| `-a, --algorithm=TYPE` | select the digest type to use |
### Digests
- crc
- md5
- sha1
- sha224
- sha256
- sha384
- sha512
- blake2b
## cp
copy files and directories
Usage: `cp [OPTION]... SOURCE DEST`
### Options
| Option | Description |
| ---------------------------------- | --------------------------------------------------------------------------- |
| `-l, --link` | hard link files instead of copying |
| `-R, -r, --recursive` | copy directories recursively |
| `-s, --symbolic-link` | make symbolic links instead of copying |
| `-S, --suffix=SUFFIX` | override the usual backup suffix |
| `-t, --target-directory=DIRECTORY` | copy all SOURCE arguments into DIRECTORY |
| `--update[=UPDATE]` | control which existing files are updated; UPDATE={all,none,older(default)}. |
| `-u` | equivalent to `--update[=older]` |
| `-v, --verbose` | explain what is being done |
| `-x, --one-file-system` | stay on this file system |
| `-b` | Create a backup file if destination already exists |
## cut
remove sections from each line of files
Usage: `cut OPTION... [FILE]...`
### Options
| Option | Description |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `-d, --delimiter=DELIM` | use DELIM instead of TAB for field delimiter |
| `-f, --fields=LIST` | select only these fields; also print any line that contains no delimiter character, unless the `-s` option is specified |
| `-s, --only-delimited` | do not print lines not containing delimiters |
| `--output-delimiter=STRING` | use STRING as the output delimiter the default is to use the input delimiter |
## date
print or set the system date and time
Usage: `date [OPTION]... [+FORMAT]`
### Options
| Option | Description |
| ---------------------- | ------------------------------------------ |
| `-d, --date=STRING` | display time described by STRING |
| `-r, --reference=FILE` | display the last modification time of FILE |
| `-s, --set=STRING` | set time described by STRING |
## dd
convert and copy a file
Usage: `dd [OPERAND]...`
### Operands
| Operand | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bs=BYTES` | read and write up to BYTES bytes at a time (default: 512) |
| `count=N` | copy only N input blocks |
| `if=FILE` | read from FILE instead of stdin |
| `of=FILE` | write to FILE instead of stdout |
| `status=LEVEL` | The LEVEL of information to print to stderr; 'none' suppresses everything but error messages, 'noxfer' suppresses the final transfer statistics, 'progress' shows periodic transfer statistics |
## df
report file system space usage
Usage: `df [OPTION]... [FILE]...`
### Options
| Option | Description |
| ---------------------- | ---------------------------------------------------- |
| `-a, --all` | include pseudo, duplicate, inaccessible file systems |
| `-h, --human-readable` | print sizes in powers of 1024 (e.g., 1023M) |
| `-H, --si` | print sizes in powers of 1000 (e.g., 1.1G) |
| `-i, --inodes` | list inode information instead of block usage |
## dirname
strip last component from file name
Usage: `dirname [OPTION] NAME...`
## du
estimate file space usage
Usage: `du [OPTION]... [FILE]...`
### Options
| Option | Description |
| ---------------------- | -------------------------------------- |
| `-h, --human-readable` | print sizes in human readable format |
| `-s, --summarize` | display only a total for each argument |
## echo
display a line of text
Usage: `echo [OPTION]... [STRING]...`
### Options
| Option | Description |
| ------ | ----------------------------------------------------- |
| `-n` | do not output the trailing newline |
| `-e` | enable interpretation of backslash escapes |
| `-E` | disable interpretation of backslash escapes (default) |
### Backslash Interpretations
| Sequence | Meaning |
| -------- | ----------------------------------------- |
| \\ | backslash |
| \a | alert (BEL) |
| \b | backspace |
| \c | produce no further output |
| \e | escape |
| \f | form feed |
| \n | new line |
| \r | carriage return |
| \t | horizontal tab |
| \v | vertical tab |
| \0NNN | byte with octal value NNN (1 to 3 digits) |
| \xHH | byte with hexadecimal value HH (1 to 2) |
## env
run a program in a modified environment
2024-01-17 08:00:45 +00:00
Print [Environment Variables ](../../../linux/Environment%20Variables.md ) with only `env`
2023-12-04 10:02:23 +00:00
Usage: `env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]`
### Options
| Option | Description |
| -------------------------- | -------------------------------------------------- |
| `-i, --ignore-environment` | start with an empty environment |
| `-u, --unset=NAME` | remove variable from the environment |
| `-C, --chdir=DIR` | change working directory to DIR |
| `--block-signal[=SIG]` | block delivery of SIG signal(s) to COMMAND |
| `--ignore-signal[=SIG]` | set handling of SIG signal(s) to do nothing |
| `-v, --debug` | print verbose information for each processing step |
## false
do nothing, unsuccessfully
Usage: `false`
## head
output the first part of files
Usage: `head [OPTION]... [FILE]...`
### Options
| Option | Description |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `-c, --bytes=[-]NUM` | print the first NUM bytes of each file; with the leading '-', print all but the last NUM bytes of each file |
| `-n, --lines=[-]NUM` | print the first NUM lines instead of the first 10; with the leading '-', print all but the last NUM lines of each file |
| `-q, --quiet, --silent` | never print headers giving file names |
## id
print real and effective user and group IDs
Usage: `id [OPTION]... [USER]...`
### Option
| Option | Description |
| -------------- | -------------------------------------------- |
| `-g, --group` | print only the effective group ID |
| `-G, --groups` | print all group IDs |
| `-n, --name` | print a name instead of a number, for `-ugG` |
| `-u, --user` | print only the effective user ID |
## install
copy files and set attributes
Usage: `install [OPTION]... SOURCE... DIRECTORY`
### Options
| Option | Description |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `-b` | make a backup of each existing destination file |
| `-S, --suffix=SUFFIX` | override the usual backup suffix |
| `-C, --compare` | compare content of source and destination files, and if no change to content, ownership, and permissions, do not modify the destination at all |
| `-d, --directory` | treat all arguments as directory names; create all components of the specified directories |
| `-g, --group=GROUP` | set group ownership, instead of process' current group |
| `-m, --mode=MODE` | set permission mode (as in chmod), instead of rwxr-xr-x |
| `-o, --owner=OWNER` | set ownership (super-user only) |
| `-p, --preserve-timestamps` | apply access/modification times of SOURCE files to corresponding destination files |
| `-s, --strip` | strip symbol tables |
| `-t, --target-directory=DIRECTORY` | copy all SOURCE arguments into DIRECTORY |
| `-v, --verbose` | print the name of each created file or directory |
## kill
terminate a process
Usage: `kill [-signal|-s signal|-p] [-q value] [-a] [--timeout milliseconds signal] [--] pid|name...`
### Options
| Option | Description |
| --------------------- | -------------------------------------------------------------------------------- |
| `-s, --signal signal` | The signal to send. It may be given as a name or a number. |
| `-p, --pid` | Only print the process ID (PID) of the named processes, do not send any signals. |
| `--verbose` | Print PID(s) that will be signaled with kill along with the signal. |
## ln
make links between files
Usage: `ln [OPTION]... TARGET LINK_NAME`
### Options
| Option | Description |
| ---------------------------------- | -------------------------------------------------- |
| `-s, --symbolic` | make symbolic links instead of hard links |
| `-t, --target-directory=DIRECTORY` | specify the DIRECTORY in which to create the links |
| `-v, --verbose` | print name of each linked file |
## ls
list directory contents
Usage: `ls [OPTION]... [FILE]...`
### Options
| Option | Description |
| ---------------------- | --------------------------------------------------- |
| `-a, --all` | do not ignore entries starting with . |
| `-h, --human-readable` | with `-l` print sizes like 1K 234M 2G etc |
| `-I, --ignore=PATTERN` | do not list implied entries matching shell PATTERN |
| `-l` | use a long listing format |
| `-r, --reverse` | reverse order while sorting |
| `-R, --recursive` | list subdirectories recursively |
## mkdir
make directories
Usage: `mkdir [OPTION]... DIRECTORY...`
### Options
| Option | Description |
| ----------------- | ----------------------------------------------------------------------------------------------------------- |
| `-m, --mode=MODE` | set file mode (as in chmod), not a=rwx - umask |
| `-p, --parents` | no error if existing, make parent directories as needed, with their file modes unaffected by any -m option. |
| `-v, --verbose` | print a message for each created directory |
## mkfifo
make FIFOs (named pipes)
Usage: `mkfifo [OPTION]... NAME...`
## mv
move (rename) files
Usage: `mv [OPTION]... SOURCE... DIRECTORY`
### Options
| Option | Description |
| ---------------------------------- | ------------------------------------------------ |
| `-b` | make a backup of each existing destination file |
| `-S, --suffix=SUFFIX` | override the usual backup suffix |
| `-t, --target-directory=DIRECTORY` | copy all SOURCE arguments into DIRECTORY |
| `-v, --verbose` | print the name of each created file or directory |
## nl
number lines of files
Usage: `nl [FILE]...`
## nproc
print the number of processing units available
Usage: `nproc`
## pwd
print name of current/working directory
Usage: `pwd`
## readlink
print resolved symbolic links or canonical file names
Usage: `readlink [OPTION]... FILE...`
### Options
| Option | Description |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `-f, --canonicalize` | canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist |
| `-e, --canonicalize-existing` | canonicalize by following every symlink in every component of the given name recursively, all components must exist |
| `-m, --canonicalize-missing` | canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence |
| `-n, --no-newline` | do not output the trailing delimiter |
## realpath
print the resolved path
Usage: `realpath [OPTION]... FILE...`
### Options
| Option | Description |
| ----------------------------- | ----------------------------------------------- |
| `-e, --canonicalize-existing` | all components of the path must exist |
| `-m, --canonicalize-missing` | no path components need exist or be a directory |
| `-L, --logical` | resolve '..' components before symlinks |
| `--relative-to=DIR` | print the resolved path relative to DIR |
| `--relative-base=DIR` | print absolute paths unless paths below DIR |
| `-s, --strip, --no-symlinks` | don't expand symlinks |
## rm
remove files or directories
Usage: `rm [OPTION]... [FILE]...`
### Options
| Option | Description |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-f, --force` | ignore nonexistent files and arguments, never prompt |
| `-i` | prompt before every removal |
| `--one-file-system` | when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument |
| `-r, -R, --recursive` | remove directories and their contents recursively |
| `-d, --dir` | remove empty directories |
| `-v, --verbose` | explain what is being done |
## rmdir
remove empty directories
Usage: `rmdir [OPTION]... DIRECTORY...`
### Options
| Option | Description |
| --------------- | ------------------------------------------------------------------------------------ |
| `-p, --parents` | remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b' is similar to 'rmdir a/b a' |
| `-v, --verbose` | output a diagnostic for every directory processed |
## seq
print a sequence of numbers
Usage:
- `seq [OPTION]... LAST`
- `seq [OPTION]... FIRST LAST`
- `seq [OPTION]... FIRST INCREMENT LAST`
### Options
| Option | Description |
| ------------------------ | --------------------------------------------- |
| `-f, --format=FORMAT` | use printf style floating-point FORMAT |
| `-s, --separator=STRING` | use STRING to separate numbers (default: \n) |
| `-w, --equal-width` | equalize width by padding with leading zeroes |
## shred
overwrite a file to hide its contents, and optionally delete it
Usage: `shred [OPTION]... FILE...`
### Options
| Option | Description |
| ---------------------- | ------------------------------------------------ |
| `-f, --force` | change permissions to allow writing if necessary |
| `-n, --iterations=N` | overwrite N times instead of the default (3) |
| `--random-source=FILE` | get random bytes from FILE |
## shuf
generate random permutations
Usage: `shuf [OPTION]... [FILE]`
### Options
| Option | Description |
| ------------------------- | ------------------------------------------------ |
| `-i, --input-range=LO-HI` | treat each number LO through HI as an input line |
| `-n, --head-count=COUNT` | output at most COUNT lines |
| `-o, --output=FILE` | write result to FILE instead of standard output |
| `--random-source=FILE` | get random bytes from FILE |
| `-r, --repeat` | output lines can be repeated |
## sleep
delay for a specified amount of time
Usage: `sleep NUMBER[SUFFIX]...`
## sort
sort lines of text files
Usage: `sort [OPTION]... [FILE]...`
### Options
| Option | Description |
| ----------------------------- | ------------------------------------------------ |
| `-b, --ignore-leading-blanks` | ignore leading blanks |
| `-d, --dictionary-order` | consider only blanks and alphanumeric characters |
| `-f, --ignore-case` | fold lower case to upper case characters |
| `-g, --general-numeric-sort` | compare according to general numerical value |
| `-i, --ignore-nonprinting` | consider only printable characters |
| `-M, --month-sort` | compare (unknown) < 'JAN' < ... < ' DEC ' |
| `-h, --human-numeric-sort` | compare human readable numbers (e.g., 2K 1G) |
| `-n, --numeric-sort` | compare according to string numerical value |
| `-r, --reverse` | reverse the result of comparisons |
## split
split a file into pieces
Usage: `split [OPTION]... [FILE [PREFIX]]`
### Options
| Option | Description |
| ---------------------------- | --------------------------------------------------------- |
| `-a, --suffix-length=N` | generate suffixes of length N (default 2) |
| `--additional-suffix=SUFFIX` | append an additional SUFFIX to file names |
| `-b, --bytes=SIZE` | put SIZE bytes per output file |
| `-C, --line-bytes=SIZE` | put at most SIZE bytes of records per output file |
| `-d` | use numeric suffixes starting at 0, not alphabetic |
| `--numeric-suffixes[=FROM]` | same as `-d` , but allow setting the start value |
| `-x` | use hex suffixes starting at 0, not alphabetic |
| `--hex-suffixes[=FROM]` | same as `-x` , but allow setting the start value |
| `-l, --lines=NUMBER` | put NUMBER lines/records per output file |
| `-n, --number=CHUNKS` | generate CHUNKS output files; see explanation below |
| `--verbose` | print a diagnostic just before each output file is opened |
## stat
display file or file system status
Usage: `stat [OPTION]... FILE...`
### Options
| Option | Description |
| --------------------- | ------------------------------------------------------------------------------------------ |
| `-L, --dereference` | follow links |
| `-f, --file-system` | display file system status instead of file status |
| `-c --format=FORMAT` | use the specified FORMAT instead of the default; output a newline after each use of FORMAT |
### Format Modifiers
| Format | Description |
| ------ | ---------------------------------------------------------------------- |
| %a | permission bits in octal (note '#' and '0' printf flags) |
| %A | permission bits and file type in human readable form |
| %b | number of blocks allocated (see %B) |
| %B | the size in bytes of each block reported by %b |
| %C | SELinux security context string |
| %d | device number in decimal (st_dev) |
| %D | device number in hex (st_dev) |
| %Hd | major device number in decimal |
| %Ld | minor device number in decimal |
| %f | raw mode in hex |
| %F | file type |
| %g | group ID of owner |
| %G | group name of owner |
| %h | number of hard links |
| %i | inode number |
| %m | mount point |
| %n | file name |
| %N | quoted file name with dereference if symbolic link |
| %o | optimal I/O transfer size hint |
| %s | total size, in bytes |
| %r | device type in decimal (st_rdev) |
| %R | device type in hex (st_rdev) |
| %Hr | major device type in decimal, for character/block device special files |
| %Lr | minor device type in decimal, for character/block device special files |
| %t | major device type in hex, for character/block device special files |
| %T | minor device type in hex, for character/block device special files |
| %u | user ID of owner |
| %U | user name of owner |
| %w | time of file birth, human-readable; - if unknown |
| %W | time of file birth, seconds since Epoch; 0 if unknown |
| %x | time of last access, human-readable |
| %X | time of last access, seconds since Epoch |
| %y | time of last data modification, human-readable |
| %Y | time of last data modification, seconds since Epoch |
| %z | time of last status change, human-readable |
| %Z | time of last status change, seconds since Epoch |
| %a | free blocks available to non-superuser |
| %b | total data blocks in file system |
| %c | total file nodes in file system |
| %d | free file nodes in file system |
| %f | free blocks in file system |
| %i | file system ID in hex |
| %l | maximum length of filenames |
| %n | file name |
| %s | block size (for faster transfers) |
| %S | fundamental block size (for block counts) |
| %t | file system type in hex |
| %T | file system type in human readable form |
## tac
concatenate and print files in reverse
Usage: `tac [FILE]...`
## tail
output the last part of files
Usage: `tail [OPTION]... [FILE]...`
### Options
| Option | Description |
| -------------------- | ---------------------------------------------------------------------------------------------------- |
| `-c, --bytes=[+]NUM` | output the last NUM bytes; or use `-c` +NUM to output starting with byte NUM of each file |
| `-f` | output appended data as the file grows; |
| `-n, --lines=[+]NUM` | output the last NUM lines, instead of the last 10; or use `-n` +NUM to skip NUM-1 lines at the start |
| `--pid=PID` | with `-f` , terminate after process ID, PID dies |
## tee
read from standard input and write to standard output and files
Usage: `tee [OPTION]... [FILE]...`
### Options
| Option | Description |
| -------------- | ------------------------------------------- |
| `-a, --append` | append to the given FILEs, do not overwrite |
## touch
change file timestamps
Usage: `touch [OPTION]... FILE...`
### Options
| Option | Description |
| ---------------------- | ----------------------------------------------- |
| `-a` | change only the access time |
| `-c, --no-create` | do not create any files |
| `-d, --date=STRING` | parse STRING and use it instead of current time |
| `-r, --reference=FILE` | use this file's times instead of current time |
## tr
translate or delete characters
Usage: `tr [OPTION]... STRING1 [STRING2]`
### Options
| Option | Description |
| -------------- | ---------------------------------------------- |
| `-d, --delete` | delete characters in STRING1, do not translate |
## true
do nothing, successfully
Usage: `true`
## truncate
shrink or extend the size of a file to the specified size
Usage: `truncate OPTION... FILE...`
### Options
| Option | Description |
| ----------------------- | ----------------------------------------- |
| `-c, --no-create` | do not create any files |
| `-r, --reference=RFILE` | base size on RFILE |
| `-s, --size=SIZE` | set or adjust the file size by SIZE bytes |
## uname
print system information
Usage: `uname [OPTION]...`
### Options
| Option | Description |
| ---------------------- | ------------------------------- |
| `-a, --all` | print all information |
| `-s, --kernel-name` | print the kernel name |
| `-n, --nodename` | print the network node hostname |
| `-r, --kernel-release` | print the kernel release |
| `-v, --kernel-version` | print the kernel version |
| `-m, --machine` | print the machine hardware name |
## uniq
report or omit repeated lines
Usage: `uniq [OPTION]... [INPUT [OUTPUT]]`
### Options
| Option | Description |
| -------------------- | ---------------------------------------------- |
| `-c, --count` | prefix lines by the number of occurrences |
| `-d, --repeated` | only print duplicate lines, one for each group |
| `-i, --ignore-case` | ignore differences in case when comparing |
| `-s, --skip-chars=N` | avoid comparing the first N characters |
| `-u, --unique` | only print unique lines |
## uptime
Tell how long the system has been running
Usage: `uptime [options]`
### Options
| Option | Description |
| -------------- | ---------------------------------------------- |
| `-p, --pretty` | show uptime in pretty format |
| `-s, --since` | system up since, in yyyy-mm-dd HH:MM:SS format |
## wc
print newline, word, and byte counts for each file
Usage: `wc [OPTION]... [FILE]...`
### Options
| Option | Description |
| ------------- | -------------------------- |
| `-c, --bytes` | print the byte counts |
| `-m, --chars` | print the character counts |
| `-l, --lines` | print the newline counts |
| `-w, --words` | print the word counts |
## whoami
print effective user name
Usage: `whoami`