After Microsoft falling in love with Linux (what has popularly come to be known as “Microsoft Loves Linux”),PowerShellwhich was originally a Windows-only component, was open-sourced and made cross-platform on 18 August 2016, available on Linux and Mac OS.
PowerShellis a task automation and configuration management system developed by Microsoft. It is made up of a command language interpreter (shell) and scripting language built on the.NET Framework.
It offers complete access toCOM(Component Object Model) andWMI(Windows Management Instrumentation), thereby allowing[system administrators to carry out administrative tasks][1]on both local and remote Windows systems as well as WS-Management and CIM (Common Information Model) enabling administration of remote Linux systems plus network devices.
Under this framework, administrative tasks are fundamentally carried out by particular.NETclasses calledcmdlets(pronounced command-lets). Similar to shell scripts in Linux, users can build scripts or executables by storing groups ofcmdletsin files by following certain rules. These scripts can be used as independent[command line utilities or tools][2].
### Install PowerShell Core 6.0 in Linux Systems
To installPowerShell Core 6.0in Linux, we will use official Microsoft Ubuntu repository that will allows us to install through most popular Linux package management tools such as[apt-get][3]and[yum][4].
#### On Ubuntu 16.04
First import the public repositoryGPGkeys, then register theMicrosoft Ubunturepository inAPTpackage sources list to installPowershell:
In this section, we will have a brief introduction toPowershell; where we will see how to start powershell, run some basic commands, look at how to work with files, directories and processes. Then later dive into how to list all available commands, show command help and aliases.
To start Powershell, type:
```
$ powershell
```
[
![Start Powershell in Linux](http://www.tecmint.com/wp-content/uploads/2017/02/start-powershell.png)
][5]
Start Powershell in Linux
You can check the Powershell version with the command below:
get-location [# Display present working directory]
```
#### Working with Files and Directories in Powershell
1.Create a new empty file using the two methods below:
```
new-item tecmint.tex
OR
“”>tecmint.tex
```
Then add content to it and view the file content.
```
set-content tecmint.tex -value "TecMint Linux How Tos Guides"
get-content tecmint.tex
```
[
![Create New File in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/Create-New-File-in-Powershell.png)
][7]
Create New File in Powershell
2.Delete a file in powershell.
```
remove-item tecmint.tex
get-content tecmint.tex
```
[
![Delete File in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/Delete-File-in-Powershell.png)
][8]
Delete File in Powershell
3.Create a new directory.
```
mkdir tecmint-files
cd tecmint-files
“”>domains.list
ls
```
[
![Create Directory in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/create-new-directory-in-Powershell.png)
][9]
Create Directory in Powershell
4.To perform a long listing, which displays details of a file/directory including mode (file type), last modification time, type:
```
dir
```
[
![Directory Long Listing in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/Directory-Long-Listing-in-Powershell.png)
][10]
Directory Long Listing in Powershell
5.View all running processes on your system:
```
get-process
```
[
![View Running Processes in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/View-Running-Processes-in-Powershell.png)
][11]
View Running Processes in Powershell
6.To view details of a single/group of running processes with a given name, provide the process name as an argument to the previous command as follows:
```
get-process apache2
```
[
![View Specific Process in Powershell](http://www.tecmint.com/wp-content/uploads/2017/02/View-Specific-Process-in-Powershell.png)
][12]
View Specific Process in Powershell
Meaning of the units in the output above:
1. NPM(K)– amount of non-paged memory that the process is using, in kilobytes.
2. PM(K)– amount of pageable memory that the process is using, in kilobytes.
3. WS(K)– size of the working set of the process, in kilobytes. The working set consists of the pages of memory that were recently referenced by the process.
4. CPU(s)– amount of processor time that the process has used on all processors, in seconds.
5. ID– process ID (PID).
6. ProcessName– name of the process.
7.To know more, get a list of all Powershell commands for different tasks:
That’s all! for now, in this article, we showed you how to installMicrosoft’s Powershell Core 6.0in Linux. To me, Powershell still has a very long way to go in comparison to the traditional Unix/Linux shells which offer, by far better, more exciting and productive features to operate a machine from the command line and importantly, for programming (scripting) purposes as well.
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.