Windows 下的 GNU/Linux 命令行工具
通常想要在 Windows 下运行 Linux 命令有以下几种选择:
不过以上几种方案除了要安装体量巨大(包含完整的工具链)的软件外,还需要切换到相应的运行环境才能执行 Linux 命令,无法在 Windows 命令行中直接运行。
本文收集了一些 GNU/Linux 命令行工具,它们都可以通过 Scoop 进行安装。
工具集
以下几种轻量化的命令行工具集,仅包含 Windows 本地可执行文件。安装后,工具集中的命令可以在 Windows 命令行终端下直接调用。
BusyBox
Windows 上的 BusyBox 是个单一可执行文件。对于要执行的命令需要通过参数的形式传递。例如:
cmdbusybox.exe uname
如果通过 Scoop 进行安装,那么安装脚本已经为所有命令做好了 shims ,可以直接运行这些命令。
- 项目主页:https://frippery.org/busybox
- 项目描述:BusyBox is a single binary that contains many common Unix tools
- 安装命令:
scoop install busybox
- 包含工具:149
ar arch ash awk base64 basename bash bunzip2 bzcat bzip2 cal cat chmod cksum clear cmp comm cp cpio cut date dc dd df diff dirname dos2unix dpkg dpkg-deb du echo ed egrep env expand expr factor false fgrep find fold fsync ftpget ftpput getopt grep groups gunzip gzip hd head hexdump httpd iconv id ipcalc kill killall less link ln logname ls lzcat lzma lzop lzopcat man md5sum mkdir mktemp mv nc nl od paste patch pgrep pidof pipe_progress pkill printenv printf ps pwd readlink realpath reset rev rm rmdir rpm rpm2cpio sed seq sh sha1sum sha256sum sha3sum sha512sum shred shuf sleep sort split ssl_client stat strings su sum tac tail tar tee test time timeout touch tr true truncate ts ttysize uname uncompress unexpand uniq unix2dos unlink unlzma unlzop unxz unzip usleep uudecode uuencode vi watch wc wget which whoami whois xargs xxd xz xzcat yes zcat
Gow
Gow 是 Gnu on Windows 的缩写。该项目中的大多数二进制程序来自于一个名叫 GnuWin32 的古老项目,已经长期停止更新,不过里面的工具比较齐全,勉强可以使用。
- 项目主页:https://github.com/bmatzelle/gow
- 项目描述:Unix command line utilities installer for Windows
- 安装命令:
scoop install gow
- 包含工具:119
awk basename bash bc bison bunzip2 bzip2 bzip2recover cat chgrp chmod chown chroot cksum clear cp csplit curl cut dc dd df diff diff3 dirname dos2unix du egrep env expand expr factor fgrep flex fmt fold gawk gfind gow grep gsar gsort gzip head hostid hostname id indent install join jwhois less lesskey ln ls m4 make md5sum mkdir mkfifo mknod mv nano ncftp nl od pageant paste patch pathchk plink pr printenv printf pscp psftp putty puttygen pwd rm rmdir scp sdiff sed seq sftp sha1sum shar sleep split ssh su sum sync tac tail tar tee test touch tr uname unexpand uniq unix2dos unlink unrar unshar uudecode uuencode vim wc wget whereis which whoami xargs yes zip
psutils
一组使用 PowerShell 脚本编写的命令行工具集,包含 6 个 Unix 命令的平替版本(不完全一致)。值得一提的是,只有该工具集中的 sudo
命令可以在 Windows 命令行下正常使用。另外,该工具集中的 say
命令可以调用系统的 TTS 引擎进行文字朗读。
- 项目主页:https://github.com/lukesampson/psutils
- 项目描述:A collection of command line utilities written in PowerShell proudly ignoring PowerShell Verb-Noun naming conventions
- 安装命令:
scoop install psutils
- 包含工具:10
gitignore ln runat say shasum sudo time timecmd touch vimtutor
WinLibs
一套完整的 Windows 编译环境,包含 GCC 编译器、 MinGW-w64 的开源 C 库、 GDB 调试工具、 GNU Binutils 、 GNU Make 、汇编工具等。
- 项目主页:https://winlibs.com/
- 项目描述:A free C and C++ compiler for Microsoft Windows
- 安装命令:
scoop install mingw-winlibs
- 包含工具:58
addr2line ar as c++ c++filt ccache cmake cmcldeps cpack cpp ctest dlltool dllwrap dos2unix doxygen elfedit g++ gcc-ar gcc-nm gcc-ranlib gcc gcov-dump gcov-tool gcov gdb gdbserver gendef genidl gfortran gprof iconv jwasm ld.bfd ld lto-dump mac2unix make mingw32-make nasm ndisasm ninja nm objcopy objdump pexports ranlib readelf size strings strip unix2dos unix2mac vsyasm widl windmc windres yasm ytasm
uutils coreutils
用 Rust 重写的 GNU coreutils 工具集。
- 项目主页:https://github.com/uutils/coreutils
- 项目描述:Rust implementation of GNU coreutils
- 安装命令:
scoop install uutils-coreutils
- 包含工具:92
arch b2sum b3sum base32 base64 basename basenc cat cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold hashsum head hostname join link ln ls md5sum mkdir mktemp more mv nl nproc numfmt od paste pr printenv printf ptx pwd readlink realpath relpath rm rmdir seq sha1sum sha224sum sha256sum sha3-224sum sha3-256sum sha3-384sum sha3-512sum sha384sum sha3sum sha512sum shake128sum shake256sum shred shuf sleep sort split sum sync tac tail tee test touch tr true truncate tsort uname unexpand uniq unlink vdir wc whoami yes
独立工具
对于有些工具,推荐独立安装,以便获取最新的版本。
file
- 项目主页:https://www.darwinsys.com/file
- 项目描述:Determine file type
- 安装命令:
scoop install file
vim
- 项目主页:https://www.vim.org
- 项目描述:A highly configurable text editor
- 安装命令:
scoop install vim
emacs
- 项目主页:https://www.gnu.org/software/emacs
- 项目描述:An extensible, customizable, free/libre text editor
- 安装命令:
scoop install emacs
nano
- 项目主页:https://github.com/okibcn/nano-for-windows
- 项目描述:The legendary small and friendly GNU editor, UTF-8 and mouse ready for Windows 32/64/ARM CLI
- 安装命令:
scoop install nano
netcat
- 项目主页:https://eternallybored.org/misc/netcat
- 项目描述:Read and write from/to network connections
- 安装命令:
scoop install netcat
wget
- 项目主页:https://eternallybored.org/misc/wget
- 项目描述:A command-line utility for retrieving files using HTTP, HTTPS, FTP, and FTPS protocols
- 安装命令:
scoop install wget
curl
- 项目主页:https://curl.se
- 项目描述:Command line tool and library for transferring data with URLs
- 安装命令:
scoop install curl
gcc
- 项目主页:https://www.gnu.org/software/gcc
- 项目描述:GNU Compiler Collection and binutils
- 安装命令:
scoop install gcc
llvm
- 项目主页:https://www.llvm.org
- 项目描述:Collection of modular and reusable compiler and toolchain technologies
- 安装命令:
scoop install llvm
flex & bison
- 项目主页:https://github.com/lexxmark/winflexbison
- 项目描述:A Windows port of Flex (the fast lexical analyser) and GNU Bison (parser generator)
- 安装命令:
scoop install winflexbison
gnupg
- 项目主页:https://www.gnupg.org
- 项目描述:A complete and free implementation of the OpenPGP standard
- 安装命令:
scoop install gnupg
其他
此外, Scoop 仓库中还有一些长期未更新的项目。由于版本太过老旧,不推荐安装。
- binutils
- util-linux-ng
- unxutils
- coreutils