tk3.biz
ブログ一覧に戻る Back to Blog

Windows に Coreutils を入れてみた I Installed Coreutils on Windows

はじめに

Windows では PowerShell が標準シェルですが、AI ツールや Claude などに操作を任せると Unix コマンド(cat・rm・echo など)をそのまま実行しようとすることがよくあります。PowerShell にも同名のエイリアスがある場合もありますが、オプションや挙動が違って失敗することがあります。

Microsoft が公式に提供している GNU Coreutils for Windows をインストールすると、Windows Terminal(PowerShell)から Unix コマンドをネイティブに近い感覚で使えるようになります。

インストール手順

1. winget でインストールする

管理者権限なしで実行できます。Windows Terminal を開いて以下を実行:

winget install Microsoft.Coreutils

インストールが完了したら、ターミナルを再起動します。

2. 動作確認

いくつかコマンドを試してみます。

echo aaaa > a.txt
cat .\a.txt
aaaa
rm .\a.txt

問題なく動きました。cat でファイルの中身を確認し、rm で削除できています。

AI との組み合わせで便利になる

Claude などの AI ツールにターミナル操作を任せると、Unix コマンドを前提とした手順を生成してくることが多いです。

たとえば:

  • cat ファイル名 でファイルの中身を確認
  • rm ファイル名 でファイルを削除
  • echo 文字列 > ファイル名 でファイルを作成

Coreutils を入れておけば、AI が生成したコマンドをそのままコピー&ペーストして実行できるので、環境の差異で詰まることが減ります。

デフォルトで PowerShell を使っている場合でも Coreutils のコマンドが優先されます。PowerShell のエイリアスと衝突する場合は、コマンドのフルパスで呼ぶか、セッション内でエイリアスを削除して対応できます。

まとめ

  • winget install Microsoft.Coreutils の一行で Unix コマンド群をインストールできる
  • cat・rm・echo などが Windows Terminal(PowerShell)からそのまま使える
  • AI ツールが生成するコマンドを Windows 環境で詰まらずに実行できるようになる

Windows をメイン環境にしていて、AI に作業を任せることが多い方にはおすすめの設定です。

Introduction

On Windows, PowerShell is the standard shell, but when you let AI tools such as Claude do the work, they often try to run Unix commands (cat, rm, echo, and so on) as is. PowerShell sometimes has aliases with the same names, but their options and behavior differ, so the commands can fail.

Install GNU Coreutils for Windows, provided officially by Microsoft, and you can use Unix commands from Windows Terminal (PowerShell) in an almost native way.

Installation

1. Install with winget

No administrator rights needed. Open Windows Terminal and run:

winget install Microsoft.Coreutils

When the installation finishes, restart the terminal.

2. Check That It Works

Let’s try a few commands.

echo aaaa > a.txt
cat .\a.txt
aaaa
rm .\a.txt

It worked without problems. cat showed the file’s contents and rm deleted it.

Handy in Combination with AI

When you let AI tools such as Claude handle terminal work, they often generate steps that assume Unix commands.

For example:

  • cat <filename> to view a file’s contents
  • rm <filename> to delete a file
  • echo <text> > <filename> to create a file

With Coreutils installed, you can copy and paste the commands the AI generates and run them as is, so you get stuck on environment differences less often.

Even if you use PowerShell by default, the Coreutils commands take precedence. If one collides with a PowerShell alias, you can call the command by its full path or remove the alias within the session.

Summary

  • A single line, winget install Microsoft.Coreutils, installs the set of Unix commands
  • cat, rm, echo and others work directly from Windows Terminal (PowerShell)
  • Commands generated by AI tools run on Windows without getting stuck

I recommend this setup if Windows is your main environment and you often hand work off to AI.

関連記事 Related Posts

Windows 11 日本語環境で「terminal」と打って Windows Terminal を起動できるようにしてみた Launching Windows Terminal by Typing "terminal" on Japanese Windows 11

日本語環境の Windows 11 ではスタート検索に「terminal」と入力しても Windows Terminal がヒットしない問題を、スタートメニューへのショートカット追加で解決する方法を紹介します。 On Windows 11 in Japanese, typing "terminal" into Start search doesn't find Windows Terminal. Here's how to fix that by adding a shortcut to the Start menu.

thinking を切っていいのか測ったら、採点器のほうが2回壊れていた I Measured Whether Turning Off Thinking Was OK, and It Was My Grader That Broke Twice

ローカルLLMのCLIでthinkingを既定で切っていました。速度だけ見て決めた判断の裏を取るため正答率を測ったら、同率でした。ただしそこに至るまでに、自分で書いた採点スクリプトのバグを2回踏んでいます。 I had turned thinking off by default in my local LLM CLI. To back up a decision I'd made by looking only at speed, I measured accuracy, and it was the same. But on the way there, I hit bugs in the grading script I wrote myself twice.

自分が書いた1418行を3つのAIにレビューさせたら、実バグが11件出た I Had Three AIs Review 1418 Lines I Wrote, and They Found 11 Real Bugs

Claude・Codex・ローカルQwenの3枚に、自分で書いて自分で動かしていたスクリプトをレビューさせました。3件は自力では気づけないもので、1件は「レビュー結果を集計するスクリプト自体」のバグでした。一方で、3枚とも見逃した欠陥もあります。 I had three reviewers, Claude, Codex and a local Qwen, review scripts I had written and been running myself. Three were bugs I couldn't have found on my own, and one was in the very script that tallies the review results. There was also a defect all three missed.