tbd: open http://localhost

Laptop Keyboard missing keys

Mac laptop		Win/Linux full size keyboard	
Fn UpArrow		PgUp
Fn DownArrow		PdDw
Fn LeftArrow		Home
Fn RightArrow		End
Fn backspace		Del     # works in vi  
^D			Del	# does NOT work in vi!

??			Ins	# No way to emulate an insert key on the laptop :( :( :( 

Keyboard shortcuts when running Mint

Mac			Win/Linux	Action
^ Fn+UpArrow 		^PgUp		previous tab in mate-terminal

Keyboard shortcuts

keyboard shortcuts from apple support
Some less intuitive keyboard binding from a windoze/linux user perspective:

Cmd/Command = Windows key = Apple key
Option      = Alt
Control     = ^


Windows Switching

Cmd-Tab				Switch apps: Switch to the next most recently used app among your open apps. 
Cmd-`     			Switch windows w/in app, within SAME WORKSPACE (works in Terminal and firefox)
Cmd-Sh ~ (Cmd-Tilde)		Switch windows: Switch to the next most recently used window of the front app. 
Cmd-alt-Lf/Rg 			cycle thru tabs in chrome.  
Cmd-    Lf/Rg 		        cycle thru windows in Terminal app, ACROSS workSpaces.  Chrome "BACK" and "FWD" on page (URL) navigation.

   ctrl-tab			cycle thru tabs    in Terminal app
sh-ctrl-tab

     Cmd-Sh-4	( cmd-$)	# cropping method.  save to .png in desktop (10.12.5?) 
Ctrl-Cmd-Sh-4	(^cmd-$)	# cropping method.  send to clipboard (no saving to file)
     Cmd-Sh-3			# screenshot of the entire screen, save to .png on desktop. 
Ctrl-Cmd-Sh-3	(^cmd-#)	# screenshot of the entire screen, send to clipboard (no saving to file)

Cmd-,				# Preferences: Open preferences for the front app.

^-Sh-Power/Eject		# blank screen (lock after additional preset num of min)
Fn   Power/Eject		# bring up lock/sleep/power off menu (closest thing to Windows-L)


Mac			Win/Linux,vi/bash?	Action
-----------------	--------- --------	-----------------------------------------------
Cmd-W			^W			close tab/window
		   ^F4
Cmd-Q			Alt-F4			quit app

Text Editing/Document Navigation

Mac			Win/Linux,vi/bash?	Action
-----------------	--------- --------	-----------------------------------------------
Alt-Lf/Rg               ^Lf/Rg 			Word left/right, even in Terminal

Alt-Del/Bksp		^Del/Bksp		Delete word			

Alt-Up/Dn		Hm/End    v,b		Begining/End of line
Cmd-Lf/Rg		Hm/End			Begining/End of line	[official apple publish]
^A/E			          ^A/E		Begining/End of line

Cmd-Up/Dn		^Hm/End			Top/End of doc
Hm/End 			^Hm/End			Top/End of doc

^Lf/Rg 						SPACES (workspace) Left/Right
3finger swipe Lf/Rg				SPACES (workspace) Left/Right
						(Gnome3 use vertical stacked workspace and use mouse wheel to nagivate.  

Editor keybind that will probably never use:
Control-L	Center the cursor or selection in the visible area.
Control-O	Insert a new line after the insertion point.
Control-T	Swap the character behind the insertion point with the character in front of the insertion point.
These looks similar to bash shell prompt binding:
But could just use arrow keys. Maybe more useful in vi mode?

Control-F	Move one character forward.              LEFT ARROW
Control-B	Move one character backward.
Control-P	Move up one line.                        UP ARROW
Control-N	Move down one line.
Terminal app keybindings
(probably add screenshots)

Cmd-Up/Dn			Terminal navigate thru command history
Google Sheets

mac		win		action
----------	-----		-----------------------------------------------
Ctrl+Alt+i	Alt+i		Insert menu  (eg R to add Row, C to add column)

Sloppy Mouse
From server fault, can get mouse follow focus for just the terminal app. only for Terminal app, not all app. But better than nothing!

Run this cmd in terminal, then restart:

defaults write com.apple.Terminal FocusFollowsMouse -boolean YES

Package managers for Mac OS/X


MacPort 	- formerly Darwin port
		  contain lot of "unix style" software packages.
		  install to /opt/local

fink		= package manager like Ubuntu apt-get, oft used by users from Debian world.
		  need to be installed separately, create resource tree independent of mac os x, more unixy...
		  more cutting edge that Mac OS Port.  May have pre-compiled binaries.
		  install to /sw

rudix		= pre-compiled unix sw for OS X (Yosemite in progress, Maverick and older okay)
		  hassle-free.  http://rudix.org/


homebrew	= http://brew.sh/
		  install to /usr/local, which is said why it works!  changing path not recommended!
		  have not been able to get it to install/work behind a proxy :( 
		  Said to depends more on mac os x native packages, more integrated, uses less space.
		  Intended audience = mac users.  
		  [still what I am using in 2023.10]
		  
		  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
		  brew install caskroom/cask/burn added a GUI Burn.app into Applications.
		  brew cask can manage and install mac native apps.  (used by geerlingguy Ansible for DevOps).


nix		= from NixOS, meant to be a declarative (stateless) package management.  
		  package are build from source, but cached to provide performance close to traditional binary-based package manager.


Comarison discussion in Stack Exchange :: Ask Different

Homebrew Install
  1. Homebrew is what I use in 2017, 2018
  2. brew install octave worked like a charm. plot() will launch GUI window, (cocoa native?), no need to start X server (at least not manually, don't remember if it was installed)
Fink Install
  1. Requirements: Java, Xcode
  2. Download installer and follow instructions from http://www.finkproject.org/download/srcdist.php
	sudo xcode-select --install
	sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
	sudo xcodebuild -license
	tar -xvf fink-0.41.1.tar.gz 
	cd fink-*
	./bootstrap 
	# long build process...
	
	You should now have a working Fink installation in '/sw'. You still need package descriptions if you want to compile packages yourself. You can get them
	by installing the dists-10.12-0.16.0.tar.gz tarball, or by running either of the commands: 'fink selfupdate-rsync', to update via rsync (generally
	preferred); or 'fink selfupdate-cvs', to update via CVS (more likely to work through a firewall). You should also run 'sudo xcodebuild -license' and
	accept the Xcode license, since some packages will require this.

	Run '. /sw/bin/init.sh' to set up this terminal session environment to use Fink. To make the software installed by Fink available in all of your future
	terminal shells, add '. /sw/bin/init.sh' to the init script '.profile' or '.bash_profile' in your home directory. The program /sw/bin/pathsetup.sh can
	help with this. Enjoy.

	(info from finkproject)
	
Obsolete method to install Fink
No longer works? cuz fink group no longer building .dmg?
installer -pkg Fink*pkg -target LocalSystem
	# similar to rpm -i sw.rpm 
  	# -target LocalSystem is the equiv of the GUI telling where to put the program.  Should be able to use / also.


pkgutil --pkgs 		# list packages installed on system (.pkg, not stuff that Fink install, which are .deb packages).
			# os x command?  but no longer avail in 10.12 ?

dmg are sw image that are "mounted", accessible from /Volumes.  
Firefox can run off inside such mount.  
Other apps req copying the files there to /Applications folder.  
Yet other require an install from there.

Fink Use

. /sw/bin/init.sh


fink selfupdate
 			# update fink db, support http_proxy env var if proxy need to be set.
fink list 		# list avail packages.  no samba or smbclient.  
			# don't see if it provides anything that homebrew don't
			# fink is prob no longer worth the trouble
fink install ...

apt-get
dpkg --list 		# list debian packages (installed by fink)

Firewall

With ~ 10.5, application-based firewall is the default firewall app (controlled by the GUI). It is a port of OpenBSD PF. It is good for laptop user who control access to app in allowing remote connection. But it is not so great for a server-oriented firewall that may want to limit access by IP address range. In such cases, the old IPFW (derived from FreeBSD) is available from the CLI. IPFW actually takes precedence over PF; neither of them are on by default.

Ref:
  • firewall from apple support 10.5+
  • guide on setting up ipfw

    cli in Mac OS/X

    
    smbutil  view  //samba-server			# ~ smbclient -N -L //samba-server
    
    
    
    # launchd is pid 1 for mac, so think of it as init/systemd of linux.
    
    launchctl list					# list services, think of systemctl list-unit-files
    launchctl stop com.nomachine.localnxserver	# like systemctl stop, should be a one time stop the nx service (but this one starts right back up)
    launchctl remove				# permanently remove service
    launchctl load					# said to load it back,  but  removed, 
    launchctl unload com.nomachine.localnxserver	# did not work
    
    # so, not sure what's the equiv of systemctl disable 
    
    sudo launchctl limit maxfiles unlimited		# fix number of open file handles to unlimited (def is very low)
    

    Python

    1. The python that comes with OS X is quite old :( Sierra 10.12.6 comes with Python 2.7 which does not have PIP :(
    2. easy_install pip . Script comes with os x in /usr/bin, will try this first
    3. (Trying to install Ansible)
    4. brew install python/pip is possible, but then install a second python on system, and different way of calling things may end up using diff python

    Getting new Mac to be useful

    Below are example commands to make os x more hacker friendly, use cli to install .dmg., etc Run
    wget -nc https://raw.githubusercontent.com/tin6150/psg/master/script/mac/installFavApp.sh -O installFavApp.sh
    # should check that downloaded the right thing before running it.  also, script use sudo.
    bash -x installFavApp.sh
    


    
    cd ~/Downloads
    # install Vagrant .dmg
    wget https://releases.hashicorp.com/vagrant/2.0.0/vagrant_2.0.0_x86_64.dmg
    sudo hdiutil attach vagrant_2.0.0_x86_64.dmg
    sudo installer -package /Volumes/Vagrant/vagrant.pkg -target /
    # in this case, the app was installed to /opt/vagrant with link in /usr/local
    sudo hdiutil detach /Volumes/Vagrant
    
    # install Oracle VirtualBox
    wget http://download.virtualbox.org/virtualbox/5.1.28/VirtualBox-5.1.28-117968-OSX.dmg
    sudo hdiutil attach VirtualBox-5.1.28-117968-OSX.dmg 
    sudo installer -package /Volumes/VirtualBox/VirtualBox.pkg -target /
    # installed to /Applications/VirtualBox.app
    sudo hdiutil detach /Volumes/VirtualBox/
    
    

    "BIOS" stuff

    
    while booting up:
    option	= select OS to boot with (when bootcamp is configured)
    apple+t = target firewire disk mode  (or just press T key?)
    apple+v = verbose mode (this time only)
    apple+s = single user mode (but don't run fsck from here! boot from DVD for such action!)  (or just s ?)
    
    apple+r = reinstall
    sh-alt-cmd-r = 
    cmd+r = reinstall current version of macOS (still wipe the whole disk?)
    
    alt = opt
    alt-cmd-r = reinstall + disk util tool (eg remove encrypted partition before reinstall)
    opt+cmd+r = install latest version of macOS that the system can handle
    sh+opt+cmd+r = install orig macOS of the machine + update
    
    shift   = Safe Boot mode - https://support.apple.com/en-us/HT201262
    
    
    
    command+r = recovery mode (same as a the recovery choice when "option" key boot).
    
    Permanently disable flashy non-useful boot screen (ie, verbose unix-like booting):
    go to terminal, run
    	sudo nvram boot-args="-v"
    To see current settings:
    	nvram -p   			
    
    
    System Integrity Protection
    csrutil status

    csrutil disable # this can only be run in Recovery Mode's terminal

    ref: https://developer.apple.com/library/content/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html

    Migration/Cloning

    May not be trivial to migrate data from an old mac to a new one...
    Backup and Prep
    1. Avoid upgrading OS when planning to migrate soonish down the road. (Direct machine restore tends to complain OS in destination host is older, not sure if build numbers are different or some bugs).
    2. Partition a new disk with GUID (Linux parted and mkfs.hfsplus didn't work). Use the mac disk utility.
    3. Install an OS on this external disk. Boot with Cmd-R, select external disk, install the OS on it.
    4. Run time machine backup to this disk (which is now bootable).
    Restore Using Migration Assistant
    NOT RECOMMENDED
    1. Start OS, login as normal.
    2. Run Migratin assistant (under App, Utilities). migrate data from time machine backup disk.
    3. The ugly part:
      • Migrate only document data matching the user that is logged in and started the Migration assistant.
      • if username doesn't match old computer, then nothing is transfered.
      • Even if username match, didn't copy much. May need apple id match.
      • But how to create such account? It is not like MS where you login directly using MS ID. *sigh* :(
      • It reboot the machine, can't do anything while it migrates
    Restore Using Migration Assistant
    1. Boot machine while holding Cmd-R
    2. Run Utility of Restore machine from time machine backup
    3. It will erase the destination computer hd.
    4. Did feel like it is a clone. Everything that was left in old computer now login and looks the same in new.
    5. One Notes and notebook open just fine. Hope it sync to web directly using a new sync id.
    6. git repos seems fine
    7. Did not migrate: Dropbox. Google drive
    8. Apple iCloud need to login, hanging.
    9. iTunes need new authorization as new computer
    Hostname
    How many places are hostname set in the mac?? !@#!$%
    sudo scutil --get Hostname 		# may not be set
    sudo scutil --set Hostname jr12pro	# affect cli "hostname"
    
    
    sudo scutil --set LocalHostName jr12.local		# bonjour hostname  (GUI Settings, Sharing, hostname)
    sudo scutil --set ComputerName "descriptive name" 	# optional
    
    dscacheutil -flushcache					# flush dns
    
    
    ref: https://knowledge.autodesk.com/support/smoke/learn-explore/caas/sfdcarticles/sfdcarticles/Setting-the-Mac-hostname-or-computer-name-from-the-terminal.html

    Older mac stuff

    
    key binding:
    
    cmd key is the apple key
    option = alt
    ctrl  = control (^)
    
    cmd+tab = similar to windoze alt+tab
    boot, option key = boot current os
    boot, c = boot from cd
    apple + control + power = reboot
    
    ---
    
    Enable unix mode boot:
    Older Macs:
    While booting, enter cmd+opt+O-F
    then,
    setenv boot-args=-v
    shut-down 
    This will cause machine to boot like sun machines.
    
    
    switching between XDarwin X session and Aqua:
    ctrl+opt+A
    (10.5, they can coexist together)
    
    ---
    
    
    NIS info from
    http://www.bresink.de/osx/nis.html
    
    OS X can act as NIS server.
    yp files are in /var/yp
    init rc file (?) at
    /System/Library/StartupItems/DirectoryServices/DirectoryServices 
    
    
    OS X NIS client.
    Some minimal info in lookupd.
    Leopard 10.5 has NIS client build-in.  Just need to specify NIS domain and servers.
    
    
    NFS mount.  Can specify the mounts in /etc/fstab, linux format.
    
    
    Troubleshooting boot up
    
    Info from Jim.  Appicable to old Mac (PowerPC) 
    
    If the critter won't start up with the C key held down, try the
    following (with the CD in the drive)
    Hold the Option key on startup, and choose the CD icon and then click
    the right-pointing arrow, or
    hold control-option-shift-delete on startup.
    
    The former is an Open Firmware method, and the latter is a shortcut to
    tell the MacOS Rom to boot form the next available system volume.
    
    If both of these methods fail, restart and hold down option-apple-p-r
    for four startup chimes, then try the above methods again. (this resets
    pram)
    
    
    

    Progies

    iTerm : a better terminal prog than the one that comes with OS X.
    

    References

  • http://www.osxfaq.com/Tutorials/LearningCenter/HowTo/Startup/index.ws sample startup script in location which is now deemed archaic:
    /System/Library/StartupItems - Apple's only /Library/StartupItems - User's customization
  • http://developer.apple.com/macosx/launchd.html launchd article from ADC
  • http://oreilly.com/pub/a/mac/2002/10/22/macforunix.html Mac tips for Unix geeks

    Serial

    screen /dev/tty.usbserial 9600
    	# ^a k 		: kill the connection (terminate screen and its use of /dev/tty...)
    	# ^a ^b    	: send break (for sun's go prompt)   (don't need ^B (upper case B))
    	# ^a b    	: send break (for sun's go prompt)   (after ^a, it is ^b OR just b, not a triplet of key seq to send the break)
    
    minicom -o -D /dev/tty.usbserial 
    
    minicom -o -D /dev/tty.usbserial -8 -b 9600 
    	# ESC-z  (hold esc while pressing z) is the default META-Z for help!)
    	# ESC-X  (ESC + upper X at same time) = exit
    	# -o = don't init modem, since can't access /dev/modem 
    	# no need to run as sudo
    	# brew install minicom
    
    serial speed to try:
    9600
    19200
    38400
    115200
    
    tip
    
    See also linux#minicom

    iOS

    iSH community supported port emulator to iOS, port of alpine linux, run as i686 on ipad. full terminal running on local machine, can run ping, vi, etc. pre-compiled app exist in app store. Very neat!

    Antigravity

    Linux

    Trying to install Mint 18.2 on a MacBook 12" mid-2017 (A1534) failed :(
    So much about getting rid of macos :-(
    2023.09 report of attempting install on Ubuntu on a old-ish macbook with usb-c power apparently touchpad is still very touchy feely, sleep is hit and mostly miss. :(

    windoze

    PS

    Why I hate Mac OS X ? Update from High Sierra (2017.11)
    These are cultural, but they have been imprinted into my brain.


    [Doc URL: http://tin6150.github.io/psg/apple.html]
    (cc) Tin Ho. See main page for copyright info.


    hoti1
    bofh1