If you spend a lot of time in the command line you may find it a bit difficult to remember the different commands you need to use to achieve basic things depending on whether you’re using Unix/Linux or Windows that day. This guide contains a cheat-sheet with some of the most used Unix commands and their Windows counterparts. If you use PowerShell you’re in luck because Microsoft has added a large number of the Unix commands as aliases for their Windows counterparts for you, but if you use CMD/Command Prompt still this list is for you.
Cheat-sheet:
Unix command: clear
CMD command: cls
The clear command is used to clear the window you currently have open, useful if the clutter is distracting you. The Windows alternative is cls (clear screen).
Unix command: ls
CMD command: dir
The ls command is used list the contents of the current directory, append with the location of another directory to list the contents of a different directory. The Windows alternative is dir (directory).
Unix command: cat
CMD command: type
cat is most frequently used to output the content of a file to the command line, or to add the content of file into another file. The Windows alternative is type (fairly self explanatory).
Unix command: sudo
CMD command: powershell Start-Process cmd.exe -Verb runAs
Windows doesn’t have an in-built answer to the sudo command (used to elevate your command line to run commands that are system sensitive), but powershell Start-Process cmd.exe -Verb runAs will open another CMD window for you running as the administrator user.
Unix command: rm
CMD command: del
Used to remove files and folders. The Windows alternative is del (delete).
Unix command: cp
CMD command: copy
Used to copy files and folders. The Windows alternative is copy (self explantory). xcopy also exists.
Unix command: nano, vi, ee
CMD command: notepad
CMD doesn’t have an in-built text editor*, but prefixing a file name with notepad will open it up in Notepad so you can edit it in the GUI. If you need to open a file as an Administrator (for example to edit the hosts file), see the next command.
* Some older versions of Windows come with edit from the DOS days, but Windows 7 64-bit and above does not.
Unix command: sudo nano
CMD command: powershell Start-Process “notepad.exe <filename>” -Verb runAs
This will open the file you want to edit in an elevated Notepad instance. For example, to edit the hosts file run: powershell Start-Process “notepad.exe C:\Windows\System32\drivers\etc\hosts” -Verb runAs and then you can make the changes needed and save the file in the GUI.
Unix command: ssh
CMD command: ssh
Windows 10 supports SSH! (Version 1809 does, anyway – older versions probably do too).
Unix command: shutdown (and shutdown -r or reboot)
CMD command: shutdown
Windows supports the shutdown command but the flags are slightly different. Replace the hyphen with a forward slash (e.g; rebooting on Windows requires shutdown /r instead of shutdown -r). Execute shutdown and CMD will display a list of arguments.