Mac: Difference between revisions
Line 637: | Line 637: | ||
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. | 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 = | = 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 Mac, go to system preferences -> System Preferences -> Sharing -> '''Screen Sharing'''. It will show the vnc address of the Mac computer. | ||
Line 647: | Line 647: | ||
** The connection speed is not ideal. You can see the screen refresh slowly. | ** 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:( | * 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.' | |||
[[File:Failscreensharing.png|250px]] | |||
= Tips = | = Tips = |
Revision as of 09:12, 21 April 2017
macOS
https://en.wikipedia.org/wiki/MacOS
Darwin (operating system) and release history
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.
OS X File System
- https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
- Mac OS X Directory Structure explained
- Directory structure between mac osx and linux
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
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
/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
macOS Sierra: Share files with others who use your Mac
- Mac OS doesn't support writing to NTFS drives.
- NTFS and REFS are a bad choice because Linux and Mac can't properly decode it
- exFAT doesn't support symlinks
- 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 diskutil partitionDisk disk2 GPT ExFat "toshiba" 0g
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/
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"
Root account vs admin account
- https://discussions.apple.com/thread/3128749?start=0&tstart=0
- The Option "Allow User to Administer this Computer" option is Dimmed
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
http://www.online-tech-tips.com/mac-os-x/install-boot-and-run-mac-os-x-from-an-external-hard-drive/
Terminal
Where is the terminal
Macintosh HD/Applications/Utilities/Terminal.
Keyboard shortcuts
- Ctrl + a - going to the beginning of the line
- Ctrl + e - 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
More
- The Best “Just For Fun” Tricks Hidden in macOS’ Terminal:
- Make Your Mac Say Anything Out Loud,
- Play Simple Games Like Tetris, Pong, and Snake,
- caffeinate will prevent your Mac from falling asleep.
Keyboard shortcuts
How Not Using Keyboard Shortcuts Makes You Lose 64 Hours Every Year
Lock screen
Shift + control + power
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.
- 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
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
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
Hardware
2015 Macbook Pro model A1398, 15.4 inch.
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/.
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. By default it is click with two fingers. We can change the setting by going to System Preferences/Touchpad/Secondary click.
- 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:
- highlight the app first
- 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.
CPU information
sysctl -n machdep.cpu.brand_string
My macbook Pro 2015 shows i7-4980HQ CPU @ 2.80GHz.
Power Adapter
85W MagSafe 2 Power Adapter for MacBook Pro with Retina Display (MD506LL/A) $75
Finder - file manager
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.
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.
Screenshots
http://www.howtogeek.com/278615/the-best-screenshot-apps-for-macos/
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
Grab
Take a Timed Screenshot With the Grab (built-in) Application. Open Grab, select Capture -> Selection/Window/Screen/Timed screen.
Lightshot
An easy-to-use app Lightshot which sits on the taskbar.
Note: to view an image resolution in Finder, right click an image and select Get Info -> More Info.
Screen cast
Quicktime player
We can record the screen (full screen or a selected region). The recorded file will be in a .mov format.
Screen cast o magic
http://screencast-o-matic.com/
Application
How to Install Applications
- http://www.howtogeek.com/177619/how-to-install-applications-on-a-mac-everything-you-need-to-know/
- Installing a .dmg and .pkg application from the command line
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/
Launch an application
- F4 key - LaunchPad
- Command + Space - Spotlight search
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.
Package formats
app directory
Example: App Store.app, SourceTree, http://doc.qt.io/qt-4.8/deployment-mac.html Qt application].
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 need to zip it. 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.
pkg file
Example: R-cran
- Extract PKG files on Mac and Windows
- How to Open .pkg Files to View What Will Install on Mac with Suspicious Package
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 /
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).
Homebrew
# Install /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install some package brew install wget # Uninstall homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
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
Text editor
http://beebom.com/best-text-editors-for-mac/
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"
If you use the open command in a terminal to open a text file, the default program will be used.
Atom editor from Github
- 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.
- Command Palette: Press Cmd+Shift+P.
- You can search by any keyword to find the keyboard shortcut.
- You can use it to install the terminal commands atom and apm if they were not installed during installing Atom.
- Settings: Atom -> Preferences.
- Open a file: Cmd+o. Save a file: Cmd+s.
- 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
Sublime
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??
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: it seems there is no way to run this automatically without the alert box. Users need to agree the license.
xcode-select --install
The installed tools 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
$ 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/
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
- http://apple.stackexchange.com/questions/221587/how-to-make-a-clean-install-of-openssl-on-el-capitan
- http://mac-dev-env.patrickbougie.com/openssl/
Python packages
http://www.scipy.org/install.html
VirtualBox
Touchpad
The direction of scrolling up and down in guest machine is opposite to the host machine.
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]
El Capitan (10.11)
- http://www.wikigain.com/install-mac-os-x-el-capitan-virtualbox/
- http://www.wikigain.com/complete-guide-fix-virtualbox-errors-installing-mac-os-x/
It works on my VirtualBox 5.1.14 and Macbook Pro 2015.
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)
Note the official image (e.g. Install macOS Sierra.app) we downloaded from Apple Store is saved under /Applications folder.
https://github.com/geerlingguy/macos-virtualbox-vm
- video memory change from 16GB to 128MB
- increase memory to 4096MB
- turn off audio
VBoxManage modifyvm "{vmname}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
After booting, select the preferred language and go to Utilities > Disk Utility. Select the VirtualBox disk and choose Erase to format it as a Mac OS Extended (Journaled) drive.
Unfortunately, the Mac guest machine cannot install guest additions.
I get a 'Guru meditation' error when I test the iso on a non-mac machine (intel core 2 duo CPU).
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/
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
- http://apple.stackexchange.com/questions/237038/os-x-terminal-command-to-turn-on-off-ssh-server
- http://osxdaily.com/2016/08/16/enable-ssh-mac-command-line/
- http://superuser.com/questions/416096/enabling-ssh-daemon-from-terminal-os-x-lion
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.'
Tips
Got a New Mac? Do This First!
http://www.makeuseof.com/tag/new-mac-setup/
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 Configure a Proxy Server
https://www.howtogeek.com/293444/how-to-configure-a-proxy-server-on-a-mac/
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
- http://thenubbyadmin.com/2014/01/29/solving-wget-error-cannot-verify-site-certificate-unable-to-locally-verify-the-issuers-authority/
- https://finkers.wordpress.com/2009/10/06/wget-and-https/ (fink solution)
- http://stackoverflow.com/questions/9224298/how-do-i-fix-certificate-errors-when-running-wget-on-an-https-url-in-cygwin (cygwin solution)
- http://stackoverflow.com/questions/30105376/error-cannot-verify-www-youtube-coms-certificate-with-wget-http-www-yout (brew has the same problem)
watch
http://stackoverflow.com/questions/9574089/osx-bash-watch-command
while :; do clear; your_command; sleep 2; done
htop
http://unix.stackexchange.com/questions/98253/how-do-i-install-htop-inside-mac-os-x
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
Git client
sourcetree. See also Happy Git and Gihub for the useR from Jenny Bryan.
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!
- Beyond Compare (commercial)
- Araxis Merge (commercial)
- DeltaWalker (commercial)
- Kaleidoscope (commercial)
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
At the end of installation, it will ask you to log out and log in again to make xquartz a default X11 server.
Apple Server
- Mac Pro server (up to 64 GB DDR3 memory)
- Why Apple Will Never Offer Another Server Again