macOS uses VNC for remote management, and has a built-in server and viewer. (Turn on the server under System Preferences > Sharing and mash the checkbox for Screen Sharing.)
But if you’re here, you probably knew that already, and you want to change the default VNC port from 5900 to something else.
Get out your terminal:
sudo nano /System/Library/LaunchDaemons/com.apple.screensharing.plist
Or use vim. Whatever. It’s your party. Your terminal party.
You’re looking for this line (line 34 in El Capitan, and since Lion):
You want to change the text “vnc-server” to whatever you want your port to be. For example, this would make it port 1337:
Don’t use port 1337.
Then turn Screen Sharing off/on again in preferences, or restart your machine. It should use the new port now.
Connecting to it from a Mac
Use the built-in VNC viewer by going to Finder > Go > Connect to Server… Under “Server Address” enter:
If you use a Mac and Windows together, you’re likely to end up with a bunch of hidden .DS_STORE files all over your Windows drives. You can easily search and destroy them all using this command:
(Open the command line first of course. You can do this by mashing Win + R, then typing “cmd”. Or just type “cmd” in the Start Menu search box.)
del /s /q /f /a .DS_STORE
That will find every instance of this Mac resource file and delete it. Good times. But wait there’s more. In addition to DS_STORE, OSX will also put a bunch of other junk every where starting with “._”. Kill those like this.
del /s /q /f /a ._.*
(Why not use “._*'” instead? Apparently, you can sweep up legit files from other things such as Chrome by doing that. Thanks commenters.)
Important note! This will only search inside the folder you’re in, as well as every folder below that. So, if you wanted to search and clean an entire drive, make sure you’re in the root folder. Get there with this:
You could also put all of this into a .bat file for great automation.
Pro tip: copy-pasting into your command window
Windows 10 will let you CTRL-V paste into the command line. Friggin sweet. But did you know you can do it in other versions of Windows too? Just right-click on the command window and click Paste. That will save you a little work.