9

I am having trouble installing PowerShell 7 on Ubuntu 20.04. I used Ubuntu Software to install powershell 7.0.3, which is the latest/stable version available. After an error-free installation, I cannot launch powershell. Attached is the screenshot. I couldn't find the documentation on the desktop file supposed to specify exec field. I note that v7 is "PowerShell Preview". Does it mean that I should install v6 instead? If so, how to get the version?

$ uname -r
5.4.0-47-generic

Screenshot of the error message

Update: I have successfully installed PowerShell 7.1.0 via Ubuntu Software. Thank you, M$!

4 Answers4

7

According to the PowerShell project's Issue on GitHub titled Please support Ubuntu 20.04 support will arrive very soon (when it does, this answer should be updated)

In the mean time there are 2 reported successful installation paths (as in - you can get the prompt in your system, but it's not exactly installed - at least not natively)

NOTE: You might not be able to launch these from a UI menu, and only from a terminal by running either powershell or pwsh command.

  • Snap:

    sudo snap install powershell --classic
    
  • dotnet runtime install:

    cd /tmp
    wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    sudo dpkg -i packages-microsoft-prod.deb
    

    sudo apt-get update;
    sudo apt-get install -y apt-transport-https &&
    sudo apt-get update &&
    sudo apt-get install -y aspnetcore-runtime-3.1

    dotnet tool install -g powershell

5

" I must have 50 rep to comment "

But thanks to @Lockszmith, I noticed this happened ~22 days ago...

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1#ubuntu-2004

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh

but then I tried to new-pssession and start-process -credential $cred -filepath powershell to find WSman, and domains not supported in linux. To which my reaction was, "then what's the point?"

I guess you can install out-gridview, and still process things in powershell-y ways. However, my enthusiasm for it was immediately curbed.

Hope this helps someone!

1

I only wanna help and posted link where I explained and solved the issue but this was deleted from Mitch.

Here is the solution:

You get this PSSession issue because of Softlinks from the installed package are not found because they are wrong. I dont know what MS is doing here...

If you do library check you can see that some library will not found:

ldd /opt/microsoft/powershell/7/libmi.so
   linux-vdso.so.1 (0x00007fff9617c000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2a180a2000)
   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2a1809c000)
   libpam.so.0 => /lib/x86_64-linux-gnu/libpam.so.0 (0x00007f2a1808a000)
   libssl.so.1.0.0 => not found
   libcrypto.so.1.0.0 => not found
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2a17e98000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f2a182ad000)
   libaudit.so.1 => /lib/x86_64-linux-gnu/libaudit.so.1 (0x00007f2a17e6a000)
   libcap-ng.so.0 => /lib/x86_64-linux-gnu/libcap-ng.so.0 (0x00007f2a17e62000)

Take a look if you have libssl.so.1.1 and librypto.so.1.1 which comes with Ubuntu 20.04 under /usr/lib/x86_64-linux-gnu/ and create softlinks as follow.

sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /lib/x86_64-linux-gnu/libssl.so.1.0.0
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0

If you dont have the librarys "apt install libssl-dev". Check again ldd, should be fine now.

Then you need to install gss-ntlmssp too.

apt install gss-ntlmssp

For more understanding take a look here https://adminsnet.de/?p=184 I have all explained howto fix powershell 7.1 with k/ubuntu 20.04.

Have fun... K3ops

k3ops
  • 321
0

This is the sequence of commands you need to install powershell properly in Ubuntu 20.04:

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Remove garbage
rm packages-microsoft-prod.deb
# Start PowerShell
pwsh

No problem with libraries or any other function, and it will auto-update as long as you execute sudo -E apt update && sudo apt upgrade -y.

Oscar
  • 181