Terminal Commands

Open the current directory in applications: open .Β / atom . / code .

Use curl to:

  • download:
    • curl -O ftp://ftp.example.com/file.zip
  • POST with multipart:
    • curl -v -F upload=@filename localhost:5000/api/upload
  • POST with json:
    • curl -d '{"Name":"John"}' -H "Content-Type: application/json" -X POST localhost:3000/api/names

Get your IPv4 address: ipconfig getifaddr en0

Reboot: sudo shutdown -r now

Clear command history: history -c

Unzip in quieter mode: unzip -qq

Check the size of the directory: du -sh ~/myFolder

List all IP sockets using port 5000: lsof -i :5000

Kill process: kill -9Β `pid`

Display local computer name: hostname

Start a simple HTTP server:
python -m SimpleHTTPServer 8000
ruby -run -e httpd . -p 9000

Give you your last command: !!

Copy content to your clipboard: pbcopy < file

Permanently save ssh key in your .bashrc:
(so you don’t need to enter passphrase all the time when using git over ssh)
echo "ssh-add -K ~/.ssh/id_rsa 2> /dev/null" >> ~/.bashrc

Use Git to:
  • Remove remote file:
    • git rm -r --cached file
  • Delete a local branch:
    • git branch -d branch
  • Remove remote branch:
    • git push origin --deleteΒ branch

Find all files containing specific string:
grep -rnwl -e 'string' dirname

Disable MacOs Gatekeeper:
sudo spctl --master-disable

Show package versions for pip3:
pip3 freeze

Show proxy settings:
scutil --proxy

Remove agent from launchd:
launchctl remove com.coppertino.VOXAgent

Find and remove VOX agent from VOX:
launchctl list | grep VOX
launchctl remove com.coppertino.VOXAgent

Check Xcode version:
xcodebuild -version

CMD Commands

Check and repair errors on disk w: drive (can beΒ used to recover files):
chkdsk /f /x w: -> force dismount first

Map your SharePoint site to a network drive (* will map to any available drive letters):
net use * \\sharepoint\site /user:domain\user password
net use p: /d -> disconnect

Connect to remote desktop and fullscreen: mstsc /v:192.168.1.1 /f

Open current directory in explorer: start .Β orΒ explorer .

Run cmd under a different account: runas /profile /user:domain\administrator cmd