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 command | PowerShell Equivalent | Explanation |
---|---|---|
man xxx | Get-Help xxx –full | Displays 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 |
pwd | Get-Location | Displays the name of the current directory |
cd xxx | Set-Location xxx | Changes the current directory for the ‘xxx’ directory |
cp xxx PATH | Copy-Item xxx PATH | Copies the ‘xxx’ files to another location (‘PATH’) |
clear | Clear-Host | Clears the screen |
rm xxx yyy | Remove-Item xxx yyy | Deletes the ‘xxx’ and ‘yyy’ files |
rm -rfi xxx yyy | Remove-Item xxx yyy –Force –Recurse -Confirm | Deletes the ‘xxx’ and ‘yyy’ files from all subdirectories, even if it’s read-only files. Ask for confirmation for each file |
ls | Get-ChildItem | Displays a list of files and subdirectories in a directory |
ls -R | Get-ChildItem -Recurse | Displays files in specified directory and all subdirectories |
ls -d | Get-ChildItem | Where {$_.PSIsContainer} | Displays files with specified attributes, directories only |
diff file1 file2 | Compare-Object $(Get-Content File1) $(Get-Content File2) | Compares two files and displays the differences between them |
grep “xxx” yyy | Select-String -Pattern xxx -Path yyy | Search for the ‘xxx’ string in the ‘yyy’ file and display the line(s) number(s) if found |
uname -n | $env:computername | Displays the computer’s hostname |
smbclient -L localhost | Get-WmiObject Win32_Share | Gets the current network and administrative shares |
date | Get-Date | Gets the current date and time |
PATHTO/xxx start | Start-Service xxx | Starts the ‘xxx’ service |
mv xxx yyy | Rename-Item xxx yyy | Rename a file |
env | Get-ChildItem env: | Displays CMD environment variables |
set x= | Clear-Item $x | Deletes the contents of the ‘x’/’$x’ variable |
set x=value | $x=value | Affect ‘value’ to the ‘x’/’$x’ variable |
.xxx | Invoke-Item xxx | Invoke the (provider-specific) default action on the ‘xxx’ item |
ps | Get-Process | Gets 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”)