| 1 |
<!-- markdownlint-disable MD033 MD041 MD002 --> |
| 2 |
<!-- markdownlint-disable commands-show-output no-duplicate-heading --> |
| 3 |
<!-- spell-checker:ignore markdownlint ; (options) DESTDIR UTILNAME manpages reimplementation oranda libclang libcrypto FIPS --> |
| 4 |
<div class="oranda-hide"> |
| 5 |
<div align="center"> |
| 6 |
|
| 7 |
 |
| 8 |
|
| 9 |
# uutils coreutils |
| 10 |
|
| 11 |
[](https://crates.io/crates/coreutils) |
| 12 |
[](https://discord.gg/wQVJbvJ) |
| 13 |
[](https://github.com/uutils/coreutils/blob/main/LICENSE) |
| 14 |
[](https://deps.rs/repo/github/uutils/coreutils) |
| 15 |
|
| 16 |
[](https://codecov.io/gh/uutils/coreutils) |
| 17 |
[](https://hosted.weblate.org/projects/rust-coreutils/) |
| 18 |
|
| 19 |
</div> |
| 20 |
|
| 21 |
--- |
| 22 |
|
| 23 |
</div> |
| 24 |
|
| 25 |
uutils coreutils is a cross-platform reimplementation of the GNU coreutils in |
| 26 |
[Rust](http://www.rust-lang.org). While all programs have been implemented, some |
| 27 |
options might be missing or different behavior might be experienced. |
| 28 |
|
| 29 |
<div class="oranda-hide"> |
| 30 |
|
| 31 |
We provide prebuilt binaries, manpages, and shell completions from main branch at https://github.com/uutils/coreutils/releases/tag/latest-commit . |
| 32 |
The latest stable tag https://github.com/uutils/coreutils/releases/latest also exists for reproducible products and packagers. |
| 33 |
Bug reporters should use binary from latest commit. |
| 34 |
|
| 35 |
Minimal compatible glibc version is same with ubuntu-latest runner. Use `coreutils-*-musl` if `coreutils-*-gnu` is not compatible with your system. |
| 36 |
|
| 37 |
</div> |
| 38 |
|
| 39 |
<!-- markdownlint-disable-next-line MD026 --> |
| 40 |
|
| 41 |
## Goals |
| 42 |
|
| 43 |
uutils coreutils aims to be a drop-in replacement for the GNU utils. Differences with GNU |
| 44 |
are treated as bugs. |
| 45 |
|
| 46 |
Our key objectives include: |
| 47 |
- Matching GNU's output (stdout and error code) exactly |
| 48 |
- Better error messages: at a terminal, a parse error is shown as a |
| 49 |
compiler-style report with a caret under the argument at fault, where GNU |
| 50 |
prints a single line (see [error diagnostics](docs/src/extensions-errors.md)); |
| 51 |
scripts and pipes still get the plain GNU message |
| 52 |
- Providing comprehensive internationalization support (UTF-8) |
| 53 |
- Continuously improving performance; significant slowdowns relative to other coreutils implementations |
| 54 |
are treated as bugs |
| 55 |
- [Extensions](docs/src/extensions.md) when relevant (example: --progress) |
| 56 |
|
| 57 |
uutils aims to work on as many platforms as possible, to be able to use the same |
| 58 |
utils on Linux, macOS, *BSD, Windows, WASI and other platforms. This ensures, for example, |
| 59 |
that scripts can be easily transferred between platforms. |
| 60 |
|
| 61 |
uutils coreutils ships by default on Ubuntu since version 25.10. |
| 62 |
|
| 63 |
<div class="oranda-hide"> |
| 64 |
|
| 65 |
## Documentation |
| 66 |
uutils has both user and developer documentation available: |
| 67 |
|
| 68 |
- [User Manual](https://uutils.org/coreutils/docs/) |
| 69 |
- [Developer Documentation](https://docs.rs/crate/coreutils/) |
| 70 |
|
| 71 |
Both can also be generated locally, the instructions for that can be found in |
| 72 |
the [coreutils docs](https://github.com/uutils/uutils.github.io) repository. |
| 73 |
|
| 74 |
Use [weblate/rust-coreutils](https://hosted.weblate.org/projects/rust-coreutils/) to translate the Rust coreutils into your language. |
| 75 |
|
| 76 |
You can try the utilities in your browser through the |
| 77 |
[WebAssembly playground](https://uutils.org/playground/), without |
| 78 |
installing anything. |
| 79 |
|
| 80 |
<!-- ANCHOR: build (this mark is needed for mdbook) --> |
| 81 |
|
| 82 |
## Requirements |
| 83 |
|
| 84 |
- Rust (`cargo`, `rustc`) |
| 85 |
- GNU Make (optional) |
| 86 |
|
| 87 |
### Rust Version |
| 88 |
|
| 89 |
uutils follows Rust's release channels and is tested against stable, beta and |
| 90 |
nightly. |
| 91 |
|
| 92 |
## Building |
| 93 |
|
| 94 |
There are currently two methods to build the uutils binaries: either Cargo or |
| 95 |
GNU Make. |
| 96 |
|
| 97 |
> Building the full package, including all documentation, requires both Cargo |
| 98 |
> and GNU Make on a Unix platform. |
| 99 |
|
| 100 |
For either method, we first need to fetch the repository: |
| 101 |
|
| 102 |
```shell |
| 103 |
git clone https://github.com/uutils/coreutils |
| 104 |
cd coreutils |
| 105 |
``` |
| 106 |
|
| 107 |
### Cargo |
| 108 |
|
| 109 |
Building uutils using Cargo is easy because the process is the same as for every |
| 110 |
other Rust program: |
| 111 |
|
| 112 |
```shell |
| 113 |
cargo build --release |
| 114 |
``` |
| 115 |
|
| 116 |
Replace `--release` with `--profile=release-small` to optimize binary size. |
| 117 |
|
| 118 |
This command builds the most portable common core set of uutils into a multicall |
| 119 |
(BusyBox-type) binary, named 'coreutils', on most Rust-supported platforms. |
| 120 |
|
| 121 |
Additional platform-specific uutils are often available. Building these expanded |
| 122 |
sets of uutils for a platform (on that platform) is as simple as specifying it |
| 123 |
as a feature: |
| 124 |
|
| 125 |
```shell |
| 126 |
cargo build --release --features windows |
| 127 |
# or ... |
| 128 |
cargo build --release --features unix |
| 129 |
# or ... |
| 130 |
cargo build --release --target wasm32-wasip1 --no-default-features --features feat_wasm |
| 131 |
``` |
| 132 |
|
| 133 |
To build SELinux-specific features, including `chcon` and `runcon`, ensure that `libselinux` |
| 134 |
and `libclang` are installed on your system. Then, run the following command: |
| 135 |
``` |
| 136 |
cargo build --release --features unix,feat_selinux |
| 137 |
``` |
| 138 |
|
| 139 |
To speed up the checksum utilities (`md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, |
| 140 |
`sha384sum`, `sha512sum`, and `cksum`) by using OpenSSL's `libcrypto` instead of |
| 141 |
the pure-Rust digest crates, enable the `openssl` feature: |
| 142 |
``` |
| 143 |
cargo build --release --features openssl |
| 144 |
``` |
| 145 |
By default OpenSSL is built from source and statically linked into the |
| 146 |
binary, so no runtime dependency on system libcrypto/libssl is added. To link |
| 147 |
dynamically against the system libcrypto instead, set `OPENSSL_NO_VENDOR=1` at build time. |
| 148 |
MinGW (Windows) needs `OPENSSL_STATIC=0` too for dynamic linkage. |
| 149 |
|
| 150 |
The speedup is largest on CPUs without SHA-NI hardware acceleration. |
| 151 |
`aws-lc` backend is used on MSVC. Setting `AWS_LC_SYS_NO_JITTER_ENTROPY=1` |
| 152 |
at build time is recommended to reduce size of binary. |
| 153 |
|
| 154 |
If you don't want to build every utility available on your platform into the |
| 155 |
final binary, you can also specify which ones you want to build manually. For |
| 156 |
example: |
| 157 |
|
| 158 |
```shell |
| 159 |
cargo build --features "base32 cat echo rm" --no-default-features |
| 160 |
``` |
| 161 |
|
| 162 |
If you want to build the utilities as individual binaries, that is also possible: |
| 163 |
|
| 164 |
```shell |
| 165 |
cargo build --release --bins --workspace --exclude coreutils --exclude uu_runcon --exclude uu_chcon |
| 166 |
``` |
| 167 |
Each utility is contained in its own package within the main repository, named "uu_UTILNAME". To |
| 168 |
build selected individual utilities, use the `--package` [aka `-p`] option. For example: |
| 169 |
|
| 170 |
```shell |
| 171 |
cargo build -p uu_base32 -p uu_cat -p uu_echo -p uu_rm |
| 172 |
``` |
| 173 |
|
| 174 |
### GNU Make |
| 175 |
|
| 176 |
Building using `make` is a simple process as well. |
| 177 |
|
| 178 |
To simply build all available utilities (with debug profile): |
| 179 |
|
| 180 |
```shell |
| 181 |
make |
| 182 |
``` |
| 183 |
|
| 184 |
In release mode: |
| 185 |
|
| 186 |
```shell |
| 187 |
make PROFILE=release |
| 188 |
``` |
| 189 |
|
| 190 |
To build all but a few of the available utilities: |
| 191 |
|
| 192 |
```shell |
| 193 |
make SKIP_UTILS='UTILITY_1 UTILITY_2' |
| 194 |
``` |
| 195 |
|
| 196 |
To build only a few of the available utilities: |
| 197 |
|
| 198 |
```shell |
| 199 |
make UTILS='UTILITY_1 UTILITY_2' |
| 200 |
``` |
| 201 |
|
| 202 |
## Installation |
| 203 |
|
| 204 |
### Install with Cargo |
| 205 |
|
| 206 |
Likewise, installing can simply be done using: |
| 207 |
|
| 208 |
```shell |
| 209 |
cargo install --path . --locked |
| 210 |
``` |
| 211 |
|
| 212 |
This command will install uutils into Cargo's _bin_ folder (_e.g._ |
| 213 |
`$HOME/.cargo/bin`). |
| 214 |
|
| 215 |
This does not install files necessary for shell completion or manpages. For |
| 216 |
manpages or shell completion to work, use `GNU Make` or see |
| 217 |
`Manually install shell completions`/`Manually install manpages`. |
| 218 |
|
| 219 |
### Install with GNU Make |
| 220 |
|
| 221 |
To install all available utilities (PROFILE=release by default): |
| 222 |
|
| 223 |
```shell |
| 224 |
make install |
| 225 |
``` |
| 226 |
|
| 227 |
To install using `sudo` switch `-E` must be used: |
| 228 |
|
| 229 |
```shell |
| 230 |
sudo -E make install |
| 231 |
``` |
| 232 |
|
| 233 |
To install all but a few of the available utilities: |
| 234 |
|
| 235 |
```shell |
| 236 |
make SKIP_UTILS='UTILITY_1 UTILITY_2' install |
| 237 |
``` |
| 238 |
|
| 239 |
To install only a few of the available utilities: |
| 240 |
|
| 241 |
```shell |
| 242 |
make UTILS='UTILITY_1 UTILITY_2' install |
| 243 |
``` |
| 244 |
|
| 245 |
To install every program with a prefix (e.g. uu-echo uu-cat): |
| 246 |
|
| 247 |
```shell |
| 248 |
make PROG_PREFIX=uu- install |
| 249 |
``` |
| 250 |
|
| 251 |
To install the multicall binary: |
| 252 |
|
| 253 |
```shell |
| 254 |
make MULTICALL=y install |
| 255 |
``` |
| 256 |
|
| 257 |
Set install parent directory (default value is /usr/local): |
| 258 |
|
| 259 |
```shell |
| 260 |
# DESTDIR is also supported |
| 261 |
make PREFIX=/my/path install |
| 262 |
``` |
| 263 |
|
| 264 |
Installing with `make` installs shell completions for all installed utilities |
| 265 |
for `bash`, `fish` and `zsh`. Completions for `elvish` and `powershell` can also |
| 266 |
be generated; See `Manually install shell completions`. |
| 267 |
|
| 268 |
To skip installation of completions and manpages: |
| 269 |
|
| 270 |
```shell |
| 271 |
make COMPLETIONS=n MANPAGES=n install |
| 272 |
``` |
| 273 |
|
| 274 |
### Manually install shell completions |
| 275 |
|
| 276 |
The `uudoc` binary generates completions for the `bash`, `elvish`, |
| 277 |
`fish`, `powershell` and `zsh` shells to stdout. |
| 278 |
|
| 279 |
Install `uudoc` by |
| 280 |
```shell |
| 281 |
cargo install --bin uudoc --features uudoc --path . |
| 282 |
``` |
| 283 |
|
| 284 |
Then use the installed binary: |
| 285 |
```shell |
| 286 |
uudoc completion <utility> <shell> |
| 287 |
``` |
| 288 |
|
| 289 |
So, to install completions for `ls` on `bash` to |
| 290 |
`/usr/local/share/bash-completion/completions/ls`, run: |
| 291 |
|
| 292 |
```shell |
| 293 |
uudoc completion ls bash > /usr/local/share/bash-completion/completions/ls.bash |
| 294 |
``` |
| 295 |
|
| 296 |
Completion for prefixed `cp` with `uu-` on `zsh` is generated by |
| 297 |
```shell |
| 298 |
env PROG_PREFIX=uu- uudoc completion cp zsh |
| 299 |
``` |
| 300 |
|
| 301 |
### Manually install manpages |
| 302 |
|
| 303 |
To generate manpages, the syntax is: |
| 304 |
|
| 305 |
```bash |
| 306 |
uudoc manpage <utility> |
| 307 |
``` |
| 308 |
|
| 309 |
So, to install the manpage for `ls` to `/usr/local/share/man/man1/ls.1` run: |
| 310 |
|
| 311 |
```bash |
| 312 |
uudoc manpage ls > /usr/local/share/man/man1/ls.1 |
| 313 |
``` |
| 314 |
|
| 315 |
## Un-installation |
| 316 |
|
| 317 |
Un-installation differs depending on how you have installed uutils. If you used |
| 318 |
Cargo to install, use Cargo to uninstall. If you used GNU Make to install, use |
| 319 |
Make to uninstall. |
| 320 |
|
| 321 |
### Uninstall with Cargo |
| 322 |
|
| 323 |
To uninstall uutils: |
| 324 |
|
| 325 |
```shell |
| 326 |
cargo uninstall coreutils |
| 327 |
``` |
| 328 |
|
| 329 |
### Uninstall with GNU Make |
| 330 |
|
| 331 |
To uninstall all utilities: |
| 332 |
|
| 333 |
```shell |
| 334 |
make uninstall |
| 335 |
``` |
| 336 |
|
| 337 |
To uninstall every program with a set prefix: |
| 338 |
|
| 339 |
```shell |
| 340 |
make PROG_PREFIX=uu- uninstall |
| 341 |
``` |
| 342 |
|
| 343 |
To uninstall the multicall binary: |
| 344 |
|
| 345 |
```shell |
| 346 |
make MULTICALL=y uninstall |
| 347 |
``` |
| 348 |
|
| 349 |
To uninstall from a custom parent directory: |
| 350 |
|
| 351 |
```shell |
| 352 |
# DESTDIR is also supported |
| 353 |
make PREFIX=/my/path uninstall |
| 354 |
``` |
| 355 |
|
| 356 |
<!-- ANCHOR_END: build (this mark is needed for mdbook) --> |
| 357 |
|
| 358 |
## GNU test suite compatibility |
| 359 |
|
| 360 |
Below is the evolution of how many GNU tests uutils passes. A more detailed |
| 361 |
breakdown of the GNU test results of the main branch can be found |
| 362 |
[in the user manual](https://uutils.org/coreutils/docs/test_coverage.html). |
| 363 |
|
| 364 |
See <https://github.com/orgs/uutils/projects/1> for the main meta bugs |
| 365 |
(many are missing). |
| 366 |
|
| 367 |
 |
| 368 |
|
| 369 |
</div> <!-- close oranda-hide div --> |
| 370 |
|
| 371 |
## Contributing |
| 372 |
|
| 373 |
To contribute to uutils, please see [CONTRIBUTING](CONTRIBUTING.md). |
| 374 |
|
| 375 |
## License |
| 376 |
|
| 377 |
uutils is licensed under the MIT License - see the `LICENSE` file for details |
| 378 |
|
| 379 |
GNU Coreutils is licensed under the GPL 3.0 or later. |