Terminal File Management: Bash vs CMD vs PowerShell Commands Compared
Muhammad Fikri Gunawan · · 7 min read
The same folder and file task needs different commands in Bash, Windows CMD and PowerShell. Here is a side-by-side guide to listing, copying, moving, deleting, searching and killing processes.
Short answer: file and folder commands are the one part of the terminal that changes between platforms. Bash (Linux, macOS and Git Bash) uses ls, cp, mv and rm; Windows CMD uses dir, copy, move and del; PowerShell uses cmdlets such as Get-ChildItem, Copy-Item, Move-Item and Remove-Item. This guide lines the three up so you can translate any command in seconds.
Git Bash runs on Windows but imitates a Unix shell, so everything in the Bash column works there too. PowerShell also accepts many Bash-style aliases like ls, cd and pwd, but the full cmdlet names are what you will see in scripts and documentation.
How do I see where I am and move between folders?
- Show the current path:
pwdin Bash and PowerShell,cdwith no argument in CMD. - List folder contents:
ls -lain Bash,dirin CMD,Get-ChildItem(aliasls) in PowerShell. - Go into a folder:
cd folder_namein all three. - Go up one level:
cd ..in all three. - Go back to the previous folder:
cd -in Bash.
How do I create folders and files?
- One folder:
mkdir folder_namein Bash and CMD,New-Item -ItemType Directory folder_namein PowerShell. - Nested folders at once:
mkdir -p a/b/cin Bash,mkdir a\b\cin CMD,New-Item -ItemType Directory -Path a\b\c -Forcein PowerShell. - An empty file:
touch file.txtin Bash,type nul > file.txtin CMD,New-Item file.txtin PowerShell.
How do I copy, move, rename and delete?
- Copy a file:
cp file.txt target/,copy file.txt target\orCopy-Item file.txt target\. - Copy a folder with its contents:
cp -r folder target/,xcopy folder target\ /E /IorCopy-Item folder target\ -Recurse. - Move a file or folder:
mv source target,move source targetorMove-Item source target. - Rename:
mv old.txt new.txt,ren old.txt new.txtorRename-Item old.txt new.txt. - Delete a file:
rm file.txt,del file.txtorRemove-Item file.txt. - Force-delete a folder and everything in it:
rm -rf folder_name,rmdir /s /q folder_nameorRemove-Item folder_name -Recurse -Force.
Warning: these delete commands skip the recycle bin. Double-check the path, and never run rm -rf with a path you have not read twice.
How do I read and search inside files?
- Show a file in the terminal:
cat file.txt,type file.txtorGet-Content file.txt. - Search for text inside a file:
grep "keyword" file.txt,findstr "keyword" file.txtorSelect-String "keyword" file.txt. - Find files by name or pattern:
find . -name "*.js",dir /s /b *.jsorGet-ChildItem -Recurse -Filter *.js. - Clear the screen:
clearin Bash,clsin CMD and PowerShell (Clear-Host).
How do I set environment variables and aliases?
- Set a temporary variable:
export NAME=valuein Bash,set NAME=valuein CMD,$env:NAME="value"in PowerShell. - Print a variable:
echo $NAME,echo %NAME%orecho $env:NAME. - Create a shortcut command:
alias ll='ls -la',doskey ll=dirorSet-Alias ll Get-ChildItem. - See command history:
history,doskey /historyorGet-History.
Which commands help with ports, processes and permissions?
When a dev server refuses to start because port 3000 is busy, these are the commands you need.
- Find what uses port 3000:
lsof -i :3000in Bash,netstat -ano | findstr :3000in CMD,Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcessin PowerShell. - Kill a process by PID:
kill -9 <PID>,taskkill /PID <PID> /ForStop-Process -Id <PID> -Force. - Make a script executable:
chmod +x file.shin Bash. It does not apply on Windows. - Create a symbolic link:
ln -s target link,mklink link targetorNew-Item -ItemType SymbolicLink -Path link -Target target. - Check a folder size:
du -sh folder_namein Bash,dir folder_name /sin CMD,Get-ChildItem folder_name -Recurse | Measure-Object Length -Sumin PowerShell.
Frequently asked questions
Why does touch not work in Windows CMD or PowerShell?
touch is a Unix command. In CMD use type nul > file.txt, and in PowerShell use New-Item file.txt. In Git Bash, touch works as usual.
Is Git Bash the same as Linux Terminal?
For everyday work, yes. Git Bash emulates a Unix shell on top of Windows, so the commands in the Bash column work there. System-level tools such as lsof may be missing.
Which shell should a web developer on Windows choose?
Pick one and learn it well. Git Bash gives you the same commands as macOS and Linux, which helps when you follow tutorials or deploy to servers. PowerShell is the better choice when you script Windows itself.
How can I remember all these commands?
Learn the Bash set first, since it is the most widely documented, then map each one to its CMD or PowerShell twin using the lists above. Aliases such as ls, cd and pwd in PowerShell soften the switch.
Previous in this series: Web developer commands for Node.js, NPM, PHP and WP-CLI. Next: the Git and GitHub CLI cheat sheet.



