blog.dopana

Back

PowerShell includes built-in aliases for many common Linux commands, allowing you to type familiar commands like ls, cd, and cat directly into the Windows terminal.

However, underneath the hood, PowerShell does not execute Unix binaries. It translates these aliases into official object-oriented Windows cmdlets (e.g., ls actually triggers Get-ChildItem).

Because they are wrappers, advanced Linux switches (like ls -la or rm -rf) will not work out of the box unless you use the proper PowerShell syntax.

Ultimate Linux-to-PowerShell Command Translation#

The table below maps standard Linux operations to their native PowerShell counterparts and existing aliases:

Linux CommandPowerShell AliasNative PowerShell CmdletDescription / Example Usage
lsls / dir / gciGet-ChildItemLists items in a directory. For hidden files: Get-ChildItem -Force
cdcd / chdir / slSet-LocationChanges the current working directory
pwdpwd / glGet-LocationPrints the absolute path of the current directory
catcat / type / gcGet-ContentReads and displays the contents of a file
mkdirmkdir / niNew-Item -ItemType DirectoryCreates a new directory
touch(None)New-Item -ItemType FileCreates an empty file (e.g., ni file.txt)
cpcp / copy / cpiCopy-ItemCopies a file or folder to a new destination
mvmv / move / miMove-ItemMoves or renames a file or folder
rmrm / del / riRemove-ItemDeletes a file or directory. For recursive delete: rm -Recurse -Force
echoecho / writeWrite-OutputPrints text to the terminal pipeline
grep(Use sls)Select-StringSearches for patterns (e.g., `cat file.txt \
clearclear / clsClear-HostClears the entire terminal screen
psps / gpsGet-ProcessLists actively running system processes
killkill / pkill / spsStop-ProcessTerminates a process by ID or name (e.g., kill -Name notepad)
curl / wgetcurl / wget / iwrInvoke-WebRequestSends web requests (Note: curl alias removed in PowerShell 7+)
which(None)Get-CommandFinds the absolute binary path or source of a command

2 Crucial Differences to Keep in Mind#

1. Text vs. Objects#

In Linux, data flows through pipelines (|) strictly as plain text. You often have to parse string output using tools like grep, awk, sed, or cut.

In PowerShell, data flows as structured .NET objects. Instead of complex string manipulations, you query structured properties directly:

ps aux | grep "chrome" | awk '{print $2, $3}'
bash
Get-Process chrome | Select-Object Id, CPU, ProcessName
powershell
flowchart TD
    subgraph Linux["Linux Pipeline (Raw Text Stream)"]
        L1["Command A (Raw Text)"] -->|Text Stream| L2["grep / awk / sed"]
        L2 -->|Filtered Text| L3["Plain String Output"]
    end

    subgraph PowerShell["PowerShell Pipeline (.NET Object Stream)"]
        P1["Cmdlet A (.NET Object)"] -->|Object Stream| P2["Select-Object / Where-Object"]
        P2 -->|Structured Object| P3["Direct Property Access"]
    end

2. Flags and Arguments#

Native Linux arguments (like -rf or -al) are rejected by PowerShell. PowerShell relies on explicit -ParameterName parameters.

  • If an error surfaces when executing a command, inspect the parameter list using the built-in manual:
    Get-Help Get-ChildItem -Detailed
    powershell
  • PowerShell arguments support Tab-completion and unambiguous parameter prefixes (e.g., -Recurse can be shortened to -Rec).

[!TIP] Pro Tip: Missing a specific keyword like which? Map it persistently inside your PowerShell profile ($PROFILE):

New-Alias -Name which -Value Get-Command
powershell

References#