Useful Commands
Linux Command | PowerShell Equivalent | CMD Equivalent |
---|---|---|
ls |
ls or Get-ChildItem |
dir |
cd |
cd or Set-Location |
cd |
cp |
cp or Copy-Item |
copy |
mv |
mv or Move-Item |
move |
rm |
rm or Remove-Item |
del or erase |
mkdir |
mkdir or New-Item -ItemType <directory-name> |
mkdir |
rmdir |
rmdir or Remove-Item |
rmdir |
pwd |
pwd or Get-Location |
cd (no arguments) |
cat |
cat or Get-Content |
type |
touch |
New-Item <file-name> |
type nul > |
echo |
echo or Write-Output |
echo |
find |
find or Get-ChildItem -Recurse |
dir /s |
grep |
Select-String |
findstr |
chmod |
icacls |
icacls |
chown |
Set-Acl |
icacls |
ps |
ps or Get-Process |
tasklist |
kill |
kill or Stop-Process |
taskkill |
ifconfig |
ipconfig |
ipconfig |
ping |
ping |
ping |
netstat |
netstat |
netstat |
traceroute |
tracert |
tracert |
curl |
curl |
curl |
wget |
Invoke-WebRequest |
powershell -Command "Invoke-WebRequest" |
Examples:¶
Operation | Linux Example | PowerShell Example | CMD Example |
---|---|---|---|
Pipe commands | `ls | grep "txt"` | ls | Select-String "txt"` | `dir | findstr "txt"` |
Redirect output (overwrite) | echo "Hello" > file.txt |
echo "Hello" > file.txt |
echo Hello > file.txt |
Redirect output (append) | echo "Hello" >> file.txt |
echo "Hello" >> file.txt |
echo Hello >> file.txt |
Find files recursively | find . -name "*.txt" |
Get-ChildItem -Recurse -Filter *.txt |
dir /s *.txt |
Search within files | grep "search_term" file.txt |
Select-String "search_term" file.txt |
findstr "search_term" file.txt |
Change permissions | chmod 755 file.txt |
icacls file.txt /grant:r Everyone:F |
icacls file.txt /grant Everyone:F |
Change ownership | chown user:group file.txt |
Set-Acl |
icacls |
List processes | ps aux |
ps aux or Get-Process |
tasklist |
Display network stats | netstat -an |
netstat -an |
netstat -an |