Mac

From 太極
Jump to navigation Jump to search

macOS

https://en.wikipedia.org/wiki/MacOS

Darwin (operating system) and release history (first is September 30, 2015). Check the current machine's build number About this Mac > System Report > Software. I found after I installed the latest updates, the available disk space is increased.

Find OS version by command line

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.11.6
BuildVersion:	15G1004

$ sw_vers -productVersion
10.11.6

How to differentiate Linux and Mac

Use uname (unix name) with -s (system name) flag

# Mac
$ uname -s
Darwin

# Linux
$ uname -s
Linux

BSD and Linux

What’s the Difference Between Linux and BSD?

Darwin, MacOS, OpenSource?

http://superuser.com/questions/19492/is-mac-os-x-open-source. Darwin is like Linux, FreeBSD, etc... Mac OS X GUI is like KDE, GNome, etc...

Apple Open Source https://opensource.apple.com/. It includes Kernel, macOS, Developer Tools, etc.

Partition format

fdisk will show it is HFS/ HFS+. Ubuntu OS can read but can't write to it.

/dev/sdb1  *       64 250675199 250675136 119.5G af HFS / HFS+

However, I got a problem when I run cp command.

$ ls -l /media/brb/SamsungUSB/
-rw------- 1 99 99 10592270336 Feb 26 09:45 macSierra.ova
-rw-r--r-- 1 99 99  6922018816 Feb 15 14:40 Sierra10.12.3.iso
$ md5sum '/media/brb/SamsungUSB/macSierra.ova' 
md5sum: /media/brb/SamsungUSB/macSierra.ova: Permission denied

$ sudo chown brb /media/brb/SamsungUSB/macSierra.ova 
chown: changing ownership of '/media/brb/SamsungUSB/macSierra.ova': Read-only file system

Some suggestion is to disable journaled file system as this.

But I found the problem should be resolved in macOS. That is, running 'sudo chmod 644' on the file from an Mac computer.

Beta version of macOS

How to get the new version of macOS 10.13

Preferences - Energy Saver

Multiple desktops

Mission Control 101: How to Use Multiple Desktops on a Mac

Dashboard

Split screen

https://support.apple.com/en-us/HT204948

  1. Hold down the full-screen button in the upper-left corner of a window.
  2. As you hold the button, the window shrinks and you can drag it to the left or right side of the screen.
  3. Release the button, then click another window to begin using both windows side by side.

Click the green button to exit the split mode (and entering the full screen mode).

Black screen with cursor

After I opened the lid to wake it up and type my password, the screen kept black with a cursor only. My solution: hold the power button for a few seconds and the screen will pop us a dialog asked me for a few options. I choose 'restart' and the desktop is back. Later it shows Your Mac hasn't restarted because RStudio failed to quit. To continue restarting, quit RStudio. If I clicked 'Try again', the Mac will re-start.

https://www.cnet.com/news/macbook-pro-blank-screen-on-wake-from-sleep-2-fixes/

Booting problem

How to Repair Your Mac’s Disk Using Safe Mode, fsck, and More

OS X File System

Home directory

/Users/USERNAME

The following is the default directories under $HOME.

$ ls ~/
Applications	Documents	Library		Music		Public	
Desktop		Downloads	Movies		Pictures

See also How to reclaim the /home directory.

/ (root) directory

Some directory may be hidden. See http://www.westwind.com/reference/OS-X/invisibles.html

$ ls -l /
total 45
drwxrwxr-x+ 62 root  admin  2108 Feb 15 12:41 Applications
drwxr-xr-x+ 69 root  wheel  2346 Feb  9 11:02 Library
drwxr-xr-x@  3 root  wheel   102 Feb  9 08:47 Network
drwxr-xr-x@  4 root  wheel   136 Sep 16 17:07 System
drwxr-xr-x   7 root  admin   238 Feb  7 15:32 Users
drwxrwxrwt@  4 root  admin   136 Feb 15 13:32 Volumes
drwxr-xr-x@ 39 root  wheel  1326 Jul  8  2016 bin
drwxrwxr-t@  2 root  admin    68 Sep 16 16:59 cores
dr-xr-xr-x   3 root  wheel  4311 Feb  9 08:47 dev
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 etc -> private/etc
dr-xr-xr-x   2 root  wheel     1 Feb 14 15:31 home
-rw-r--r--@  1 root  wheel   313 Aug  2  2015 installer.failurerequests
dr-xr-xr-x   2 root  wheel     1 Feb 14 15:31 net
drwxr-xr-x@  3 root  wheel   102 Feb  9 14:58 opt
drwxr-xr-x@  6 root  wheel   204 Sep 16 16:59 private
drwxr-xr-x@ 59 root  wheel  2006 Sep 16 16:59 sbin
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 tmp -> private/tmp
drwxr-xr-x@ 12 root  wheel   408 Feb  9 11:02 usr
lrwxr-xr-x@  1 root  wheel    11 Sep 16 16:59 var -> private/var

Library folder & show hidden files/folders

How to show hidden files and folders including ~/Library on a Mac

In MacOS Sierra, use CMD-Shift-. (dot).

Or follow Quickly Show/Hide Hidden Files on macOS Sierra, OS X El Capitan & Yosemite

6 macOS Folders You Can Safely Delete to Save Space

https://www.makeuseof.com/tag/macos-folders-delete-save-space/

/Volumes and Machintosh HD directory

Macintosh HD is just a symbolic link to / (root) on your system; that is done in /Volumes.

$ ls -l /Volumes/
total 8
lrwxr-xr-x  1 root  admin    1 Feb  9 08:47 Macintosh HD -> /
drwxrwxr-t  8 root  admin  340 Jan 18 14:06 OS X Install ESD

/Users/Shared folder

macOS Sierra: Share files with others who use your Mac

Format SD card as FAT

Use SD Memory Card Formatter (Windows and mac only). See https://www.raspberrypi.org/documentation/installation/noobs.md.

ExFat: Best drive/partition format to share data between Mac, Linux and OS X

http://superuser.com/questions/398190/what-is-the-best-drive-format-to-share-data-between-mac-linux-and-os-x

  • Mac OS doesn't support writing to NTFS drives.
  • Mac OS can't find ext3/ext4 partition. See some solutions How can I mount an ext4 file system on OS X?
  • NTFS and REFS are a bad choice because Linux and Mac can't properly decode it
  • Ubuntu does not support exFAT by default. To get exFAT support, run sudo apt-get install exfat-fuse exfat-utils
  • exFAT doesn't support symlinks. So the Illumina igenomes data won't work on exFAT partitioned drive.
  • Fat32 has a 4GB single file limit and 2TB partition size.
  • In one case when my NTFS partition (USB drive) is broken, it becomes a format called 'RAW' shown on Windows Disk Management utility.
  • It is easy to create exfat partition format on Windows 7. When I move the USB drive to a Linux machine, fdisk -l shows
$ sudo fdisk -l /dev/sdc
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sdc: 123.6 GB, 123633401856 bytes
255 heads, 63 sectors/track, 15030 cylinders, total 241471488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5b508967

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   241469439   120733696    7  HPFS/NTFS/exFAT

For some reason using Disk Utility to erase/format a 16GB USB drive to ExFat failed (Media kit reports not enough space on device). Fortunately the command line method works (and fast at least for the 16GB space case).

diskutil list     # get the name to the disk you're trying to format
diskutil unmountDisk force disk2
sudo dd if=/dev/zero of=/dev/disk2 bs=1024 count=1024 # use bs=4000000 and skip count for an alternative
diskutil partitionDisk disk2 GPT ExFat "toshiba" 0g

use dd command to burn an ubuntu image

The bs parameter on Mac should be 4m instead of 4M.

The USB drive will not be able to start. It will give an error in GRUB step: illegal numeric value. This is tested on Ubuntu 18.04

Find partition type

df -hT

blkid /dev/sda1

mount

sudo file -sL /dev/sd*

sudo fdisk -l

rsync: mkstemp FILENAME failed: Function not implemented (38)

http://blog.marcelotmelo.com/linux/ubuntu/rsync-to-an-exfat-partition/

# Do not use 'rsync -av SRC DEST'

# Use
rsync -rltDv  --info=progress2 SRC DEST

What is the “wheel” user in OS X?

wheel is the system administrator group in BSD, much like root is the system administrator user. See http://superuser.com/questions/191955/what-is-the-wheel-user-in-os-x

/bin/sh and /bin/bash differences

https://discussions.apple.com/thread/3177477?start=0&tstart=0

How to Auto-Hide the Dock With No Delay

http://www.makeuseof.com/tag/auto-hide-dock-no-delay-mac/

Hide username from menu bar

https://apple.stackexchange.com/questions/57712/hide-username-from-menu-bar/57715. The other options are to show full name or icon only.

Move icons in the menubar

Hold the CMD key and then click and drag the icon.

Move icons in the Dock

drag and drop QUICKLY. Another trick is to drag the icon out of the Dock and put it back somewhere in the Dock.

Don't show recent applications in Dock in Mojave

macOS Mojave: Turn Off Recent Applications to Remove Extra Dock Icons

How can I list my open network ports with netstat?

http://apple.stackexchange.com/questions/117644/how-can-i-list-my-open-network-ports-with-netstat

sudo lsof -i -P | grep -i "listen"

Ethernet status icon

Consider "Ethernet Status" app. Horizon icon in bright color shows the ethernet is connected and grey color shows the ethernet is not connected. Free version works fine and the full version costs $1.99. See the discussion.

Another way is to open "Network Utility" from Spotlight or /System/Library/CoreServices/Applications.

The third way is just open "Network" from System Preferences.

Root account vs admin account

@ sign in file attributes

# seqtools-dl is a folder extracted from the SeqTools zip file.

# Case 1. the zip file is downloaded through a browser
brbs-iMac:~ brb$ ls -l@ Documents/seqtools-dl/SeqTools.app/Contents/MacOS/code
total 176
-rwxr-xr-x  1 brb  staff  18229 May 15 09:15 createGeneListSNPEFF.sh
-rwxr-xr-x  1 brb  staff   1550 Oct 24  2016 gdown.pl
-rwxr-xr-x  1 brb  staff   4214 May 15 09:15 gdown_mac.sh
-rwxr-xr-x  1 brb  staff  22264 May 15 09:15 statsVariantGeneAnno_Auto.sh
...

# Case 2. the zip file is obtained through the scp command
brbs-iMac:~ brb$ ls -l@ Downloads/seqtools-dl/SeqTools.app/Contents/MacOS/code
total 176
-rwxr-xr-x@ 1 brb  staff  18229 May 15 09:15 createGeneListSNPEFF.sh
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff   1550 Oct 24  2016 gdown.pl
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff   4214 May 15 09:15 gdown_mac.sh
	com.apple.quarantine	   57
-rwxr-xr-x@ 1 brb  staff  22264 May 15 09:15 statsVariantGeneAnno_Auto.sh
	com.apple.quarantine	   57
...

"App" is not optimized for your Mac and needs to be updated

32-bit app compatibility with macOS High Sierra 10.13.4 and later

Uninstall a program

How to Uninstall Programs on Mac

Create a Bootable macOS Installer

Make sure you use a USB flash drive or other removable media that has at least 12GB of available disk space.

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia \
     --volume /Volumes/usb16g --applicationpath /Applications/Install\ macOS\ Sierra.app

Reboot, holding down the OPTION key and selecting the “Install OS X Sierra” drive upon boot..

How to Run macOS Mojave in Parallels For Free

https://www.howtogeek.com/364272/how-to-run-macos-mojave-in-parallels-for-free/

Install to a USB drive

To boot from your external Sierra drive, plug it into the Mac in question, press the power button, and hold the Option key until the recovery disk screen appears. From there, you can select your external drive and click the arrow to boot into it for that session.

How to Install and Use macOS Sierra on an External Drive

https://www.howtogeek.com/293476/how-to-install-and-use-macos-sierra-on-an-external-drive/

How to Burn OS X El Capitan to a USB Flash Drive

http://lifehacker.com/how-to-burn-os-x-el-capitan-to-a-usb-flash-drive-1733425133

Install, Boot, and Run Mac OS X From an External Hard Drive

Pressing the Option key on boot displays a list of your Mac’s bootable drives.

Terminal

Where is the terminal

Macintosh HD/Applications/Utilities/Terminal.

Mouse pointer

A temporary solution is to hold the 'Alt' key while moving the mouse in the terminal. This strategy also works on RStudio's code panel.

Another solution is to use iTerm2 instead.

Keyboard symbols

Keyboard shortcuts

The Mac Terminal Commands Cheat Sheet

  • Ctrl + a OR Cmd + left arrow = going to the beginning of the line
  • Ctrl + e OR Cmd + right arrow = going to the end of the line
  • Fn + Down arrow = page down
  • Fn + Up arrow = page up

Rename terminal tabs

Click the “Shell” menu and select “Edit Title” to bring up the Terminal Inspector window

Terminal replacement

  • iTerm2. GPL2 license. Source code is in github.
    • (Update 5/14/2018) Copy from RStudio to iTerm2 R console may mess up. Don't find a solution yet.
    • Save window/tabs on exit?. Works.
    • The HOME/END keys work when I work in a virtual machine. To change font size, go to Preferences -> Profile -> Text -> Font or just use the keyboard shortcut Command + +/-.
    • Copy won't include the background color.
    • We can change the cursor color from grey to anything (Preferences -> Profile -> Colors -> Cursor Colors).
    • It can display image on its terminal using their own utility imgcat. After downloading it, chmod +x and then move it to /usr/local/bin directory.
    • iTerm2 Leaks Everything You Hover in Your Terminal via DNS Requests (9/20/2017)
  • MacTerm

exit does not close a terminal/tab

You can change the setting by Preferences -> Profiles -> Shell. See https://superuser.com/questions/158375/how-do-i-close-the-terminal-in-osx-from-the-command-line.

Mac Terminal’s Hidden Task Manager to See Background Processes

https://www.howtogeek.com/309273/how-to-use-the-mac-terminals-hidden-task-manager-to-see-background-processes/

terminal fun

Recording the terminal

asciinema

Keyboard shortcuts

How Not Using Keyboard Shortcuts Makes You Lose 64 Hours Every Year

Keyboard mappings using a PC keyboard on a Macintosh

Mac keyboard: Ctrl -> Option/Alt -> Cmd. Windows keyboard: Ctrl -> Windows -> Alt.

Mac-keyboard.jpg Windows-keyboard.jpg

Lock screen

Shift + control + power

Cut and paste files

http://osxdaily.com/2011/07/29/cut-and-paste-mac-os-x-lion/

  1. Cmd + C
  2. Cmd + Opt + V

Minimize all windows

  • Method 1: Cmd + F3 (min apps go to the RHS)
  • Method 2: Opt + Cmd + H + M

Finder

Command + [: move back to the previous folder

See more.

Navigation in a browser or document

  • Command + up = go to the top of the document
  • Command + down = go to the end of the document
  • Command + f = search
  • Fn + Down arrow = page down (or Spacebar in a web browser)
  • Fn + Up arrow = page up (or Shift + Spacebar in a web browser)
  • Fn + Left arrow = Home
  • Fn + Right arrow = End
  • Ctrl + TAB = switch tabs in browser

Text navigation and selection

12 Keyboard Shortcuts for Navigating & Selecting Text in Mac OS X

  • Select text to beginning of a line – Shift+Command+Left Arrow
  • Select text to end of a line – Shift+Command+Right Arrow
  • Select text to beginning of current word – Shift+Option+Right Arrow
  • Select text to end of current word – Shift+Option+Right Arrow
  • Select text to beginning of all text – Shift+Command+Up Arrow
  • Select text to end of all text – Shift+Command+Down Arrow

Switch input sources

Go to System Preferences -> Keyboard -> Shortcuts -> Input Sources. Check 'Select the previous input source ^Space'. Use Ctrl + Space to switch.

Compare to Windows/Linux

  • Use Command + q to close an application instead of "Alt+F4" on Windows/Linux.
  • System Activity tool:
    • Windows: Task Manager
    • Linux: System Monitor
    • Mac: Activity Monitor

Switch between windows of the same application

Cmd + ` (backtick)

Hardware

  1. MacBook Pro (Retina, 15-inch, Mid 2015) - Technical Specifications 2015 Macbook Pro model A1398, 15.4 inch.
  2. MacBook Pro 15 inch, 2018 Technical Spec. 2.6GHz 6 cores i7.

9 Essential Details You Must Know About Your Mac

https://www.makeuseof.com/tag/essential-mac-details/

Display resolution

2880x1800 on my 15-Inch Retina Display MacBook Pro. According to the Retina Display page on Wikipedia, its PPI (pixels per inch) is 220. To achieve the same PPI on 21.5 inch display, it has to be 4K and the display has to be 5K if it is 27 inch display.

Unfortunately Virtualbox (5.1.14) can only give 1440x900 (tested on Ubuntu & Windows). See a workout http://tusharm.com/articles/win7-on-retina-display-with-virtual-box/.

External monitor

On Dell U2718Q 27-inch 4K monitor, we can get a larger font size for every app by changing the scaling through System Preferences > Display > Resolution > Scaled. The choices are

  • 1920 x 1080
  • 2560 x 1440 (more comfortable)
  • 3008 x 1692
  • 3360 x 1890
  • 3840 x 2160

On the original macbook pro, the choices are

  • 1024 x 640
  • 1280 x 800
  • 1440 x 900 (more comfortable)
  • 1680 x 1050
  • 1920 x 1200

Touchpad

Need to press a little bit (instead of touch) for the left-click effect. If we want to use 'tap' for the click (like other OS), go to the System Preferences to change it.

The right click is called secondary click in OS X. We can enable it by going to System Preferences/Touchpad/Secondary click. Then tapping with two fingers would work. See Change or Disable the Secondary Click in Mac OS X.

Other handy gestures:

  • Scroll: two fingers move up/down. The direction is like moving a paper; i.e. scrolling up will gradually show the next part of the content.
  • Zoom in/out: pinch with two fingers.
  • Smart zoom: double-tap with two fingers.
  • Drag and drop method 1: Use the normal three finger drag, leave two fingers on the trackpad while doing a flicking motion with the third finger (eg thumb). The more momentum you add to your motion, the further it drags.
  • Drag and drop method 2:
    1. highlight the app first
    2. lightly click the app (you should only feel one click. Do not use too much force; if you do, you will hear two click sound and it will pop up a window to show the file information) with your thumb and then use your index to move the app to “Applications” directory.
  • Show desktop: Spread with thumb and three fingers
  • Mission control: Swipe up with three fingers
  • Swipe between full-screen apps: swipe left or right with three fingers
  • Dictionary/Thesaurus: Tap with three fingers

CPU information

sysctl -n machdep.cpu.brand_string

My macbook Pro 2015 shows i7-4980HQ (see GeekBench 4 score) CPU @ 2.80GHz. Quad cores. Eight threads. Base Frequency 2.8GHz. Max Turbo Frequency 4.0GHz. Bus Speed: 5 GT/s DMI2.

CPU temperature and alias

$ gem install iStats
$ istats

# We can make an alias by inserting a line in ~/.bash_profile
$ echo "alias temperature='istats'" >> ~/.bash_profile
$ source ~/.bash_profile

Fan and CPU temperature

When it asks for the admin password for its help tool, no need to enter it (choose 'Cancel') if we don't need to change fan control. See FAQ.

After launching it, it will show an icon on the menubar. It can be configured to show the CPU temperature (CPU Proximity result is close to istats reported) and fan speed.

RAM

Can you upgrade the ram in your Mac

Power Adapter

Keyboard battery level

macOS 10.11.6 shows the battery level is 18%.

macOS 10.12.6 corrected the calibration problem. Now it is showing 58%.

Battery

Plug or unplug

Should I disconnect my MacBook Pro's power cord when the battery is fully charged?. Answer: No.

Battery diagnostic

About this Mac -> Overview -> System report -> Power.

Cycle count limits for my macbook pro 15inch Mid 2015 (shown from About This Mac) is 1000.

  • The current cycle count currently is 175 cycle count (10/20/2017). Full charge capacity (mAh) is 8421.
  • The current cycle count currently is 199 (Feb 7, 2017 -> Nov 29, 2017). Full charge capacity is 8076.
  • The current cycle count is 263 (Mar 2, 2018). Full charge capacity is 8096.
  • The current cycle count is 430 (Oct 10, 2018). Full charge capacity is 7554.
  • The current cycle count is 437 (Oct 19, 2018). Full charge capacity is 7073 (80%).

The Chargeberry app shows the factory capacity is 8755 mAh.

Ambient light sensor

http://osxdaily.com/2010/05/22/where-is-the-ambient-light-sensor-on-a-macbook-pro/

Too hot: remove the cover, cleaning

How to Clean Dust Out of Your MacBook

Complaints

Macbook Pro 2015

  • Even the lid is closed, the fan is turning loud (6000 RPM for both fans, something is running?) parentalcontrolsd uses 248% cpu and the CPU temperature 50+. Router showed the machine's wifi is still on. The battery is drained out fast when I open the lid: Hazard!!
  • After I open the lid, the screen can not be unlocked. I only see the mouse cursor.
  • Wifi cannot automatically connect

iMac Pro

The new (2017) iMac Pro can be equipped with a 128 GB of memory and 4 TB SSD drive.

Finder - file manager

Change font size

View -> Show View Options -> Text Size

Copy file full path

This is important since RStudio cannot drag and drop a file to insert the file path.

  1. Navigate to the file or folder you wish to copy the path for
  2. Right-click (or Control+Click, or a Two-Finger click on trackpads) on the file or folder in the Mac Finder
  3. While in the right-click menu, hold down the OPTION key to reveal the “Copy (item name) as Pathname” option, it replaces the standard Copy option
  4. Once selected, the file or folders path is now in the clipboard, ready to be pasted anywhere

Cf. On Ubuntu, it is much simple. Just click Ctrl+C.

Enter key does not open the file

Use Command+Down instead of Enter key to open a file or go into a directory.

Enter key is only used to rename a file. See https://discussions.apple.com/thread/3140356?start=0&tstart=0.

Use Command+Down will immediately uncompress a tar.gz file.

Go to a folder

Use Cmd+Shift+o to go to a specific location by entering its full path. Unfortunately this option is not available in other applications in general.

Permanently mapping a network drive

Map a network drive to Mac OS X that re-mounts after system reboot

Users & Groups

In System Preferences -> Users & Groups. Click Login Items tab. You will see all item (e.g. NCIMacDriveScript) that will open automatically when I log in. The item location can be found by right clicking the item.

Tag

How To Tag Files on a Mac, iPhone, or iPad

Commander One

Free dual pane file manager for Mac.

  • User Guide
  • The bookmark is called 'Favorites' in Commander One. Click the 'star' icon and a Windows' style of a right click menu will pop up. You can select 'Add to Favorites' to add the current directory to the favorites. This bookmarked location will be shown when you click the 'star' icon next time.
  • The icon (multiple horizontal lines) next to the 'star' shows the recent locations. This is useful too!
  • By default, Commander One will send anonymous usage statistics to Eltima. Go to Preferences -> General to uncheck this option.

Find files

The 5 Best Spotlight Alternatives for Searching Mac Files and More

Screenshots

Terminal

Use the screencapture command.

screencapture test.jpg

screencapture -c    # send to the clipboard

screencapture -T 10 timedshot.jpg # timer 

screencapture -w test.jpg
# OR
screencapture -W

screencapture -h     # help

To view an image file, use the open command. See also Shell tricks: the OS X open command.

open test.jpg

To view the metadata of an image file, use the mdls command such as mdls XXX.png. See How to look up file metadata in OS X

Grab

Grab is a utility. Finder -> Go -> Applications -> Utilities -> Grab.

How To Use macOS & Mac OS X Grab Utility To Take Screenshots

Take a Timed Screenshot With the Grab (built-in) Application. Open Grab, select Capture -> Selection/Window/Screen/Timed screen.

Lightshot

Lightshot works like Shutter in Ubuntu - easy to use and can sit on the taskbar.

Note: to view an image resolution in Finder, right click an image and select Get Info -> More Info.

Its icon is a feather.

Feather has an advantage that the screenshot does not need to be saved. It can be copied to a clipboard and then discarded.

Screen cast/recorder

Top Best Screen Recorder For Mac

Quicktime player

We can record the screen (full screen or a selected region). The recorded file will be in a .mov format.

recordit

Screen cast o magic

http://screencast-o-matic.com/

Application

How to Install Applications

Keyboard shortcut to launch an application

  • F4 key - LaunchPad
  • Command + Space - Spotlight search

Messages when you launch an application

  • Google Chrome

ChromeMac.png

  • iTerm

Iterm open.png

  • SeqTools

Seqtoos open1.png Seqtoos open2.png Seqtoos open3.png

Install pkg file from command line

http://apple.stackexchange.com/questions/15658/how-can-i-open-a-pkg-file-manually

sudo installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/
# OR
installer -pkg ~/Downloads/packagename.pkg -target ~/Applications/

Close an application

Clicking the red button does close/quit an application/a program. You need to use Command-Q.

Another answer: The red close button just closes the window. It is up to the application whether it quits or not - typically if the application uses documents or it has other windows that can be opened it will not quit. Applications with a single window (System Preferences, for example), will usually quit when the window is closed, since there isn't anything else it does.

Delete/remove an application

AppCleaner

Package formats

app directory

Example: App Store.app, Atom editor, SourceTree

http://apple.stackexchange.com/questions/112197/what-does-a-app-file-actually-do

apps are "Package Bundles" is Apple jargon. These are actually Unix directories, in a special format. The actual Unix Executable File is in a subdirectory named MacOS, which you can see using the "Show Package Contents" menu in Finder.

To deliver the program in an app format, we can zip the app folder. If we use Safari browser, it will automatically decompress the zip file so the app program will appear in the Downloads directory.

For example, in SourceTree, the download file is called 'SourceTree_X.Y.zip'. When we click the zip file, it will be automatically extracted. And when I click SourceTree.app, it will have a dialog to help user to move the program to the application folder.

Sourcetree.png

pkg file

Example: R-cran

PKG files are Mac OS X installation (setup) packages that contain installer scripts ('Scripts' file) and compressed installation files ('Payload' file) that are used to install Mac software applications onto a user's hard drive.

On the case of R-x.y.z.pkg, it contains R framework, R.app GUI, Tcl/Tk X11 and TexInfo.

To install a pkg file from terminal, see this post

sudo installer -pkg R-3.3.3.pkg -target /

pkgutil

dmg (disk image) file

Example: Google chrome, JDK, FastQC, Sketchup, Commander One.

A DMG file is a disk image, which is sort of like an archive file. When you download one, you can double-click it to “mount” it (under Devices in the Finder), allowing you to extract the application from inside it.

After the app is dragged to your Applications folder, you can run it normally — from the Finder, Launchpad, Spotlight, dock, or anything else.

We can mount or eject a dmg file by

# mount
hdiutil mount fastqc_v0.11.5.dmg
# copy its content
mkdir -p ~/FastQC
cp -r /Volumes/FastQC/FastQC.app/Contents/MacOS/* ~/FastQC/
# eject
hdiutil eject /Volumes/FastQC/

To create a dmg file (see command line or here and GUI)

hdiutil create -volname WhatYouWantTheDiskToBeNamed \
    -srcfolder /path/to/the/folder/you/want/to/create \
    -ov -format UDZO name.dmg

To convert a dmg file to iso

hdiutil convert imagefile.dmg -format UDTO -o imagefile.iso
mv imagefile.iso.cdr imagefile.iso

To install a dmg file from terminal, see this or this

MOUNTDIR=$(echo `hdiutil mount jdk-8u121-macosx-x64.dmg | tail -1 \
| awk '{$1=$2=""; print $0}'` | xargs -0 echo) \
&& sudo installer -pkg "${MOUNTDIR}/"*.pkg -target / \
&& sudo hdiutil detach "${MOUNTDIR}"

Explanation: The first command (hdiutil mount jdk-8u121-macosx-x64.dmg) will output

expected   CRC32 $628D96B6
/dev/disk2          	GUID_partition_scheme          	
/dev/disk2s1        	Apple_HFS                      	/Volumes/JDK 8 Update 121

We like to grab the string "/Volumes/JDK 8 Update 121". This can be achieved by getting the last line of the output and replace the first and 2nd fields with empties and then output the whole line.

Package manage software

http://apple.stackexchange.com/questions/32724/what-are-pros-and-cons-for-macports-fink-and-homebrew & http://apple.stackexchange.com/questions/64690/macports-vs-fink-vs-homebrew

MacPorts

Different versions of Mac OS X has a different macport binary (in .pkg format).

MacPorts Brings the Best Open Source Software to Your Mac

Homebrew

# Install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# It will ask around 11 times on your administrator password for a variety of questions.

# install some package
brew install wget
brew install htop
brew install ruby # install a newer version of ruby & gem; overwrite the pre-installed one 
brew install cvs
which htop        # /usr/local/bin/htop
# Update brew
brew update  # Not add sudo
# Uninstall homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

brew tap command

How to uninstall / remove a Homebrew package including all its dependencies

Homebrew Cast extends Homebrew and brings its elegance, simplicity, and speed to macOS applications and large binaries alike. What is the difference between `brew` and `brew cask`?.

Fink

No binary installer for recent versions of OS X (good to me). You will need to install the proper Command Line Tools for Xcode for your system.

Rudix

# install
curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py | sudo python - install rudix
# install some package
sudo rudix install wget
sudo rudix install python-pip
# remove a package
sudo rudix remove python-pip
# uninstall
sudo rudix -R

Extract files (Unzip)

Unarchiver. Mentioned by Raspbian.

Image editor

https://www.howtogeek.com/304677/the-best-free-photo-editors-for-macos/

Note when I use the 'Preview' program, it will automatically save the changes without any warnings when I exit the program.

Paintbrush

https://paintbrush.sourceforge.io/

Works fine. It does prompt to save for any changes when I quit the program.

Text editor

http://beebom.com/best-text-editors-for-mac/

For printing to pdf files with line numbers, I am using GEdit in Ubuntu VM. Some promising editors like BBEdit cannot even let me open rmd files.

Change the default text editor

Just right (or control) click a file of the type you want to change and: "Get Info" -> "Open with:" -> (Select your program) -> "Change All".

The above method can be used to change the default player too (iTune -> VLC).

If you use the open command in a terminal to open a text file, the default program will be used.

Atom editor from Github

Complains: too frequent updates. It makes multiple instances on the right click menu in Finder on macOS (seems it is only a problem on Mac). See a report here. A solution is

rm -rf ~/Library/Caches/com.github.atom.ShipIt 
killall Finder

and then launch Finder manually.

Atom Flight Manual

  • The atom application requires no installation. So once it is downloaded (we actually download a zip file. After download has finished Safari browser will automatically decompress the zip file), we can drag it to the Application folder.
  • Open atom from a terminal.

Method 1 (GUI). Atom -> Install Shell Commands. Two symbolic links (atom and apm) will be created in /usr/local/bin to point to the currently opened Atom application.

Method 2 (Manual):

ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
  • When you open the Atom the first time, it will split the screen into two panes: on the LHS it has a 'Welcome' and on the RHS it has a 'Welcome Guide'. You can choose to close any one of them by View -> Panes -> Close Pane. You may reopen the Welcome Guide by Help -> Welcome Guide.
  • You can hide the directory on the left hand side by View -> Toggle Tree View.
  • Command Palette: Press Cmd+Shift+P.
  • Settings: Atom -> Preferences.
  • Open a file: Cmd+o. Save a file: Cmd+s.
  • If a file is modified and not saved yet, the changes are saved to a cache. Even we close Atom, the changes are there. The original file is still intact.
  • Open a directory as a project. Open a folder will add a tree view to the editor where you can browse all the files. You can toggle the tree view on the side of the window by Cmd+\.
  • Jump to a specific line: Ctrl+g.
  • Find and replace: Cmd+f. To search the whole project, Cmd+Shift+f.
  • Folding: Alt+Cmd+[ and Alt+Cmd+]
  • Panes splitting: Cmd+K Up/Down/Left/Right
  • Preview a markdown file (toggle): Ctrl+Shift+M
  • R syntax highlight
$ apm install language-r
Installing language-r to /Users/USERNAME/.atom/packages ✓
# Re-start Atom to enable it

Printing. No way!

Macdown- markdown editor

If I use macDown to open a text file, macDown will still assume the file is a markdown file and give a preview on the right panel.

Sublime

http://www.sublimetext.com/

How do I open new files in a new tab?

TextMate

http://lifehacker.com/5817833/the-best-programming-text-editor-for-mac

For some reason when I open an old file, TextMate does not open it on a new tab; it opened the file in a new window??

BBEdit

5 年過去了,知名文字檔編輯軟體 BBEdit 回歸 Mac App Store

gedit

http://macappstore.org/gedit/ Does not work. I got the same error.

Jekyll

http://idratherbewriting.com/documentation-theme-jekyll/mydoc_install_jekyll_on_mac.html

Text to speech

Dictionary

Expand Your Mac’s Dictionary App by Adding Additional Languages

I add 'Simplified Chinese - English' dictionary and move it to the top. With the change, when I right click a word and choose 'Look Up' in a browser, the 'Simplified Chinese -English' will be shown up on top.

Videos

How to Trim Videos with Quick Look in macOS Mojave

Printer

To print a test page: Mac -> System Preferences > Printers and Scanners. Double click a printer, go to the menu on top and select Print -> Print Test Page.

When installing an office printer (\\nciprint\5W012CAN5560, Canon iR-ADV C5550/5560 UFR II), mac asks for the driver (1. Generic PostScript Printer 2. Generic PCL Printer 3. Select Software). If I choose Generic PostScript Printer, the test page shows the driver name "Generic.ppd" and version 1.0. When I download the driver from Canon website and add the printer using the new driver, the test print page shows driver name CNPZUIRAC5550ZU.ppd.

PDF

Print to PDF from the print dialog

In the Print dialog, look for the “PDF” button in the lower left corner, click on that pull-down menu, and select “Save as PDF”. Click “Save” in the save dialogue box, and save the file to whatever location you want.

Command line to print a file to pdf

# Suppose we have an R file. We like to print it to PDF with line numbers.
$ cat -n tmp.R > tmp.txt
$ cupsfilter tmp.txt > tmp.pdf

# OK. But how to control the font size? How to deal with indentation for line wrapping. Landscape orientation.
  • text2pdf
  • Use pandoc to convert it to docx (so we can control font size) and convert it again to PDF.

Convert a pptx to pdf

The 'Zoom' function is kind of slow to response with Office 2016. There is no this problem with converted PDF file.

  • Use 'Save As...'
  • Don't use print to PDF. The quality will reduced.

Delete/add/reorder page pages using Preview

http://osxdaily.com/2010/01/20/delete-pages-in-a-pdf-document/

There is no need to save the document. It will be saved automatically.

For some reason, after I join pdf files and export the merged pdf, the exported file contains only 1 page.

A more reliable way is to use a built-in command line program 'join.py' (works on OS X El Capitan)

# Use Cmd + c to copy PDF files relative paths from /home/$USER/Downloads directory

cd /User/$USER/Downloads/
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" \
  -o FILE.pdf \
  file1.pdf file2.pdf /PATH/TO/A/WHOLE/DIR/*.pdf

Print multiple pages per sheet

"Preview" does not have this option. Use Adobe Reader.

Merge/combine several PDF files

How to Use Mojave’s Quick Actions to Quickly Combine PDFs on the Mac

Crop pdf files

Preview. See a demonstration on youtube. This is very good and the crop experience is similar to briss.

  1. View → Thumbnails
  2. Select all pages by Cmd+a. Use Cmd+click to unselect any pages.
  3. Click the Show Markup Toolbar button from the RHS of the toolbar and click the Rectangular Selection button or directly click on Tools → Rectangular Selection
  4. Use mouse to select an area on the first page (or on a specific page). A rectangular area will show up on ALL pages.
  5. Adjust the width/height as you want from the 1st page (or from the specific page).
  6. Close the document and the changes will be automatically saved.

Edit by Preview

Search woe in Preview

If a word is split, it can not find it. For example, "ade-quacy" cannot be found.

Preview Keyboard shortcuts

  • Hide sidebar: CMD + Option +1
  • Show sidebar: CMD + Option +2
  • Show Table of Contents: CMD + Option +3

Kill Preview

Using the command line: killall Preview

Icon/symbol next to opened documents under 'Window' menu

https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/

  • Checkmark: the active document
  • Diamond: document that is currently minimized in the Dock.

Disk

Trash can

See its icon in the Dock.

Using the trash folder

Alternative to WinDirStat

https://alternativeto.net/software/windirstat/?license=free&platform=mac

  • ncdu
brew install ncdu
  • Disk Inventory X. It shows the sizes of files and folders in a special graphical way called "treemaps". The filename is DIX1.0Universal.dmg. It froze my Mac:(
  • QDirStat based on Qt. No binary for macOS
  • DaisyDisk $10.

Google Chrome browser

Safari

How to View Websites on Mac that Require Internet Explorer/Edge (or a PC)

Developer

Macs (unlike Linux) don’t come with a package manager, but there are a couple of popular package managers you can install. See SciPy.

Install Xcode

http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

Note:

xcode-select --install

The installed tools (like ar, gcc, g++, git, libtool, make, nm, otool, svn, et al) are located in /Library/Developer/CommandLineTools/usr/bin/ directory. If the command is run again, you will get a message

xcode-select: error: command line tools are already installed, use "Software update" to install updates 

To check the Xcode version (if you have installed a full Xcode)

$ xcodebuild -version  # if you have the full Xcode installed
Xcode 8.2.1
Build version 8C1002  # if you only have the command line tool installed
$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer 
directory '/Library/Developer/CommandLineTools' is a command line tool instance

To check whether Xcode has been installed

$ xcode-select -p
/Library/Developer/CommandLineTools             # if you have installed the command line tool only
# or
/Applications/Xcode.app/Contents/Developer  # if you have the full Xcode package installed
# or
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one
(or see `man xcode-select`)

To accept the XCode license through command line, follow the post Debugging macOS Kernel using VirtualBox:

$ sudo xcodebuild -license accept # it seems not working. A dialog is still popped up.

The df command shows installing the command line developer tools takes about 600MB space.

Uninstall Xcode

http://osxdaily.com/2012/02/20/uninstall-xcode/

Header file location

  • /usr/include (does not exist on my 10.12 Sierra)
  • /usr/local/include (some are over there; e.g. from "sudo make install" command)
  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (if you have installed a full Xcode)

I get the following error

In file included from init.c:1:
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [init.o] Error 1
ERROR: compilation failed for package ‘later’

when I install some package. The stdlib.h file is missing from /usr/local/include. However, a simple C code compiles fine.

#include <stdio.h>
#include <stdlib.h>

int main ()
{
  char str[10] = "3.14";
  printf("The value is %f\n",atof(str));
  return 0;
}

See this post (R-SIG-Mac) 'math.h' file not found

sudo installer -pkg \
  /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
  -target /

However, I don't have "Packages" directory.

See Where is my “stdio.h” in Mac? & Simply installing Xcode will not install all of the command line developer tools. Try

  • Run "sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/include". Get a message "Operation not permitted". See this post Unix “ln -s” command not permitted in OSX El Capitan Beta3
  • Run "xcode-select --install". Get a message "Can't install the software because it is not currently available from the Software Update server."

Search within R-SIG-Mac Archives.

System Integrity Protection/SIP

Lib location

  • /usr/lib
  • /usr/local/lib
  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib/ (if you have installed a full Xcode)

ldd on Mac

otool -L  <exec>

openssl

Method 1: brew

brew doctor
brew update
brew upgrade
brew install openssl  # the opposite operation is 'uninstall'
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .

Method 2: compile yourself

Python packages

http://www.scipy.org/install.html

Install macOS on a PC

http://www.makeuseof.com/tag/how-to-install-mac-os-x-on-a-pc-without-using-a-mac/ (7/17/2017)

VirtualBox

Touchpad

The direction of scrolling up and down in guest machine is opposite to the host machine.

Keyboard shortcuts (macOS + Windows keyboard)

Since there is no Command key on Windows keyboards, we need to modify preferences.

Copy and paste: go to preferences -> keyboard -> Modifier keys. Change 'Option' key to 'Command' key and 'Command' key to 'Option' key. Since the 'Option' key is 'Alt' on Windows keyboards, the layout will be very similar to using Mac keyboards. This is consistent with Logitech K780 multi-device keyboard where 'Alt' key shares with the 'Command' key.

Do not use Ctrl to replace Command; you will not able to use the Ctrl key in nano and you are missing Ctrl + a to move mouse to HOME in Terminals. NOTE: iTerm2 is a good replacement for macOS's built-in Terminal program; HOME/END works.

Keyboard shortcuts (Windows OS + mac keyboard)

  • Left CMD is used by VirtualBox to switch to full screen (at least on VirtualBox)
  • Right CMD = Windows key
  • fn + delete = DEL/Backspace key

Guest additions

VirtualBox doesn't have guest additions for OSX. http://askubuntu.com/questions/372982/virtualbox-4-3-guest-additions-on-osx-guest

In order to share files between the host and guest machine, we need to 1. add 'host-only' network adapter to the guest machine and 2. enable 'Remote Login' by going to the System Preferences -> Sharing.

For example, from the host machine, I can use the following on the host machine to access the guest machine

$ ssh [email protected]

However, it is unsuccessfully to do access the host machine from the guest machine??

$ ssh [email protected]

Smart card reader

If USB is enabled in the guest machine, the Smart Card reader will not be available on the host machine. That is, we cannot use the smart card in Mac. So it is necessary to uncheck the USB from the USB setting in the guest machine.

Screen resolution

https://forums.virtualbox.org/viewtopic.php?f=22&t=54030 works.

$ VBoxManage setextradata "vm_name" VBoxInternal2/EfiGopMode 4

The number '3' corresponds to a resolution of 1280x1024 (5:4) and '4' corresponds to 1440x900 (8:5). On lenovo laptop (1600 x 900, 16:9), the height will fill the screen but there are little black spaces on both sides. See Display resolution and aspect ratio.

Note that I need to enable Full Screen for the guest machine b/c the desktop is too large.

El Capitan (10.11)

It works on my VirtualBox 5.1.14 and Macbook Pro 2015.

Note: if I skip the following commands, the macOS booting will keep re-run again and again.

VBoxManage modifyvm macElcapitan --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata macElcapitan "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1   

Con: The image downloaded there is already a virtual machine image format.

If I try to use the iso file downloaded from internet, I saw an error "Missing Bluetooth Controller Transport" (https://gist.github.com/frdmn/de12c894a385bc8e6bff).

Sierra (10.12)

  1. Enable Picture-in-picture. Right click on a video and then immediately right click again. It will show an option "picture in picture" in the right-click menu.
  2. The official image (e.g. Install macOS Sierra.app) we downloaded from Apple Store is saved under /Applications folder.
  3. We can follow the instruction https://github.com/geerlingguy/macos-virtualbox-vm to convert the app folder into an iso file. The prepare-iso.sh script seems to always put the iso file onto the Desktop folder; i.e. output folder and name is not taken.
  4. When we want to create a virtual machine in VirtualBox
    • video memory change from 16GB to 128MB
    • increase memory to 4096MB
    • turn off audio
VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff

Another instruction is to run (this seems to be necessary even we uses 'import Appliance' method)

VBoxManage modifyvm "Sierra10.14" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Sierra10.14" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

After booting, select the preferred language and (before click the 'Continue' button) go to Utilities > Disk Utility. Select the VirtualBox disk (VBOX HARDDISK Media)and choose Erase to format it as a Mac OS Extended (Journaled) drive. Installing macOS took about 15 minutes on my Dell T3600 Desktop running Ubuntu/Mint.

After a successful login, the 'df -h' command shows macOS uses 8.6 GB space.

Unfortunately, the Mac guest machine cannot install guest additions.

I get a 'Guru meditation' error when I test the iso on an old non-mac machine (intel core 2 duo CPU).

Note there is an error (IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0) to install Sierra 10.12.4 as a guest machine. See https://benlimmer.com/2017/04/23/macos-sierra-virtualbox-10-12-4/.

High Sierra (10.13)

How to Download macOS High Sierra From macOS Mojave

Mojave (10.14)

On VB 5.2.x.

# cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage modifyvm "macMojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "macMojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Change Settings. Select USB and check 3.0 USB. This is to enable mouse and keyboard support in the virtual machine.

After the first reboot, I need to remove the iso file. But it dropped to Shell after I boot up. It's more complicated. See the 3rd link above.

On Step 8, it complains "cd System\Library\CoreServices\". Change to use fs1 instead of fs2 fixes a problem.

I am setting up a new user (brb/arraytools). Note the password must be at least 4 characters.

It shows 12 GB was used when I first boot up the machine.

The "TheTechBlogger_APFSEfi.iso" should be kept there.

Create an ISO from the Sierra install app obtained from the Mac app store

https://klue.github.io/blog/2017/04/macos_kernel_debugging_vbox/

How to Run Your Mac’s Boot Camp Partition as a Virtual Machine

https://www.howtogeek.com/315083/how-to-run-your-macs-boot-camp-partition-as-a-virtual-machine/

Remote connection (ssh)

Use Preferences -> Sharing -> Select Remote Login. http://osxdaily.com/2011/09/30/remote-login-ssh-server-mac-os-x/

To uses a command line to enable it, see

ssh key

Remote/Virtual machine: go to system preferences -> sharing and enable remote login. Suppose the user name is 'brb' and the hostname is 'brbs-MacBook-Pro.local'.

Host machine:

ssh-keygen -t rsa -f ~/.ssh/virtmac  # press 'Enter' 3 times
cat ~/.ssh/virtmac.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
ssh -i ~/.ssh/virtmac [email protected]

When I run testings, I need to restore the virtual machine to its initial status. I can use this method in order to avoid the message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" when I use the 'ssh' command.

Remote Desktop Connection to Mac

On Mac, go to system preferences -> System Preferences -> Sharing -> Screen Sharing. It will show the vnc address of the Mac computer.

On my Ubuntu, see AppleRemoteDesktop

  • The built-in program Remmina Remote Desktop Client does not work. After clicking the 'connect' button & entering username/password, the screen flashed and disappeared.
  • RealVNC. I download the tarball (VNC Connect 6.0.3, Generic x64, default). Extract it to the Download folder and run vncviewer program. Yes, I can connect to Mac. But since the Mac has a very high resolution, I need to adjust the resolution setting in my connection. To do that: close the connection, right click a connection icon (created from last connection), choose Properties. In 'Options' tab, select Scaling -> Scale to fit window.
    • After connection, a toolbar will appear on the top of screen. It has a series of icons: Full screen mode, No scaling, Ctrl Alt Del, Info, Properties, Disconnect.
    • Even Mac screen lid is closed, VNC still works.
    • The connection speed is not ideal. You can see the screen refresh slowly.
  • Vinagre. It has to be installed from Ubuntu Software. Unfortunately it does not even allow me to enter a long password:(

Remote Desktop Connection from Mac

When I try to use the Screen Sharing (1.7) program in Mac to connect to Ubuntu 16.04 (type 'vnc://192.168.1.188'), I get an error 'The software on the remote computer appears to be incompatible with this version of Screen Sharing.'

Failscreensharing.png

Another remote desktop program is called Remote Desktop Connection for iMac. It appears to be used to connect to a Windows-based computer.

Tips

Got a New Mac? Do This First!

http://www.makeuseof.com/tag/new-mac-setup/

Update date and time using command line

sudo ntpdate -u time.apple.com
sudo ntpdate -u ntp1.nih.gov

Forget a wifi network

macOS wants to use the "login" keychain

It asks me to enter my keychain password where I have my PIV card inserted. I need to enter my PIN not password.

I need to enter my PIN (PIV card is connected) for wifi to connect to office network.

Scopedbookmarkagent wants to use keychain

I need to enter my PIN (PIV card is connected) for wifi to connect to office network.

List DNS servers

How do I check what DNS server I'm using (on Mac OS X)

$ scutil --dns | grep 'nameserver\[[0-9]*\]'

To change the DNS settings, follow this.

How to Keep an iPad From Dropping Wi-Fi Signals

Renew the iPad's DHCP lease.

Change the channel on your wireless channel (pick the channel has the lowest signals).

PS1

If I give PS1="\[\w$ " it will change my prompt from

NCI-12345678-ML:bdge USERNAME$

to

~/github/bdge$ 

where the new one is probably better. We can replace \w with \W to get the directory basename instead of the full path.

The default PS1='\h:\W \u\$ ' is defined in /etc/bashrc.

My El Capitan, I need to create a new file ~/.profile (not in ~/.bash_profile) and put the command there.

export PS1="\w (\!)\$ "

See

app Store

  • Need a credit card information. The 'None' option is not available. Some tricks.
  • Cannot log in my account. Activity clock just keeps spinning and spinning
  • If macOS has been downloaded, the 'Download' button will be changed to 'Open' button in 'App Store' application.
  • If my macOS is already Sierra, we don't need to sign into 'App Store' in order to download a newer version Sierra image.

Upgrading to macOS Sierra (nee OSX) for R users

http://www.win-vector.com/blog/2017/01/upgrading-to-macos-sierra-nee-osx-for-r-users/

Access the Root Directory

http://osxdaily.com/2013/01/17/access-root-directory-mac-os-x/

Disable update notification

http://news.softpedia.com/news/how-to-disable-os-x-update-notifications-493961.shtml

How to download macOS update using the terminal

https://www.howtogeek.com/347920/how-to-download-macos-updates-using-the-terminal/

Console/All Messages

This is like the system log application in Linux/

Does not sleep when the lid is closed

$ syslog | grep 'Wake reason' | grep 'Mar 22'
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: ?
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: RTC (Alarm)
...  processWakeReason Wake reason: Host (0x01)
...  Wake reason: EC.LidOpen (User)

$ pmset -g assertions
2018-03-22 19:45:03 -0400 
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 120(hidd): [0x00050da000090379] 00:16:13 UserIsActive named: "com.apple.iohideventsystem.queue.tickle" 
	Timeout will fire in 1189 secs Action=TimeoutActionRelease
   pid 2903(RStudio): [0x0004b27a000124c2] 08:02:10 PreventUserIdleSystemSleep named: "R Computation" 
   pid 2903(RStudio): [0x0004b27a000124ba] 08:02:10 PreventUserIdleSystemSleep named: "R Computation" 
No kernel assertions.
Idle sleep preventers: IODisplayWrangler
  • It seems mac wakes up every 2 hours according to the syslog output. This issue is indeed caused by the discoveryd process.
  • It may be useful to run ping from another machine to see if Mac is still connected to the internet (cannot check if it is live)
  • Since when I wake up the machine the next morning, the internet is not connected, it may be useful to send emails in a regular time interval to see how long the machine still is connected to the internet.
  • Battery life went down from 98% to 88% the next day morning even I put the machine to sleep in the afternoon before I left.
  • Turn Off in Power management "Wake up by Wifi"
  • iMac randomly wakes up from sleep. In my case, I see Rstudio and hidd processes show 'Yes'.

Prevent ssh from sleep

http://osxdaily.com/2011/03/21/temporarily-prevent-a-mac-from-sleeping/

pmset noidle

This method does not prevent Mac from displaying screensaver & locking the screen. But it seems to fix the problem of broken pipe in ssh connection.

A better way is to modify .ssh/config file. See Way to prevent ssh connection timeout.

How to Configure a Proxy Server

https://www.howtogeek.com/293444/how-to-configure-a-proxy-server-on-a-mac/

Open a chm file

iChm program works fine. Chmox is too old (power pc) and not works.

CHM Reader from Mac App Store is not different from iChm.

Back up

Record sound

Use 'QuickTime player'.

The build-in microphone is located inside the left speaker. The recording sound is weak. Go to System Preferences -> Sound. Select 'Input' tab and increase the 'input volume' from the smallest to the loudest.

If we want to use an external mic, make sure the headphone connector has 4 sections.

XXX can't be opened because it is from an unidentified developer

/private/var/folders

https://discussions.apple.com/thread/1933443?start=0&tstart=0

If SeqTools was downloaded through a browser, then when we launch it the R script folder in <run_variantannose.sh> becomes something like /private/var/folders/1h/kcm8vkdx6nl00z5wjm5bqlw00000gp/T/AppTranslocation/051E078E-7C2D-4C6C-90FF-F651985EC9C0/d/SeqTools.app/Contents/MacOS/SeqTools/code

Extreme NAC Assessment Agent

https://isdp.nih.gov/isdp/version.action?prodid=220

'Please enter the host name or IP address of the Extreme NAC Assessment Agent server' 137.187.64.22.

Which Processes Can You Safely Quit in Activity Monitor on a Mac

Which Processes Can You Safely Quit in Activity Monitor on a Mac?

Command line to find the IP address

ipconfig getifaddr en0 # it will return XX.XXX.XX.XXX

Or use ifconfig to show all of the interfaces and their IPs.

Uninstall inSync

https://www.insynchq.com/uninstall

Use AirDrop to share files between Macs and iOS devices

How to Add an AirDrop Icon to Your macOS Dock

How to Transfer Files From PC to iPhone and iPad (And Vice Versa)

How to Transfer Files From PC to iPhone and iPad (And Vice Versa), FileApp

Share Files Between Mac & Windows Computers

Share files on your Mac so that it appears on Windows computers automatically.

Share Files Between iOS and Mac

What Is Airdrop? How to Share Files Between iOS and Mac

Digital color meter

Discover the DigitalColor Meter tool on your Mac Very useful when you want to know the color's RGB value from any dot on your screen.

Notes folder

Where do my notes written in the Notes application on my Mac get saved?

$ ls ~/Library/Group\ Containers/group.com.apple.notes/
Library			NoteStore.sqlite	NoteStore.sqlite-shm	NoteStore.sqlite-wal

The data can be synchronized through iCloud. How Do I Sync My iPhone Notes With Mac Or PC?.

PIV card

  • Open Keychain Access. It should show up "PIV-USER NAME-A" on the first item.
  • Change browsers (Chrome -> Safari). Firefox does not help.
  • Empty Cache in Chrome
  • Incognito mode (not help)
  • Reboot
  • Change PIC card reader (new one uses less power)

Git GUI Client

https://git-scm.com/download/gui/mac

SourceTree

sourcetree. See also Happy Git and Gihub for the useR from Jenny Bryan.

Unfortunately it requires a Bitbucket account in order to finish its installation.

Github Desktop

Looks good. It is OK to bypass to login a Github account in the installation process.

Useful Apps

The Ultimate List of Mac Menu Bar Apps

Amphetamine: keeps your Mac awake (not sleep)

Caffeine is too old. KeepingYouAwake is a small menu bar utility that is inspired by Caffeine from Lighthead Software. The app is a small wrapper around Apple's caffeinate command line utility.

See a review of Amphetamine and one from lifehacker.

Lungo is another one (paid) and it requires macOS 10.13.

Take a break

Five free apps to help remind you to take a break.

  • Time Out looks cool. Some features like put the app in the menu bar are available for supporters:(
  • Break Timer, memory leak?
  • Stretchly

My installed apps

  • iTerm2
  • RStudio, R
  • Amphetamine
  • Anaconda-Navigator
  • Firefox
  • Flux
  • Lightshot Screenshot
  • Meld
  • Paintbrush
  • Stretchly
  • The Unarchiver
  • VirtualBox
  • VLC
  • Xcode
  • SourceTree
  • Atom
  • Visual Studio Code
  • Pennywise
  • XQuartz (R does not need it; R uses Quartz for plotting).
    • However when I try to install tinytex package, it complains unable to load shared object '/Library/Frame/R.framework/Resources/modules//R_X11.so'. It seems to be related to missing XQuartz. See the discussion here. Run X11 in Mac OS X with XQuartz.
    • Another case is when I try to use svg() to save an image. It shows "Unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so'".
    • Another case is edit() won't work with data frame.
    • You will need to log out and log back in to make XQuartz your default X11 server.
  • Stopwatch & Timer
  • Qt Creator
  • Chargeberry

Missing Linux commands

wget

Method 1: Rudix

curl -O https://raw.githubusercontent.com/rudix-mac/rpm/2016.12.13/rudix.py
python rudix.py install rudix
sudo rudix install wget
which wget
# /usr/local/bin/wget

$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
--2017-02-26 08:41:09--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
ERROR: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
To connect to raw.githubusercontent.com insecurely, use `--no-check-certificate'.
$ wget https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh --no-check-certificate
--2017-02-26 08:41:26--  https://raw.githubusercontent.com/arraytools/bdge/master/install_rnaseq.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.192.133, 151.101.128.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.192.133|:443... connected.
WARNING: cannot verify raw.githubusercontent.com's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 8502 (8.3K) [text/plain]
Saving to: ‘install_rnaseq.sh’

install_rnaseq.sh                        100%[===============================================================================>]   8.30K  --.-KB/s    in 0.001s  

2017-02-26 08:41:26 (15.7 MB/s) - ‘install_rnaseq.sh’ saved [8502/8502]

Method 2: homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install wget --with-libressl

Method 3: Build from source (require Xcode, works on my OS X 10.12 Sierra w/ Xcode 8.2.1)

xcode-select --install
cd ~/Downloads

curl -O https://www.openssl.org/source/openssl-1.0.2h.tar.gz
tar xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./configure darwin64-x86_64-cc 
make
sudo make install

curl -O http://ftp.gnu.org/gnu/wget/wget-1.18.tar.gz # version 1.19 won't work at the 'make' step
tar -zxvf wget-1.18.tar.gz
cd wget-1.15/
./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/ssl
make
sudo make install

For some reason, when I use wget to download files from https server, I will get a message: ERROR: cannot verify site certificate. Unable to locally verify the issuer’s authority. See

watch

http://stackoverflow.com/questions/9574089/osx-bash-watch-command

while :; do clear; your_command; sleep 2; done

top command

To sort by CPU

top -u

To sort by Memory

top -o mem

htop

http://unix.stackexchange.com/questions/98253/how-do-i-install-htop-inside-mac-os-x

It seems the result is not accurate. For example when the fan is working (esets_daemon is running), htop does not show much CPU from eset_daemon but Activity Monitor shows esets_daemon is on the top cpu usage list.

md5sum

It is called md5 instead of md5sum in Linux.

For SHA-1 and SHA-256 use

shasum filename
# OR
shasum -a 1 filename

shasum -a 256 filename

tar

If we run the following command

tar xzvf filename.tar.gz -C directory 2> error.log

we will get a non-empty file in <error.log> even the extraction is successful.

Therefore it is better to use the following way

tar xzvf filename.tar.gz -C directory
if [ $? -eq 0 ]; then
    echo OK
else
    echo FAIL
fi

Diff tools

  • Diff Tools on macOS
  • FileMerge - part of XCode from Apple. Too un-intuitive compared to WinMerge on Windows or Meld on Linux:(
  • DiffMerge. Still not intuitive.
  • Meld for OSX - BEST!
    • Invalid byte sequence in conversion input ??
  • git diff will give a colored output on your terminal
    • Still a command line based
    • The compared files do not need to be in the local git directory
    • Green means the 1st file has more contents
    • Red means the 2nd file has less contents
  • Beyond Compare (commercial)
  • Araxis Merge (commercial)
  • DeltaWalker (commercial)
  • Kaleidoscope (commercial)

zcat

macOS always adds .Z to the .gz filename. A more portable solution is to use gunzip -c such as gunzip -c XXX.gz.

See zcat on OS X is running in POSIX mode and will always append .Z to all filenames.

R

failed to load cairo DLL

I got an error when I use svg() command.

 svg("~/Downloads/3dPiePlot.svg")
Warning messages:
1: In svg("~/Downloads/3dPiePlot.svg") :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so
  Reason: image not found
2: In svg("~/Downloads/3dPiePlot.svg") : failed to load cairo DLL

http://r.789695.n4.nabble.com/Cairo-package-error-quot-unable-to-load-quot-td4694453.html

you don't have X11 installed and it no longer ships with OS X 10.9 - you need to get it from

http://xquartz.macosforge.org

At the end of installation, it will ask you to log out and log in again to make xquartz a default X11 server.

Tex/Latex

Download failure

BasictexErr.png

The error seems to be related to a new release (6/7/2017). The download link for basicTex is http://tug.org/cgi-bin/mactex-download/BasicTeX.pkg. It downloaded the file mactex-basictex-20161009.pkg. But the new release is mactex-basictex-20170607.pkg. The download works fine on 6/8/2017.

http://ctan.org/pkg/mactex-basic website is working fine but the downloaded file name is <BasicTex.pkg> so it is not clear about the release date.

tlmgr error

$ tlmgr update --self
tlmgr: The Tex Live versions supported by the repository
http://ctan.sharelatex.com/tex-archive/systems/texlive/tlnet
  (2016-2016)
do not include the version of the local installation
  (2017).

Install a new package through tlmgr

When I try to knitr an R markdown file in RStudio, an error was popped up complaining about missing 'framed.sty' file. The solution is to install the framed package on macOS or texlive-latex-extra package on Ubuntu/Debian.

sudo tlmgr update --self
sudo tlmgr install framed

Microsoft Outlook

Customize views

  • Sidebar (from the outside Menu bar): View > Sidebar
  • Organize (from the inside menu or blue Ribbon): Focused Inbox, Message Preview.

Import a calendar into Outlook

Add ics file to outlook 2011 (Mac) as new calendar. Drag and drop.

Temp folder

On my Outlook (365 subscription), it is /private/var/folders/2q/slryb0rx4tj97t66v7l6pwvr_z6g3s/T/com.microsoft.Outlook/Outlook\ Temp/. It is obtained by Open an attachment and then select & copy a file.

Encrypted emails

Unable to read encrypted emails.

Go to Preferences > Account > Advanced > Security.

  • Digital signing Certificate: XXXX-S
  • Encryption Certificate: XXX-E
  • Certificate authentication Authentication: XXX-S

Rebooting computer helps.

To check PIV card is inserted: open the 'Keychain Access' app.

Save an email

The file format is *.eml.

Apple Server

OS Server

Hackintosh

How to Triple Boot Your Hackintosh with Windows and Linux

http://lifehacker.com/5698205/how-to-triple-boot-your-hackintosh-with-windows-and-linux

How To Install macOS Sierra Hackintosh On PC

http://www.redmondpie.com/how-to-install-macos-sierra-hackintosh-on-pc-guide/

Building a GTX 1080 Ti-powered Hackintosh: Installing macOS Sierra step-by-step

https://9to5mac.com/2017/04/28/building-a-gtx-1080-ti-powered-hackintosh-installing-macos-sierra-step-by-step-video/

iOS

iPad Pro 10.5 vs iPad 9.7 (2017)

Screen shut off automatically

Settings -> Display & Brightness -> Auto-Lock. If you select 'Never', the screen will never turn it off by itself.

Share an internet/hotspot

How to Use Instant Hotspot on Your iPhone, iPad, or Mac

Firefox Focus

Feel quite fast on my iPad. The 'setting' (gear symbol) on the top right hand side cannot be seen unless we click 'Erase' first. On the setting, we can change the search engine, Send usage data, etc.

But the regular Firefox has an option called "Tracking Protection" which is doing the same thing.

File manager

https://www.makeuseof.com/tag/file-manager-apps-iphone-ipad/

Documents by Readdle is a file manager with an integrated web browser, which makes it easy to download and transfer YouTube videos. See How to Download and Save YouTube Videos on iPhone.

The Fastest File Transfer Methods Between PCs and Mobile Devices

https://www.makeuseof.com/tag/x-fastest-ways-transfer-file-pc-mobile-device/

Split screen

How to Split Screen on iPad (And the Best Tips and Tricks When Doing It)

MiniKeePass

Dropbox -> KeePass file -> "..." -> Export -> Open in -> Copy to MiniKeePass.

Voice recorder

https://www.makeuseof.com/tag/iphone-voice-recorder-apps/

Take a screenshot

  1. Press and hold the Sleep/Wake (on/off) button on the top of your iPad.
  2. Quickly click the Home button at the bottom of the screen.
  3. Release both buttons.

When you successfully trigger a screen shot, you'll see a white flash and, if audio is on, hear the camera shutter sound.

HDR photo

How to Shoot in HDR on Your iPhone

The best use cases for HDR photography are landscapes, objects in direct sunlight, and low-light or backlit scenes.

How to Take Better Fireworks Photos

https://lifehacker.com/how-to-take-better-fireworks-photos-with-your-iphone-1827324154

Procreate

https://www.makeuseof.com/tag/procreate-for-ipad-one-of-the-most-beautiful-and-powerful-art-apps-for-ios-available-today/

GoodNotes

http://www.goodnotes.com/

Replace desktop?

  • How to download pdf files?
  • How to search on pdf files?

AirDrop

Use AirDrop on your iPhone, iPad, or iPod touch

Shell/terminal

iSH - An iOS Linux Shell for Your iPhone or iPad

AirDroid: wifi transfer files

AirDroid works on iOS. It has frequent updates and gets good reviews. Another popular android app "Portal" does not get updates and does not have a good review on iOS.

Turn off passcode

https://appsliced.co/ask/how-do-i-disable-the-passcode-lock-on-my-ipad

Under Settings -> Touch ID &N Passcode

Turn off auto-lock

http://www.solveyourtech.com/disable-auto-lock-ipad-2/

Under Settings -> Display & Brightness

Reducing eye strain

https://www.makeuseof.com/tag/reduce-eye-strain-iphone/

iCloud

6 Nifty Uses for Spare iCloud Storage

Music

Novel Effect Make Story Magic

Chrome keyboard shortcuts

22 Chrome for iPad Keyboard Shortcuts