Native Windows CMD (Server 2003) ported to Termux — Zero dependencies, zero emulation, pure ELF ARM64.
termux-cmd is a native port of Microsoft's Windows Server 2003 cmd.exe to Termux (Android/Linux ARM64). No chroot, no proot, no Wine, no Box64/QEMU — just a clean ELF binary built with Termux's clang toolchain against bionic libc.
| Approach | Status |
|---|---|
proot-distro + Windows |
❌ Slow, heavy |
wine / box86 / box64 |
❌ x86 emulation overhead |
qemu-user |
❌ Syscall translation latency |
| This project | ✅ Native ARM64, direct syscalls |
| Category | Commands |
|---|---|
| Navigation | cd, chdir, pwd |
| Filesystem | dir, type, copy, del, ren, move, md, rd |
| Attributes | attrib |
| Environment | set, path, ver, vol |
| Batch/Control | if, for, goto, call, shift, pause, rem |
| Console | cls, echo, title, prompt, date, time |
| Redirection | >, >>, <, ` |
| Wildcards | *, ? with recursive /s support |
- ✅ Batch scripts (
.bat,.cmd) — full parser - ✅ Interactive mode — prompt, history, tab-completion
- ✅ Pipe/Redirect — stdin/stdout/stderr
- ✅ Unicode/ANSI — CP437/CP850/UTF-8 via iconv shim
⚠️ External executables — limited (no PE loader, usesCreateProcessshim →execve)
- Termux (F-Droid or GitHub release)
clang,make,git(for building)
pkg install clang make git# Download latest release
curl -L -o cmd https://github.com/rianprei/termux-cmd/releases/latest/download/cmd-arm64
chmod +x cmd
mv cmd $PREFIX/bin/cmdgit clone https://github.com/rianprei/termux-cmd.git
cd termux-cmd
make clean && make
cp cmd.exe $PREFIX/bin/cmdcmd /c "ver && echo OK"
# Microsoft Windows [Version 4.0.0000]
# OK$ cmd
Microsoft Windows [Version 4.0.0000]
(C) Copyright 1985-2003 Microsoft Corp.
C:\data\data\com.termux\files\home>dir
Volume in drive C is ROOT
Volume Serial Number is 1234-5678
Directory of C:\data\data\com.termux\files\home
08/11/2026 14:30 <DIR> .
08/11/2026 14:30 <DIR> ..
08/11/2026 14:25 123 test.txt
1 File(s) 123 bytes
2 Dir(s) 0 bytes free
C:\data\data\com.termux\files\home># Single command
cmd /c "dir /b"
# Batch file
cmd /c script.bat
# Interactive with init script
cmd /k init.bat| Windows | Termux |
|---|---|
C:\ |
/ |
C:\Users\ |
/data/data/com.termux/files/home/ |
C:\Windows\System32 |
/system/bin/ |
D:\ |
/sdcard/ (if mounted) |
┌─────────────────────────────────────────────────────────────┐
│ termux-cmd (ELF ARM64) │
├─────────────────────────────────────────────────────────────┤
│ cmd.c / cmdexec.c │ Core interpreter, dispatcher │
│ clex.c / cparse.c │ Lexer, parser, tokenizer │
│ ctools*.c │ Path, file, string utilities │
│ cpwork.c / cfile.c │ Copy/move/rename/attrib implementations│
│ dir.c / display.c │ Directory listing, formatting │
│ cenv.c / cpath.c │ Environment, PATH handling │
├─────────────────────────────────────────────────────────────┤
│ portable/ (POSIX Shim Layer) │
│ ├── _file.c │ CreateFile, ReadFile, GetFullPathName │
│ ├── _find.c │ FindFirstFile, FindNextFile (glob) │
│ ├── _msg.c │ FormatMessage, message tables │
│ ├── _locale.c │ GetLocaleInfo, GetTime/DateFormat │
│ ├── _path.c │ _splitpath, DOS↔UNIX path conversion │
│ ├── _time.c │ Time/date helpers │
│ ├── _error.c │ GetLastError/SetLastError │
│ └── compat.h │ Win32 type definitions, inline shims │
└─────────────────────────────────────────────────────────────┘
| Challenge | Solution |
|---|---|
Win32 HANDLE → POSIX fd |
Dual handle table (low=fd, high=FILE*) |
C:\path → /path |
DOSPath2UNIXPath / UNIXPath2DOSPath |
FindFirstFile |
glob() with GLOB_PERIOD |
FormatMessage |
Custom message table + snprintf |
GetLocaleInfo |
Hardcoded PT-BR locale data |
GetTimeFormat |
strftime with Windows→POSIX format conversion |
| Document | Description |
|---|---|
| Installation Guide | Detailed build/install steps |
| Command Reference | All supported commands with syntax |
| Batch Scripting | Writing .bat/.cmd scripts |
| Architecture | Deep dive into internals |
| Porting Guide | Adding new commands/shims |
| Troubleshooting | Common issues & fixes |
# Clean build
make clean && make
# Debug build (with symbols)
CFLAGS="-g -O0 -fno-omit-frame-pointer" make
# Run tests
make testtermux-cmd/
├── *.c, *.h # Core source (from Win2K3 leak)
├── portable/ # POSIX shim layer
│ ├── *.c, *.h
│ └── compat.h # Win32 typedefs + inline shims
├── Makefile # Build system
├── cmdmsg.mc # Message compiler input
├── parsemsg.py # Message compiler (Python)
├── docs/ # Documentation
├── tests/ # Test suite
├── scripts/ # Build/release helpers
└── .github/ # CI/CD workflows
- Add prototype to
cmdproto.h - Add entry to
aAllCommands[]incmdexec.c - Implement
cmdexec_CmdXxx()incmdexec.c - Add help strings to
cmdmsg.mc - Run
python3 parsemsg.pyto regeneratecmdmsg.c - Rebuild:
make clean && make
# Run full test suite
./run_tests.sh
# Individual test categories
./test_builtins.sh # Core commands
./test_batch.sh # Batch scripting
./test_paths.sh # Path translation
./test_wildcards.sh # Glob/pattern matching- GitHub Actions: builds on every push
- Tests run on ARM64 Termux container
- Artifacts uploaded as release candidates
| Version | Target |
|---|---|
| 1.0 | ✅ Core commands, batch, pipes |
| 1.1 | External executable support (PE loader stub) |
| 1.2 | Tab completion, command history |
| 1.3 | Unicode/UTF-8 full support |
| 2.0 | Plugin system for custom commands |
See CONTRIBUTING.md for guidelines.
- Code follows existing style (K&R, tabs=4)
- New shims go in
portable/ - Message strings in
cmdmsg.mc - Tests added for new functionality
- Documentation updated
MIT License — see LICENSE for details.
This project is based on Microsoft Windows Server 2003 cmd.exe source code (leaked 2004, publicly archived). Original copyright Microsoft Corporation. This port contains significant modifications for POSIX/Termux compatibility.
- Microsoft — Original
cmd.exesource (Windows Server 2003) - Termux Team — Excellent ARM64 Linux environment
- Community — Testing, bug reports, patches
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Email security@rianprei.com
Made with ❤️ for the Termux community
Native Windows CMD on Android — no emulation required