PowerShell CheatSheet – Bash > PS

Because we’re not “sexists”, here’s some common and usefull Bash to PS equivalents. Yes, *nixes pussies, you can now start to use Windows! 😉

Bash commandPowerShell EquivalentExplanation
man xxxGet-Help xxx –fullDisplays the help for the ‘xxx’ command
chmod 123 xxx$ACL = Get-Acl xxx
$TempACL = New-Object SSAF1
$ACL.SetAccessRule($TempACL)
Set-Acl XXX $Acl
Modifys Access Control Lists (ACLs) for the ‘xxx’ file
pwdGet-LocationDisplays the name of the current directory
cd xxxSet-Location xxxChanges the current directory for the ‘xxx’ directory
cp xxx PATHCopy-Item xxx PATHCopies the ‘xxx’ files to another location (‘PATH’)
clearClear-HostClears the screen
rm xxx yyyRemove-Item xxx yyyDeletes the ‘xxx’ and ‘yyy’ files
rm -rfi xxx yyyRemove-Item xxx yyy –Force –Recurse -ConfirmDeletes the ‘xxx’ and ‘yyy’ files from all subdirectories, even if it’s read-only files. Ask for confirmation for each file
lsGet-ChildItemDisplays a list of files and subdirectories in a directory
ls -RGet-ChildItem -RecurseDisplays files in specified directory and all subdirectories
ls -dGet-ChildItem | Where {$_.PSIsContainer}Displays files with specified attributes, directories only
diff file1 file2Compare-Object $(Get-Content File1) $(Get-Content File2)Compares two files and displays the differences between them
grep “xxx” yyySelect-String -Pattern xxx -Path yyySearch for the ‘xxx’ string in the ‘yyy’ file and display the line(s) number(s) if found
uname -n$env:computernameDisplays the computer’s hostname
smbclient -L localhostGet-WmiObject Win32_ShareGets the current network and administrative shares
dateGet-DateGets the current date and time
PATHTO/xxx startStart-Service xxxStarts the ‘xxx’ service
mv xxx yyyRename-Item xxx yyyRename a file
envGet-ChildItem env:Displays CMD environment variables
set x=Clear-Item $xDeletes the contents of the ‘x’/’$x’ variable
set x=value$x=valueAffect ‘value’ to the ‘x’/’$x’ variable
.xxxInvoke-Item xxxInvoke the (provider-specific) default action on the ‘xxx’ item
psGet-ProcessGets the processes that are running on the local computer or a remote computer

To Be Enriched…


1 SSAF: System.Security.AccessControl.FileSystemAccessRule(“user”,”FullControl”,”Allow”)

Leave a Reply

Scroll to Top