LoginSignup
1
0

BashにPowerShellをインストールする方法について

Last updated at Posted at 2024-03-02

Bash(Ubuntu)にPowerShellをインストールする方法をまとめました。

PowerShellコマンドが使えるか確認します。

~# pwsh
bash: pwsh: command not found

Microsoftリポジトリの公開鍵を追加します。

wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb

インストール前にパッケージリストを更新しておきます。

sudo apt-get update

PowerShellをインストールしましょう!

sudo apt-get install -y powershell

pwshコマンドを実行するとPowerShellを起動できます。

~# pwsh
PowerShell 7.4.1

以上でPowerShellをインストールできました。

PS /root> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Ubuntu 22.04.3 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

補足

コマンドがないとエラーが出たときは次のコマンドを実行してください。

~# wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
bash: lsb_release: command not found
bash: wget: command not found

パッケージリストを更新します。

~# sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done

wgetコマンドをインストールします。
ファイルをインストールするコマンドラインです。

~# sudo apt-get install -y wget
Reading package lists... Done
...

lsb-releaseコマンドをインストールします。

~# sudo apt-get install -y lsb-release
Reading package lists... Done

以上でコマンドが実行できるようになります。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0