PowerShell is a command-line shell and a scripting language that is used for task automation and configuration management. It is a cross-platform tool developed by Microsoft.
The administrative tasks are performed using cmdlets (or command-lets) which are specialized .NET classes implemented to perform specific operations.
In this article, we will discuss how to install and use PowerShell in Ubuntu Linux.
Prerequisites
To install a package in a Ubuntu system you should have access to a user account with superuser privileges.
How to install PowerShell in Ubuntu
The PowerShell can be installed on a system by adding its repository. Now follow the given steps for installing Powershell on a Ubuntu system.
Before you install PowerShell make sure the apt package repository is updated –
sudo apt update
Use the following command to install some prerequisite packages –
sudo apt install -y wget apt-transport-https software-properties-common
Now use the given command to download Microsoft repository GPG keys –
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Once the package is downloaded install it by using –
sudo dpkg -i packages-microsoft-prod.deb
Refresh the apt repository by running –
sudo apt update
Finally, use the given command to install PowerShell on your system –
sudo apt install -y powershell
You can verify the installation by using –
pwsh --version
Using PowerShell on Ubuntu
Once the package is installed successfully you can start PowerShell by executing the given command –
pwsh
You can use the given command to list all the items in your current working directory.
ls
You can use the cd command to navigate through directories –
By typing the given command will display the history of commands run on PowerShell –
Get-History
You can use the given command to exit from PowerShell –
exit
If you want to know more you can see the complete list of commands here.
How to remove PowerShell from Ubuntu
To remove PowerShell from Ubuntu you can use –
sudo apt remove powershell
press y and then enter if it asks for your confirmation.
Use the given command to remove any unused dependencies –
sudo apt autoremove
Conclusion
I hope you have successfully installed PowerShell on your system. Now if you have a query then write us in the comments below.