ホームページ  >  記事  >  システムチュートリアル  >  sudo ツールが Windows に登場: 使用方法とその理由

sudo ツールが Windows に登場: 使用方法とその理由

WBOY
WBOYオリジナル
2024-06-14 22:27:49799ブラウズ

Windows セットアップを微調整するのが好きな場合は、多くの場合、「管理者特権」または管理者レベルのコマンドを実行する必要があります。おそらく管理者としてコマンド プロンプトを実行してこれを実行することに慣れていると思いますが、Windows で sudo を使用するとさらに簡単になります。

sudo コマンドは何をしますか?

Windows では、設定アプリや使いやすい構成ウィザードを使用してすべてを構成することに一般的に重点が置かれていますが、場合によっては、依然としてコマンドを入力する必要があります。これらの多くは、標準ユーザー アカウントでは機能しません。代わりに、管理者として実行する必要があります。管理者権限を要求することは、Windows ではまだ比較的新しい概念ですが、古いオペレーティング システムでははるかに長い間普及していました。

この問題は非常に蔓延していたので、オペレーティング システム開発者は数十年前にこの問題の解決策を考えました。 Unix インストールには、「ユーザーの切り替え」を意味する su コマンドがあり、今でもあります。これにより、アカウントを他のユーザーに切り替えることができますが、デフォルトでシステムの管理者またはスーパーユーザーのアカウントとして実行することもできます。 su command, which means "switch user." This would allow you to switch accounts to any other user, but could also let you run as the administrator, or superuser, account of the system by default.

This solution worked, but logging in as the administrator to run one command seemed like overkill. As a solution, developers created the sudo command, which means either "switch user and do," or "superuser do," depending on various opinions. Long story short, the sudo command lets you easily run one command with elevated privileges—we've covered the differences between su and sudo if you're curious.

This means that the sudo command is roughly equivalent to right-clicking on the Command Prompt app, selecting Run as administrator, and running a command, like do_something. With the help of the sudo command, you don't need to worry about remembering to run the Command Prompt as administrator. Instead, simply type sudo do_something, and the command will work in exactly the same way.

Which Windows Versions Can Run the sudo Command?

Microsoft is adding the sudo command to Windows 11, and considering that support for Windows 10 is winding down, we don't expect to see the command coming there anytime soon. At the time of writing, the sudo command is only available for Windows Insider participants (builds 26045 and later), specifically those on the Developer and Windows Canary channels.

Unlike some features that Microsoft tests in these versions, it seems fairly likely that sudo is going to arrive on the operating system soon.

How to Enable the sudo Command on Windows

If the sudo command isn't yet available for your version of Windows, you'll need to sign up for Windows Insider. This is a simple process, but be warned: the Developer and Canary options can be unstable, so don't use them on a PC you're not willing to lose data on.

Once you're running a version of Windows that has the sudo command available, enabling it is a simple process. Open the Settings app, then select System on the left and For developers from the main area of the window.

Here, scroll down and enable the checkbox that reads Enable sudo.

The sudo Tool Is Coming to Windows: How and Why to Use It

Enable sudo via the Command Prompt

If you're more command-line oriented, you can also enable sudo via the Commmand Prompt. Somewhat ironically, this requires you to run an elevated CMD window. Press the Windows key, type "command," then right-click on Command Prompt (or PowerShell) and select Run as administrator.

In this prompt, run the following command:

<code class="hljs bash">sudo config --enableenable</code> 
The sudo Tool Is Coming to Windows: How and Why to Use It

How to Use the sudo Command on Windows

After you've enabled the sudo command on Windows, it's simple to use. Simply prepend the sudo command to any command you'd typically need to run as an administrator, then accept the prompts that follow.

An example from Microsoft uses the netstat

この解決策は機能しましたが、管理者としてログインして 1 つのコマンドを実行するのはやりすぎのように思えました。解決策として、開発者は sudo コマンドを作成しました。これは、さまざまな意見に応じて、「ユーザーを切り替えて実行する」または「スーパーユーザーが実行する」のいずれかを意味します。簡単に言うと、sudo コマンドを使用すると、昇格した特権で 1 つのコマンドを簡単に実行できます。興味があれば、su と sudo の違いについても説明しました。 The sudo Tool Is Coming to Windows: How and Why to Use It

これは、sudo コマンドが、コマンド プロンプト アプリを右クリックし、[管理者として実行] を選択して、do_something などのコマンドを実行することとほぼ同等であることを意味します。 sudo コマンドを使用すると、管理者としてコマンド プロンプトを実行することを忘れずに済みます。代わりに、「sudo do_something」と入力するだけで、コマンドはまったく同じように機能します。

sudo コマンドを実行できる Windows のバージョンはどれですか? 🎜🎜 Microsoft は Windows 11 に sudo コマンドを追加していますが、Windows 10 のサポートが終了しつつあることを考慮すると、このコマンドがすぐに登場するとは予想されていません。この記事の執筆時点では、sudo コマンドは Windows Insider 参加者 (ビルド 26045 以降)、特に開発者チャネルと Windows Canary チャネルの参加者のみが使用できます。 🎜🎜 Microsoft がこれらのバージョンでテストしている一部の機能とは異なり、sudo が間もなくオペレーティング システムに導入される可能性がかなり高いようです。 🎜

Windows で sudo コマンドを有効にする方法 🎜🎜 お使いの Windows のバージョンで sudo コマンドがまだ利用できない場合は、 Windows Insider にサインアップする必要があります。これは簡単なプロセスですが、注意してください。開発者オプションとカナリア オプションは不安定になる可能性があるため、データを失いたくない PC では使用しないでください。 🎜🎜 sudo コマンドが利用可能なバージョンの Windows を実行している場合、それを有効にするのは簡単なプロセスです。設定アプリを開き、左側の [システム] を選択し、ウィンドウのメイン領域から [開発者向け] を選択します。 🎜🎜 ここで、下にスクロールして、「sudo を有効にする」というチェックボックスをオンにします。 🎜 sudo ツールが Windows に登場: 使用方法とその理由

コマンド プロンプト経由で sudo を有効にする

🎜 コマンドライン指向の場合は、コマンド プロンプト経由で sudo を有効にすることもできます。やや皮肉なことに、これには昇格した CMD ウィンドウを実行する必要があります。 Windows キーを押して「command」と入力し、コマンド プロンプト (または PowerShell) を右クリックして [管理者として実行] を選択します。 🎜🎜 このプロンプトで、次のコマンドを実行します: 🎜
<code class="hljs xml">sudo netstat -ab</code> 
sudo ツールが登場Windows へ: 使用する方法と理由

Windows で sudo コマンドを使用する方法 🎜🎜 Windows の sudo コマンドは簡単に使用できます。通常、管理者として実行する必要があるコマンドの先頭に sudo コマンドを追加し、その後に続くプロンプトを受け入れます。 🎜🎜 Microsoft の例では、netstat コマンドを使用しています。 🎜 rrreee🎜 🎜 この機能は少し不必要に思えるかもしれませんが、多くの人にとっては不必要です。とはいえ、Windows でコマンドを次から次へと実行して一日を過ごしており、sudo コマンドのシンプルさを求めるのであれば、このコマンドの追加により作業が楽になるでしょう。 🎜

Microsoft は sudo の実装に力を入れているようで、GitHub で sudo をオープンソースとしてリリースすることまで行っています。これを読んで、Windows の内部で何が起こっているのかをさらに知りたくなったら、すべての Windows ユーザーが知っておくべきコマンドのリストを必ず参照してください。

以上がsudo ツールが Windows に登場: 使用方法とその理由の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。