This post may contain affiliate links, please read our affiliate disclosure to learn more.
45 Commands: Linux/Bash to PowerShell (With Examples)

45 Commands: Linux/Bash to PowerShell (With Examples)

 By Charles Joseph | Cybersecurity Researcher
 Published on March 20th, 2023
This post was updated on February 29th, 2024

PowerShell is a powerful scripting language and command-line shell developed by Microsoft, designed primarily for task automation and configuration management.

It’s built on the .NET Framework and utilizes a versatile scripting language called PowerShell Scripting Language (PSL).

Stay One Step Ahead of Cyber Threats

Want to Be the Smartest Guy in the Room? Get the Latest Cybersecurity News and Insights.
We respect your privacy and you can unsubscribe anytime.

With its ease of use, flexibility, and robustness, PowerShell has become an indispensable tool for system administrators and developers alike.

Why Use Powershell?

One of the main reasons you’d want to use PowerShell is its ability to seamlessly manage and automate tasks across different Microsoft platforms and services.

It can be used to interact with the Windows operating system, Active Directory, Exchange Server, Azure, and many other Microsoft technologies.

Moreover, PowerShell enables you to manage remote systems, execute commands in parallel, and perform complex tasks with just a few lines of code.

Its object-oriented nature allows for precise control over data manipulation, offering better error handling and output formatting.

History of Powershell

PowerShell was first introduced in 2006 as Windows PowerShell, a replacement for the traditional Command Prompt (cmd.exe).

It was designed to address the limitations of the Command Prompt and provide a more powerful and extensible scripting environment.

The first version of PowerShell, 1.0, was released with Windows Server 2008, and its popularity grew steadily with each subsequent release.

In 2016, Microsoft made a significant announcement: PowerShell was going open source, and a cross-platform version called PowerShell Core was being developed.

This move aimed to expand PowerShell’s reach and usability beyond the Windows ecosystem.

PowerShell Core, built on the .NET Core framework, was first released in 2018 as version 6.0, offering support for macOS and

45 Linux Commands with Their Powershell Equivalents

No.Linux CommandPowerShell EquivalentLinux ExamplePowerShell Example
1lsGet-ChildItemls /home/userGet-ChildItem C:\Users\User
3cdSet-Locationcd /home/userSet-Location C:\Users\User
4mkdirNew-Itemmkdir new_directoryNew-Item -ItemType Directory -Path new_directory
5touchNew-Itemtouch new_file.txtNew-Item -ItemType File -Path new_file.txt
6cpCopy-Itemcp file1.txt file2.txtCopy-Item file1.txt file2.txt
7mvMove-Itemmv file1.txt dir1/Move-Item file1.txt dir1\
8rmRemove-Itemrm file.txtRemove-Item file.txt
9catGet-Contentcat file.txtGet-Content file.txt
10grepSelect-Stringgrep ‘word’ file.txtSelect-String -Path file.txt -Pattern ‘word’
11echoWrite-Outputecho “Hello, World!”Write-Output “Hello, World!”
12wcMeasure-Objectwc -l file.txtGet-Content file.txt | Measure-Object -Line
13chmodSet-Aclchmod 755 file.txtN/A (Permissions are set differently in Windows)
14chownSet-Ownerchown user:group file.txtN/A (Ownership is set differently in Windows)
15sudoStart-Processsudo apt-get updateStart-Process -Verb RunAs PowerShell
16killStop-Processkill -9 12345Stop-Process -Id 12345 -Force
18tailGet-Contenttail -n 10 file.txtGet-Content -Path file.txt -Tail 10
19sortSort-Objectsort file.txtGet-Content file.txt | Sort-Object
20headGet-Contenthead -n 10 file.txtGet-Content -Path file.txt -Head 10
22unameGet-CimInstanceuname -aGet-CimInstance -ClassName Win32_OperatingSystem
23dfGet-PSDrivedf -hGet-PSDrive -PSProvider FileSystem
24duGet-ChildItemdu -sh /home/userGet-ChildItem -Path C:\Users\User -Recurse -Force | Measure-Object -Property Length -Sum
25tarCompress-Archivetar -czvf archive.tar.gz folderCompress-Archive -Path folder -DestinationPath
26gzipCompress-Archivegzip file.txtCompress-Archive -Path file.txt -DestinationPath file.txt.gz
27gunzipExpand-Archivegunzip file.txt.gzExpand-Archive -Path file.txt.gz -DestinationPath .
28wgetInvoke-WebRequestwget -Uri -OutFile file.txt
29aliasSet-Aliasalias ll=’ls -la’Set-Alias -Name ll -Value “Get-ChildItem -Force”
30curlInvoke-WebRequestcurl -O -Uri -OutFile file.txt
31envGet-ChildItemenvGet-ChildItem -Path Env:
32exportSet-Variableexport VAR=valueSet-Variable -Name VAR -Value “value” -Scope Global
35manGet-Helpman lsGet-Help Get-ChildItem
36pingTest-NetConnectionping example.comTest-NetConnection -ComputerName
37sedForEach-Objectsed ‘s/old/new/g’ file.txtGet-Content file.txt | ForEach-Object { $_ -replace ‘old’, ‘new’ } | Set-Content file.txt
38awkForEach-Objectawk ‘{print $1}’ file.txtGet-Content file.txt | ForEach-Object { ($_ -split ‘\s+’)[0] }
39topGet-ProcesstopGet-Process | Sort-Object -Descending CPU
40crontabTask Schedulercrontab -eN/A (Use Windows Task Scheduler)
41scpCopy-Itemscp file.txt user@host:/path/Copy-Item -Path file.txt -Destination \hostname\path\ -ToSession (New-PSSession -ComputerName hostname)
42sshEnter-PSSessionssh user@hostEnter-PSSession -ComputerName hostname -Credential (Get-Credential)
43diffCompare-Objectdiff file1.txt file2.txtCompare-Object (Get-Content file1.txt) (Get-Content file2.txt)
44passwdSet-LocalUserpasswdSet-LocalUser -Name “username” -Password (Read-Host -AsSecureString)
45uptimeGet-CimInstanceuptime(Get-CimInstance -ClassName Win32
"Amateurs hack systems, professionals hack people."
-- Bruce Schneier, a renown computer security professional
Scroll to Top