Mac Unix

Mac Unix

by John Vincent


Posted on February 14, 2017


This stuff ends up sprayed everywhere, so let's create a reference document.

Various

Find and delete

find . -name ‘*.class' -delete
find . -name “*.class” -exec rm {} \;
find . -name "*.pdf" -exec chown someuser:somegroup {} \;

Find and exclude

find . -type f -name "utils.js" ! -path "*/node_modules/*" | more

List directories as a tree

tree -I node_modules

excludes node_modules folder

Root Alias

Add to /var/root/.profile

. /Users/jv/Desktop/MyDevelopment/github/repo_shell_scripts/mac/.root_bash_profile

where .root_bash_profile

#!/bin/bash
#

echo "Running /Users/jv/Desktop/MyDevelopment/github/repo_shell_scripts/mac/.root_bash_profile"

lf() { ls -FaC $*; }

alias ls='ls -GFh'

Use

sudo su -

What is my IP?

dig @ns1.google.com -t txt o-o.myaddr.l.google.com +short
dig -4 @ns1-1.akamaitech.net -t a whoami.akamai.net +short
dig -4 @resolver1.opendns.com -t a myip.opendns.com +short

Add SSH keys

cd
cd .ssh

ls to list keys

ssh-add -k id_digital_ocean
ssh-add -k id_github

Terminal

New Tab Command T

To auto complete

cd abc<tab>

Move forward / backward one word

opt left arrow, right arrow.

Beginning of line

ctrl A

end of line

ctrl E

clear screen

ctrl k

Finder

Rename a folder: Click the folder and hold over it. Name will become editable.

New Tab; Command T

New Window; from anywhere, Command N

Disk Space

find . -name “node_modules" -print
find . -type d -name "node_modules" -exec rm -rf '{}' +

Since 30 days ago

find . -mtime -30 -name "*.js" -exec ls -l {} \;

Screen Saver

Control + Shift + Eject or Power

Shutdown

Command + Shift + Eject or Power

Screen Snapshot

  • Full screen: Command Shift 3
  • Partial screen: Command Shift 4

Save .png file to desktop.

Can drag and drop into Evernote.

Record Screen

Shift + Command + 5

Multiple Desktops

  • F3 (desktops)
  • Mouse to top right
  • Plus sign appears
  • Click it

Remove Desktop

  • F3 (desktops)
  • hover over desktop
  • X appears top left
  • Click it

Move to Another Desktop

  • F3 (desktops)
  • Drag window to the desktop

Add a Desktop

  • F3 (desktops)
  • Far right, a + will appear
  • Click it to add a desktop

Network Utility

  • Command+Spacebar to summon Spotlight
  • type "Network Utility" followed by the return key to launch the Network Utility app

Mac Quarantine

jar files downloaded from the internet are automatically set to quarantine.

To see this

xattr -l file

To clear this

xattr -d com.apple.quarantine my_jar.jar
xattr -dr

Show Hidden Files

  • Terminal
  • defaults write com.apple.finder AppleShowAllFiles YES
  • killall Finder

Enable Zoom

  • Apple, System Preferences
  • Accessibility

Notice

  • Toggle zoom: Shift Command 8
  • Zoom out: Shift Command +
  • Zoom in: Shift Command -

Open Ports

lsof -i | grep LISTEN

Evernote Mac Keys

Paste as Plain Text: Command Shift V

Make a Spec

  • Make screen shots and save to desktop.

  • Using Paint X Lite,

  • Drag images to extra large canvas, re-align them and save as .png to desktop.

  • Start Skitch

    • New file (Screen Snap, Blank)
    • Drag the image onto Skitch

Now can add text etc.

Save in Skitch (Evernote).

Combine PDFs with Brother Printer/Scanner

  • Arrange pages in order.
  • Place in feed print side up and top of document towards to the feeder.

Open Control Center

  • Scan
  • File
  • Check; Continuous Scanning
  • Start Scanning - will scan all the pages
  • Finish

The PDF is created on the desktop.

LibreOffice ODT to PDF

libreoffice --headless --convert-to pdf *.odt

or

  • Open with LibreOffice
  • Export
    • Pdf

Connect to Windows

For example, connect to remote windows host gamma

  • open terminal
  • cd /etc
  • sudo vi /etc/hosts
  • add ip to gamma

Should now be able to ping.

  • Open new Finder Windows
  • Finder menu
  • Go
  • Connect to Server
    • smb://gamma/

Should now connect to server, now authenticate

  • connect as: registered user
  • name: john
  • password:

Will show volumes to mount

  • mount as neeeded

Format USB Stick

Applications, Utilities, Disk Utility

  • Select Device
  • Erase

This should work.

If get error

Couldn't modify partition map

find the path of the USB

diskutil list

and erase the USB device /dev/disk5

diskutil eraseDisk ExFAT USBNAME /dev/disk5

Archived

Mac Update - check the following

Ethernet connection fails.

Reinstall

/Users/jv/Desktop/MyDownloads/mac/AX88179_178A_Macintosh_10.6_to_10.12_Driver_Installer_v2.8.0_20161108/AX88179_178A.dmg

Install and restart.

Install MySQL on MacAds Removal