rm is rmx,ls is lsx:108 tools in one binary

The GNU core utilities, everywhere

A GNU-compatible toolkit in Go: one binary, a library and a portable shell. The same flags, messages and exit statuses on Linux, macOS, Windows, in containers, in the browser and inside Go programs.

Runs on Linux · macOS · FreeBSD · Windows · the browser · Go programs

An animation of gnux in a terminal: listing a directory with lsx, counting lines with catx and wcx, removing a build directory with rmx, running a script through the gnux shell, and stopping an endless yesx with headx.
  1. lsx -la prints total 8 drwxr-xr-x 6 you staff 192 Oct 11 19:18 . drwxr-xr-x 26 you staff 832 Oct 11 19:18 .. -rw-r--r-- 1 you staff 7 Oct 11 19:18 README.md drwxr-xr-x 4 you staff 128 Oct 11 19:18 build -rw-r--r-- 1 you staff 50 Oct 11 19:18 notes.txt
  2. catx notes.txt | wcx -l prints 5
  3. rmx -rv build/ prints removed 'build/main.o' removed 'build/out/app' removed directory 'build/out' removed directory 'build/'
  4. gnux shell -c 'mkdirx -p src && touchx src/main.go && lsx src' prints main.go
  5. yesx | headx -3 prints y y y

108 tools, one binary

01Three ways

Three ways to reach it

The same engines sit behind all three, so a flag means the same thing wherever you reach it from.

  • 01rmx, cpx, lsx

    As commands

    Each tool is a command of its own and a subcommand of the one binary. Both forms answer to the GNU name too, so rm and gnux rm reach the same engine.

    Installation and usage guide
    An animation of gnux tools at a prompt: cpx copies a directory verbosely, mvx renames a file, and headx prints its first two lines.
    1. cpx -rv src backup prints 'src' -> 'backup' 'src/main.go' -> 'backup/main.go'
    2. mvx -v notes.txt todo.txt prints renamed 'notes.txt' -> 'todo.txt'
    3. headx -n 2 todo.txt prints buy milk ship gnux
  • 02import "github.com/braswelljr/gnux/core/rm"

    As a Go library

    Every tool is an importable engine. Pass the options its flags would set and the streams to use, and get an error back with the same diagnostics the command prints.

    Using gnux from Go
    An animation of a Go program that builds the rmx engine with recursive and verbose options and runs it on a build directory, then the output of go run.
    // rmx -rv build
    engine := rm.New(
        rm.Options{Recursive: true, Verbose: true},
        core.Stdio(),
    )
    err := engine.Run([]string{"build"})

    go run . prints removed 'build/main.o' removed directory 'build'

  • 03gnux shell

    As a portable shell

    A small POSIX sh subset whose commands are the tools, run in-process. Variables, pipes, redirection and && behave the same on every platform, Windows included.

    The gnux shell language
    An animation of the gnux shell: setting a variable, removing and recreating a directory tree with rmx and mkdirx, and echoing a message that uses the variable.
    1. OUT=dist prints nothing
    2. rmx -rf $OUT && mkdirx -pv $OUT/bin prints mkdirx: created directory 'dist' mkdirx: created directory 'dist/bin'
    3. echox "built $OUT" prints built dist

02Every OS

Same script, every OS

Linux, macOS and Windows are built and tested together. The command is the same, the output is the same, and so is the exit status.

  • Linux

    Number 01

    An animation of bash on Linux running catx piped into headx, then the gnux shell creating a directory tree with mkdirx, with the same output as the other platforms.
    1. catx todo.txt | headx -n 2 prints buy milk ship gnux
    2. gnux shell -c 'mkdirx -pv dist/bin' prints mkdirx: created directory 'dist' mkdirx: created directory 'dist/bin'
  • macOS

    Number 02

    An animation of zsh on macOS running catx piped into headx, then the gnux shell creating a directory tree with mkdirx, with the same output as the other platforms.
    1. catx todo.txt | headx -n 2 prints buy milk ship gnux
    2. gnux shell -c 'mkdirx -pv dist/bin' prints mkdirx: created directory 'dist' mkdirx: created directory 'dist/bin'
  • Windows

    Number 03

    An animation of PowerShell on Windows running catx piped into headx, then the gnux shell creating a directory tree with mkdirx, with the same output as the other platforms.
    1. catx todo.txt | headx -n 2 prints buy milk ship gnux
    2. gnux shell -c 'mkdirx -pv dist/bin' prints mkdirx: created directory 'dist' mkdirx: created directory 'dist/bin'

03Why gnux

Compatible where it counts. Better where it can be.

  • Binary

    Number 01

    One static binary

    Every tool in one file, built without cgo. Nothing to install alongside it, nothing that breaks when the system upgrades.

  • Portability

    Number 02

    The same everywhere

    Linux, macOS, FreeBSD, Windows and the browser run the same code, so a script prints the same output and exits with the same status on each.

  • Fixes

    Number 03

    Fixes, not just copies

    GNU flags and messages, minus its rough edges: dux reads trees in parallel, recursive chmodx refuses /, nicex and nohupx really work on Windows. Every difference is documented.

  • Themes

    Number 04

    Your colors, every tool

    More than fifty built-in themes, from Solarized and Xcode to iOS colors and monochrome. Pick one once with gnux theme and every tool uses it; pipes and scripts still get GNU's exact output.

04Tools

108 tools, and the names they answer to

Short flags combine, long flags take values, and diagnostics read as the originals do. Each tool runs as its own name, as its GNU name, or as a subcommand of gnux.

  • GNU name: arch

    Number 01

    archx

    Print machine architecture.

  • GNU name: b2sum

    Number 02

    b2sumx

    Print or check BLAKE2b (512-bit) checksums.

  • GNU name: base32

    Number 03

    base32x

    Encode or decode data in base32.

  • GNU name: base64

    Number 04

    base64x

    Encode or decode data in base64.

  • GNU name: basename

    Number 05

    basenamex

    Strip the directory and suffix from file names.

  • GNU name: basenc

    Number 06

    basencx

    Encode or decode data in one of several encodings.

  • GNU name: cat

    Number 07

    catx

    Concatenate files and print them on standard output.

  • GNU name: chgrp

    Number 08

    chgrpx

    Change group ownership.

  • GNU name: chmod

    Number 09

    chmodx

    Change file mode bits.

  • GNU name: chown

    Number 10

    chownx

    Change file owner and group.

  • GNU name: cksum

    Number 11

    cksumx

    Print or check checksums and byte counts.

  • GNU name: comm

    Number 12

    commx

    Compare two sorted files line by line.

  • GNU name: cp

    Number 13

    cpx

    Copy files and directories.

  • GNU name: csplit

    Number 14

    csplitx

    Split a file into sections determined by context lines.

  • GNU name: cut

    Number 15

    cutx

    Remove sections from each line of files.

  • GNU name: date

    Number 16

    datex

    Print the date and time.

  • GNU name: dd

    Number 17

    ddx

    Convert and copy a file, block by block.

  • GNU name: df

    Number 18

    dfx

    Report file system space usage.

  • GNU name: dircolors

    Number 19

    dircolorsx

    Print commands that set LS_COLORS, the colors of lsx --color.

  • GNU name: dirname

    Number 20

    dirnamex

    Strip the last component from file names.

  • GNU name: dir

    Number 21

    dirx

    List directory contents in columns, whether or not the output is a terminal.

  • GNU name: du

    Number 22

    dux

    Estimate file space usage.

  • GNU name: echo

    Number 23

    echox

    Display a line of text.

  • GNU name: env

    Number 24

    envx

    Run a program in a modified environment, or print the environment.

  • GNU name: expand

    Number 25

    expandx

    Convert tabs to spaces.

  • GNU name: expr

    Number 26

    exprx

    Evaluate an expression and print its value.

  • GNU name: factor

    Number 27

    factorx

    Print the prime factors of each specified integer NUMBER.

  • GNU name: false

    Number 28

    falsex

    Do nothing, unsuccessfully.

  • GNU name: find

    Number 29

    findx

    Search for files in a directory hierarchy.

  • GNU name: fmt

    Number 30

    fmtx

    Reformat each paragraph of text.

  • GNU name: fold

    Number 31

    foldx

    Wrap each input line to fit in a specified width.

  • GNU name: grep

    Number 32

    grepx

    Print the lines that match patterns.

  • GNU name: groups

    Number 33

    groupsx

    Print the groups a user is in.

  • GNU name: head

    Number 34

    headx

    Print the first part of each file.

  • GNU name: hostid

    Number 35

    hostidx

    Print the numeric identifier for the current host.

  • GNU name: hostname

    Number 36

    hostnamex

    Print the name of the current host system.

  • GNU name: id

    Number 37

    idx

    Print real and effective user and group IDs.

  • GNU name: install

    Number 38

    installx

    Copy files into place and set their mode, owner and group.

  • GNU name: join

    Number 39

    joinx

    Join lines of two files on a common field.

  • GNU name: kill

    Number 40

    killx

    Send a signal to processes, or list signals.

  • GNU name: link

    Number 41

    linkx

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

  • GNU name: ln

    Number 42

    lnx

    Make hard or symbolic links between files.

  • GNU name: logname

    Number 43

    lognamex

    Print the user's login name.

  • GNU name: ls

    Number 44

    lsx

    List information about files and directory contents.

  • GNU name: md5sum

    Number 45

    md5sumx

    Print or check MD5 (128-bit) checksums.

  • GNU name: mkdir

    Number 46

    mkdirx

    Create the DIRECTORY(ies), if they do not already exist.

  • GNU name: mkfifo

    Number 47

    mkfifox

    Make named pipes (FIFOs).

  • GNU name: mknod

    Number 48

    mknodx

    Make block or character special files, or named pipes.

  • GNU name: mktemp

    Number 49

    mktempx

    Create a temporary file or directory, safely, and print its name.

  • GNU name: mv

    Number 50

    mvx

    Move (rename) files and directories.

  • GNU name: nice

    Number 51

    nicex

    Run a program with modified scheduling priority.

  • GNU name: nl

    Number 52

    nlx

    Number lines of files.

  • GNU name: nohup

    Number 53

    nohupx

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

  • GNU name: nproc

    Number 54

    nprocx

    Print the number of processing units available.

  • GNU name: numfmt

    Number 55

    numfmtx

    Convert numbers to and from human-readable strings.

  • GNU name: od

    Number 56

    odx

    Dump files in octal and other formats.

  • GNU name: paste

    Number 57

    pastex

    Merge lines of files.

  • GNU name: pathchk

    Number 58

    pathchkx

    Check whether file names are valid or portable.

  • GNU name: pinky

    Number 59

    pinkyx

    Show who is logged in, or what is known about users: a lightweight finger.

  • GNU name: printenv

    Number 60

    printenvx

    Print all or part of the environment.

  • GNU name: printf

    Number 61

    printfx

    Format and print data.

  • GNU name: pr

    Number 62

    prx

    Paginate or columnate files for printing.

  • GNU name: ptx

    Number 63

    ptxx

    Produce a permuted index of the words in a text.

  • GNU name: pwd

    Number 64

    pwdx

    Print the full name of the current working directory.

  • GNU name: readlink

    Number 65

    readlinkx

    Print resolved symbolic links or canonical file names.

  • GNU name: realpath

    Number 66

    realpathx

    Print the resolved absolute file name.

  • GNU name: rmdir

    Number 67

    rmdirx

    Remove the DIRECTORY(ies), if they are empty.

  • GNU name: rm

    Number 68

    rmx

    Remove (unlink) files and directories.

  • GNU name: sed

    Number 69

    sedx

    Filter and transform text with a stream editor.

  • GNU name: seq

    Number 70

    seqx

    Print a sequence of numbers.

  • GNU name: sha1sum

    Number 71

    sha1sumx

    Print or check SHA-1 (160-bit) checksums.

  • GNU name: sha224sum

    Number 72

    sha224sumx

    Print or check SHA-224 (224-bit) checksums.

  • GNU name: sha256sum

    Number 73

    sha256sumx

    Print or check SHA-256 (256-bit) checksums.

  • GNU name: sha384sum

    Number 74

    sha384sumx

    Print or check SHA-384 (384-bit) checksums.

  • GNU name: sha512sum

    Number 75

    sha512sumx

    Print or check SHA-512 (512-bit) checksums.

  • GNU name: shred

    Number 76

    shredx

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

  • GNU name: shuf

    Number 77

    shufx

    Generate random permutations.

  • GNU name: sleep

    Number 78

    sleepx

    Delay for a specified amount of time.

  • GNU name: sort

    Number 79

    sortx

    Sort lines of text files.

  • GNU name: split

    Number 80

    splitx

    Split a file into pieces.

  • GNU name: stat

    Number 81

    statx

    Display file or file system status.

  • GNU name: stdbuf

    Number 82

    stdbufx

    Run a command with modified buffering of its standard streams.

  • GNU name: stty

    Number 83

    sttyx

    Print or change terminal line settings.

  • GNU name: sum

    Number 84

    sumx

    Print the checksum and block count of each FILE.

  • GNU name: sync

    Number 85

    syncx

    Synchronize cached writes to persistent storage.

  • GNU name: tac

    Number 86

    tacx

    Concatenate and print files in reverse.

  • GNU name: tail

    Number 87

    tailx

    Print the last part of each file, optionally following it as it grows.

  • GNU name: tee

    Number 88

    teex

    Copy standard input to each FILE, and also to standard output.

  • GNU name: test

    Number 89

    testx

    Check file types and compare values.

  • GNU name: timeout

    Number 90

    timeoutx

    Run a command with a time limit.

  • GNU name: touch

    Number 91

    touchx

    Update the access and modification times of each FILE to the current time.

  • GNU name: true

    Number 92

    truex

    Do nothing, successfully.

  • GNU name: truncate

    Number 93

    truncatex

    Shrink or extend the size of each FILE to the specified size.

  • GNU name: tr

    Number 94

    trx

    Translate, squeeze, and/or delete characters from standard input.

  • GNU name: tsort

    Number 95

    tsortx

    Write a totally ordered list consistent with the partial ordering in FILE.

  • GNU name: tty

    Number 96

    ttyx

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

  • GNU name: uname

    Number 97

    unamex

    Print system information.

  • GNU name: unexpand

    Number 98

    unexpandx

    Convert spaces to tabs.

  • GNU name: uniq

    Number 99

    uniqx

    Report or omit repeated lines.

  • GNU name: unlink

    Number 100

    unlinkx

    Call the unlink function to remove the specified file.

  • GNU name: uptime

    Number 101

    uptimex

    Tell how long the system has been running.

  • GNU name: users

    Number 102

    usersx

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

  • GNU name: vdir

    Number 103

    vdirx

    List directory contents in the long format.

  • GNU name: wc

    Number 104

    wcx

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

  • GNU name: whoami

    Number 105

    whoamix

    Print the user name associated with the current effective user ID.

  • GNU name: who

    Number 106

    whox

    Show who is logged on.

  • GNU name: xargs

    Number 107

    xargsx

    Build and run command lines from standard input.

  • GNU name: yes

    Number 108

    yesx

    Output a string repeatedly until killed.

05Install

Install

No cgo and no runtime dependencies. Link the tool names to the binary and each one is a command of its own.

  • Go

    Number 01

    Go

    Installs the gnux binary, then links each tool name to it.

    Go install
    go install github.com/braswelljr/gnux@latest
    bin="$(dirname "$(command -v gnux)")"
    for t in $(gnux --list); do ln -sf gnux "$bin/$t"; done
  • Release

    Number 02

    Release

    A prebuilt archive per platform, checked against checksums.txt.

    Release install
    v=v0.0.1
    curl -LO "https://github.com/braswelljr/gnux/releases/download/$v/gnux-$v-linux-amd64.tar.gz"
    tar -xzf "gnux-$v-linux-amd64.tar.gz"
    sudo mv "gnux-$v-linux-amd64/gnux" /usr/local/bin/
  • Docker

    Number 03

    Docker

    Build the image from a checkout and mount the directory to work on.

    Docker install
    git clone https://github.com/braswelljr/gnux && cd gnux
    docker build -t gnux .
    docker run --rm -v "$(pwd):/work" gnux lsx -la

Run it before you install it

The playground is the real gnux compiled to WebAssembly, on a filesystem held in memory. Every tool and the shell, and nothing leaves your machine.