Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

The terminal is your friend, who only speaks a foreign language.


Overview

This tutorial describes how to make use of Terminal to do stuff (make your life easier and less frustrating).

I want you to feel confident that you’ve mastered this skill. That’s why this takes a hands-on approach where you type in commands and we explain the responses and possible troubleshooting. This is a “deep dive” because all details are presented.

Like a good music DJ, I’ve carefully arranged the presentation of concepts into a sequence for easy learning, so you don’t have to spend as much time as me making sense of the flood of material around this subject.

Sentences that begin with PROTIP are a high point of this website to point out wisdom and advice from experience. NOTE point out observations that many miss. Search for them if you only want “TL;DR” (Too Long Didn’t Read) highlights.

Stuck? Contact me and I or one of my friends will help you.

Open Terminal from Finder Folder

It’s hard to get away from using a command-line terminal.

Since Yosemite, you can open a terminal to a folder listed within Finder by positioning mouse on it then tapping with two fingers on the touchpad.

  1. Click the Apple icon, System Preferences....
  2. Press K and select Keyboard.
  3. Click Shortcuts, Services.
  4. Scroll to the Files and Folders section.
  5. Check on New Terminal at Folder.
  6. Close the dialog by clicking the red dot at the upper left corner.

Three ways to relaunch the Finder:

  1. Hold the Option key and right-click the Finder icon in the Dock, then select Relaunch.

  2. Press Command with your right hand and Option-esc with your left hand and choose Force Quit from the Apple menu. Then select the Finder and click Relaunch.

  3. Log out and log back in to your user account.

System Preferences

  1. If you don't see the Apple icon at the top of the screen, move the cursor to the very top of the screen for a few seconds.
  2. Click on the Apple icon at the upper left corner.
  3. Select System Preferences.
  4. Click Displays.
  5. Set Resolution to Scaled
  6. Test Page reports the screen and resolution along with browser version.
  7. The Mac Pro 15 inch retina display is preconfigured to a screen resolution of 1440 wide x 900 high, but a browser window of 1440 x 738.
  8. Click one of the 5 resolutions between Larger Text and More Space.

Microphone

To disable the internal microphone, there is no icon. So reduce the input volume to 0:

  1. Click on the Apple logo at the upper left corner.
  2. Select System Preferences.
  3. Type S and click on Sound.
  4. Click on the Input tab.
  5. Drag the Input volume slider all the way to the left.
  6. Close System Preferences.

This works by changing the audio input to the line-in, also known as the audio input port on your Mac. As long as you don’t actually have any audio input device connected, such as an external microphone or some other line-in device, this method should work.

Sound Control

Until Apple realizes how annoying it is to have that start-up sound on a Mac, create in the /Library/Scripts folder shell scripts containing osacript (Applescripta>) commands to mute sound automatically before reboot, and un-mute after reboot.

  1. Open a terminal and type in nano. Press Enter.

    Type this in the nano editor that pops up this shell script (starting with the she-bang #! characters):

    #!/bin/bash
    osascript -e 'set volume with output muted'
    
  2. Press Ctrl+O, then when it asks you for the filename type in

    ~/Documents/mute.sh

  3. Hit Enter to save the file. This puts the mute script in your Documents folder (don’t worry, we’re going to move it later).

  4. Create the unmute.sh script:

    #!/bin/bash
    osascript -e 'set volume without output muted'
    

    (In older versions the unmute script instead has

    set volume with output unmuted.

  5. Press Ctrl+X, press Y to agree, then type in

    ~/Documents/unmute.sh for the file name.

  6. Hit Return to save the new file, and nano should quit.

  7. To make the scripts executable, run the following commands in the Terminal, hitting Enter after each one

    sudo chmod u+x ~/Documents/mute.sh
    sudo chmod u+x ~/Documents/unmute.sh
    sudo mv ~/Documents/mute.sh /Library/Scripts/
    sudo mv ~/Documents/unmute.sh /Library/Scripts/
    
  8. Set the scripts to run automatically:

    sudo defaults write com.apple.loginwindow LogoutHook /Library/Scripts/mute.sh
    sudo defaults write com.apple.loginwindow LoginHook /Library/Scripts/unmute.sh
    
  9. Close the Terminal, save data in all other apps, and reboot your machine.

  10. To undo the above actions, set defaults in a Terminal window:

    sudo defaults delete com.apple.loginwindow LogoutHook
    sudo defaults delete com.apple.loginwindow LoginHook
    

For more about Applescript commands and hooks, see this.

Desktop Wallpaper Pictures

Get to the Desktop by spreading thumb and 4 fingers on the touchpad.

Choose a different picture from Preferences

desktops/screensaver select your desktop (highlight) press Command and C at he same time. BTW, notice where your picture/photo folders.

Want to add the Windows 10 wallpaper to your desktop?

Get to folder where system wallpapers are held from the Finder > Go |> Go to Folder > /Library/Desktop Pictures.

Sort by File Size.

Some wallpaper images that come with OS X are of Retina resolution: 5120x2880.

Hosts file

Mac, Windows, and Linux systems have a hosts file that locally does the work of the public DNS – translating host names (typed on browser address field) to IP address numbers.

  1. Edit the hosts file on a Mac:

    
    atom /etc/hosts
    

    The default contents:

    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost
    

    fe80::1 is like 127.0.0.1 for IPV4, but actually IP address 169.254.. in IPV4, an address not often used.

    fe80:: is a block of IPV6 addresses reserved for link-local addresses used for packets sent only to directly connected devices (not routed). The network discovery protocol (NDP), which replaces ARP and DHCP in IPv4, is the biggest user of link-local addresses (NDP sorta .

    Each IPV6 interface has a different link-local address starting with fe80:: and (typically) ending with a modified version the interface’s MAC address (EUI-64 format) to ensure a unique address on a segment.

    Programs such as OpenVPN add to the bottom of the file:

    # BEGIN section for OpenVPN Client SSL sites
    127.94.0.1  client.openvpn.net
    # END section for OpenVPN Client SSL sites
    
  2. Flush the cache:

    dscacheutil -flushcache

DNS Configuration with NameBench

Analysis at one time showed this ranking by speed:

  1. UltraDNS at 156.154.70.1
  2. Google at 8.8.4.4, 8.8.8.8
  3. OpenDNS at 208.67.222.222, 208.67.220.220, 208.67.222.220

Google Namebench tries the speed of various DNS servers from YOUR machine (which takes some time) and pops up in your browser this:

  1. If you don't see the Apple icon at the top of the screen, move the cursor to the very top of the screen for a few seconds.
  2. Click on the Apple icon at the upper left corner.
  3. Select System Preferences.
  4. Click Network.
  5. Click Advanced.
  6. Click DNS.
  7. Click [+], copy, and paste

An example:

  1. 205.171.3.65
  2. 216.146.35.35
  3. 192.168.0.1

Flush the DNS cache since OSX 10.9 :

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Previously, OSX 10.7 and 10.8, only the killall was needed.

Previous to that, OSX 10.5 and 10.6, only the decacheutil was needed, without the sudo.

BTW, the equivalent for Ubuntu is sudo service network-manager restart while other Linux flavors uses sudo /etc/init.d/nscd restart. Windows uses ipconfig /flushdns.

Cursor to Screen Hot Corners

By default, if you move the mouse to one of the corners of the screen, stuff happens. It can be annoying.

  1. Click the Apple menu at the upper left corner.
  2. Select System Preferences.
  3. Select Desktop & Screen Saver.
  4. Click Hot Corners at the lower-right corner.

ADVICE: I disabled each by selecting the dash (last choice) because they show up when I don’t want them.

Terminal Ping Host

Find the IP address of a website host name:

host microsoft.com
microsoft.com has address 134.170.185.46
microsoft.com has address 134.170.188.221
microsoft.com mail is handled by 10 microsoft-com.mail.protection.outlook.com.

Terminal File Listing Home Folder

By default, the terminal shows the hard drive and lowest level file folder name, in white letters over black.

To show the present (current) working directory (folder):

pwd

The response for me is:

/Users/wilsonmar

You will of course have a different machine user name than wilsonmar.

To get back to this home folder:

cd ~/

To list all file names (without any metadata):

ls

Folders available by default include Documents, Downloads, Pictures, Desktop, Music, Movies.

To dive into a folder type:

cd mu

Press Enter.

Nothing happens because upper case letters are important. Press delete to remove the mu and type:

cd Mu

Press Enter for the Music folder.

Go back up a level:

cd ..

To list all files with their permission settings:

ls -ls

Notice that no hidden files are listed. To list all hidden files with permission settings, piping the listing to more instead of having results flying by:

ls -la ~/ | more

A colon appears at the bottom if there is more to show.

To cancel the listing, press control + C.

Notice the .bashrc on the first page, something like:

-rw-r–r– 1 discworld discworld 3330 Mar 10 16:03 .bashrc

(It’s for the Bash Shell.)

If it’s not listed, create it with:

vi ~/.bashrc

To make it rw r r:

chmod 644 .bashrc

List only hidden files in the current folder:

ls -ld .??*

Create a Projects folder to hold projects downloaded from Github:

mkdir Projects

This only needs to be done once.

Show Hidden Invisible Files in Finder

By default, the Mac’s Finder does not show hidden files.

  1. Close all Finder folders.

  2. Enter this in Terminal before typing Return:

    defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder

    This causes all Finder windows to be reset.

    To make invisible files invisible again:

    defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder

    A description of each keyword:

    defaults - OSX’s command to change defaults, apple’s low-level preference system.

    write - tells defaults you want to change a preference, or write it

    com.apple.finder - defaults that the application’s preferences you want to change is Finder, specified by the application’s bundle identifier.

    AppleShowAllFiles - specifies which preference you want to change within the application.

    TRUE or FALSE - the value you want to set the preference to. In this case, it is a boolean, so the values must be TRUE or FALSE. I think you might be able to use YES or NO, but I’m not sure.

    && - a terminal operator to run whatever’s after this if the previous command is successful.

    killall - kills processes or closes applications.

    Finder - specifies the process or application to close.

Create Terminal Aliases

Most developers leave files un-hidden. But if you want to just type showFiles and hideFiles to show and hide Mac OS X’s hidden files, consider this article to create such terminal aliases.

An example is an alias for the tree command by adding this in the ~/.bash_profile script:

   alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
   

Alternately:

Brew install tree

OSX does not come with the tree command that many other Linux distributions provide. So add it using brew:

brew install tree

Active Terminal sessions need to be closed so new Terminal Shell New Window Shell has this activated.

See list of parameters:

tree --help

List only 2 levels deep with human-readable file size kilobytes and sort by last modified date:

tree -L 2 -s -h -p -D -t

Bash Profile Configuration

The profile file is run during boot-up to configure the terminal to define file path, shims, and autocompletion handlers.

This is the single biggest frustration with people using Linux on Mac.

One of the earliest articles on bash at http://www.macdevcenter.com/pub/a/mac/2004/02/24/bash.html shows shell variables, environment variables, and aliases.

Each operating system has its own file name for its profile:

  • With Ubuntu: Modify ~/.profile instead of ~/.bash_profile.
  • With Zsh: Modify ~/.zshrc file instead of ~/.bash_profile.
  • With Fish: Modify `~/.conf/fish/config.sh` to append.

If there is both a .bash_profile and a .profile file, boot-up only executes the first one it finds.

On my Yosemite Mac, open a terminal and:


cd ~

View the file using the vi editor that comes with OSX:


vi .bash_profile

According to the bash man page, .bash_profile is executed during login before the command prompt, while .bashrc is executed for interactive non-login shells such as when you start a new bash instance by typing /bin/bash in a terminal.

Here’s what my profile file begins:

echo ".profile"
export NVM_DIR="/Users/wilsonmar/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
export PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Exit vi by typing :q

Some installers request that adding a $PATH using a command such as:

echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile

To execute profile with the changes:


source  ~/.bash_profile

Alternately, to install GHC copy and paste into ~/.bash_profile:

# Add GHC 7.8.4 to the PATH, via http://ghcformacosx.github.io/
export GHC_DOT_APP="/Users/wilsonmar/Applications/ghc-7.8.4.app"
if [ -d "$GHC_DOT_APP" ]; then
export PATH="${HOME}/.cabal/bin:${GHC_DOT_APP}/Contents/bin:${PATH}"
fi

https://github.com/gcuisinier/jenv/blob/master/README.md

Terminal Usage

This page contains notes for system administrators and developers, who need to control Macs below the UI level, which require typing commands into a command-line terminal screen.

To list open files (process id’s and ports, actually):

sudo lsof -i -P

To avoid text wrapping, pull the right edge to expand the screen width.

The right-most column heading "Name" shows the port (either TCP or UDP).

To filter a particular port number:

sudo lsof -i -P | grep 8080

The second column, PID, lists the process identifier. Copy a number for use in the kill command:

sudo kill 289

Operating System Kernel

I can use Linux commands in my version of the operating system:

uname -a (a for all) or uname -rvm

returns:

14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

which is a combination of:

uname -r for release number,
uname -v for kernel version,
uname -m for model:

x86_64 for Intel or AMD 64-bit or
i*86 for 32-bit.

For more information about Darwin operating system developed at Apple, see:

  • http://www.wikiwand.com/en/XNU and
  • https://www.wikiwand.com/en/Comparison_of_operating_system_kernels

NOTE: lsb_release -a which works on Debian, RHEL 6.6, and Ubuntu is not recognized on Gentoo nor CentOS 6, which has no folder /etc/lsb-release.

Distriwatch.com describes releases.

Setup Your Mac Like a Pro

Paul Irish is one of top pros among developers, and now a Google Evangelist. He put his Mac configuration settings on github.com/paulirish/dotfiles. But he recommends cloning github.com/mathiasbynens/dotfiles/.

On the Git page notice that he has established an industry convention of using Projects folder we defined earlier.

On the Git page I clicked on Clone in Desktop.

The library is called dotfiles because that’s what hidden files are called, and most configuration files are hidden.

Edit terminal prompt setting

Paul Irish offers his setup-a-new-machine.sh at https://github.com/paulirish/dotfiles ZShell (included with Mac and can be set as the default in Terminal) * oh-my-zsh as a ZShell framework * The oh-my-zsh Git plugin * And the oh-my-zsh theme called jnrowe </p>

By default, if you have a long file name, it would leave little room to type in commands before it wraps to the next line.

To redefine what appears in the prompt, edit this file using the vi editor that comes with each Mac: vi .bashrc Copy this and paste to the bottom of the .bashrc file:

txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White

bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White

unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White

bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
badgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White

txtrst='\e[0m'    # Text Reset

print_before_the_prompt () {
printf "\n $txtred%s: $bldgrn%s \n$txtrst" "$USER" "$PWD"
} 
PROMPT_COMMAND=print_before_the_prompt
PS1='->'

The command above uses global parameters $USER and $PWD, plus colors from this list.

Exit from the Terminal shell: exit

Environment Variables

Like on PCs, the PATH environment variable stores where the operating system should look to find a particular program to execute.

A big reason to use a command-line terminal is to set environment variables.

To see what is already defined:

export

http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x talks about setting launchd.conf and rebooting. This applies to all users.

To see what was already defined:

echo $PATH

$PATH must be upper case.

The response I’m getting is:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Root user for sudo commands

The root user has the ability to relocate or remove required system files and to introduce new files in locations that are protected from other users.

Any user with an administrator account can become the root user or reset the root password. A root user has the ability to access other users’ files.

Under a Unix system like Mac OS X you must have “root” (administrative) privileges to start IP-services using ports smaller than 1024.

After Mac install, the root or superuser account is not enabled. While it is possible to enable the root account, once enabled, if forgetten, you’ll have to reboot from the installer drive (a hassle).

It is safer and easier to use the sudo command to gain temporary root access to the system.

DOTHIS: In a Terminal window invoke:

sudo -s After I type in my password, the response for me is the version of bash:

bash-3.2#

to demote out of root:

exit

DO THIS: The folders that bash looks into are:

/bin/echo $PATH

On a fresh Yosemite, its:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Each additional app adds to the front of the list:

/Library/Frameworks/Python.framework/Versions/3.4/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Separating the folders between colon separator:

  • /Library/Frameworks/Python.framework/Versions/3.4/bin
  • /opt/local/bin
  • /opt/local/sbin
  • /Applications/MAMP/bin/php5/bin
  • /Applications/MAMP/Library/bin
  • /Applications/Adobe AIR SDK/bin
  • /usr/local/bin
  • /usr/bin
  • /bin
  • /usr/sbin
  • /sbin

New folders are added to the front of the PATH using a command such as:

export PATH=&LT;new folders>:$PATH

Depending on how you’re setup, file ~/.profile or ~/.bash_profile or ~/.bash_login contains the path echo’d.

Or your PATH may be set in /etc/profile for all users

Clear the terminal history:

clear

Spotlight on Network Utility to List Ports

Apple’s Spotlight is like Window’s Search omni-box. Press Command+Spacebar.

Type the name of utilities that are buried, such as Network Utility.

Click the keyboard return/enter key to launch the Network Utility app.

Select the "Port Scan" tab.

Enter the IP (such as 127.0.0.1), localhost, or domain name you wish to scan for open ports.

Choose scan to see what ports the server responds to.

Create Windows-like shortcuts with parameters using text editor

http://www.jesseweb.com/coding/automator/create-windows-like-shortcuts-with-parameters/

Mac OSX doesn’t allow you to create shortcuts like Windows. OSX alias don’t allow parameters (ex. create a Screen Sharing shortcut that connects to a specific computer).

Jessie suggests this to create a Windows like shortcut with parameters in the Comments field.

Another alternative is to use a text editor to create URL shortcut files like the ones Windows Internet Explorer stores its bookmarks. Apple Safari recognizes them when clicked within Finder. So they are cross-platform.

  1. Copy the URL to the clipboard by pressing Command+C.
  2. From within a text editor, open a new text file.
  3. Type at the top of the file: [InternetShortcut]
    URL=
  4. Paste from clipboard by pressing Command+V
  5. Press enter/return to add a blank line under the URL line.
  6. Save the file with a .url file extension.
  7. From within Finder, click on the file to see it display by Safari.

Mount .dmg files using hdiutil tool

.dmg (Disk Image) files can be mounted from the command line:

hdiutil attach /path/to/diskimage.dmg

The response is like:

/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_HFS /Volumes/Mounted Disk Image

Note the disk from the message above to unmount (detatch):

hdiutil detach /dev/disk1s2

The same utility can mount .iso images:

hdiutil mount sample.iso

Clear DNS Cache Cache

Different commands are needed for different versions of OS. OSX 10.10 added requirement for sudo when using the built-in discoveryutil:

sudo discoveryutil udnsflushcaches

OSX 10.9

dscacheutil -flushcache;
sudo killall -HUP mDNSResponder

OSX 10.7 to 10.8

sudo killall -HUP mDNSResponder

OSX 10.5 to 10.6

sudo dscacheutil -flushcache

Windows by contrast:

ipconfig /flushdns

Linux (depending on the flavor running)

/etc/init.d/named restart
/etc/init.d/nscd restart

Hard Drives on Mac

DOTHIS: Open a Terminal window to invoke:

diskutil list

This lists physical and virtual disks.

"0:" and other such numbers are partitions.

DOTHIS: In a Terminal window invoke:

diskutil info /dev/disk0

The “Device / Media Name” is the partition label from the disk’s partition map (GPT - GUID Partition Table). disk0 Device Media Name: such as "APPLE SSD SM768E Media" is the make and model of your drive.

Device / Media Names are set when a partition is created on a disk. The only way you could rename the “startup partition” would be to startup from another drive. The initial name is set by Apple. (which Apple does not expected people to change and does not reference them at the CLI or GUI level).

AOTW, Apple sells SD drives up to 750.4 GB.

Notice that disk1 is a Logical Volume on disk0s2 with a GUID referencing disk0.

DOTHIS: In a Terminal window invoke:

diskutil info /dev/disk0s2

disk0s1: “EFI system partition”

contains extended firmware for your drive.

DOTHIS: In a Terminal window invoke:

diskutil info /dev/disk0s1

disk0s1: “EFI system partition”
contains extended firmware for your drive.

disk0s2: “Customer” to diskutil is where your files are stored.

DOTHIS: In a Terminal window invoke:

diskutil info /dev/disk1

appears on the Desktop as "Macintosh HD" system partition, which can be changed by pressing Return key after clicking on it.

disk0s3: “Recovery HD” is a clean install of the OS to make restoring your computer easier.

If you add your own custom partition to the mix you will find that Apple’s tools (i.e. Disk Utility) will match the visible name and the device name.

DOTHIS: Plug in a Time Machine drive. In a Terminal window invoke:


   diskutil info /dev/disk2
   

In the list it would have 3 partitions:

0: Apple_partition_scheme

1: Windows_FAT_32

2: Apple_HFS

DOTHIS: Plug in a SD card. In a Terminal window invoke:


   diskutil list
   

In the list it would have 2 partitions:

0: FDISK_partition_scheme

1: Windows_NTFS

In a Terminal window invoke:

diskutil info /dev/disk3

DOTHIS: Plug in an external drive. In a Terminal window invoke:

diskutil list

In the list it would have 2 partitions:

0: FDisk_partition_scheme

1: Windows_NTFS Seagate Backup Plus …

DOTHIS: In a Terminal window invoke:

diskutil info /dev/disk5

"Seagate BUP Slim SL Media"

According to http://osxdaily.com/2014/03/20/mount-ext-linux-file-system-mac/”> http://sourceforge.net/projects/osxfuse/files/osxfuse-2.7.5/osxfuse-2.7.5.dmg/download”> OSX Fuse</p> extend OS X’s native file handling capabilities via third-party file systems such as ext4.

fstab – static information about filesystems.

Hard Drive Partition Tables

DOTHIS: To show partition tables for a particular disk: In a Terminal window invoke:

sudo get show /dev/disk0

Eject the disk from the Finder (or use the unmount terminal command if you’d like). If you don’t do this, you may get a Resource busy error message during the following step.

CAUTION: Change the partition label as desired:


   sudo gpt label -i 2 -l "My New Partition Label" /dev/rdisk0
   

(replace disk0 with the relevant disk number and replace 2 with the index number.

Disk Space Usage

One of the folks at Sketch (the Mac photo-editing tool) noticed that Daisy Disk didn’t map all the disk space usage.

To reveal disk usage by a file that Apple Lion uses to store copies of files to revert to any version:


   sudo du -sh /.DocumentRevisions-V100
   

Resetting to zero would involve re-installs.

If you use an alternative backup such as Dropbox, you can turn it off for a particular program:


   defaults write -app ‘sketch’ ApplePersistence -bool no
   

Folders accessed by developers

DOTHIS: In Finder, select from the left panel the first item under the Devices list.

Click on Macintosh HD.

  • Applications hold apps installed.
  • Incompatible Software hold apps which cannot be installed, such as Amazon Kindle, which competes with Apple's iBooks. This occured during upgrade to Yosemite.
  • Library/Library holds Apple internal apps.
  • System hold apps installed.
  • Users hold data for each user defined, as well as a Shared folder accessible by all users.

DOTHIS: Click on your username (wilsonmar in my case). This action is the same as clicking on the last default item under the Favorites list.

Many WordPress developers prefer to add a folder named Sites which holds the wordpress folder expanded from download.

IPv6 compatibility with Curl command line apps

curl http://localhost:3000

When invoked on Mac OS 10.10 (Yosemite), you need to add a parameter to make the request using IPv4:

curl http://localhost:3000 –ipv4

Otherwise, you will see an error message such as:

curl: (7) Failed to connect to localhost port 3000: Connection refused

even if the URL loads fine in a browser.

This occurs because curl, being under Yosemite, uses IPv6 by default but some apps, such as LoopBack.io, by default uses IP v4.

See if you see IP v6 entries in your hosts file (::1 localhost, fe80::1%lo0 localhost). If they are there it is likely that curl is making requests using IP v6.

You can make your LoopBack app use IPv6 by specifying an IPv6 address as shown below:

app.start = function() {
// start the web server
return app.listen(3000, '::1',function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
});
};

VMWare Fusion

To create a Windows 10 instance within VMWare Fusion:

  1. Download the ISO file from:

    https://www.microsoft.com/en-us/software-download/windows10ISO

  2. Within VMWare Fusion, select File New.
  3. Drag the ISO file and drop on the dialog.
  4. Supply the license key.

Disable System Integrity Protection

Some programs make calls to the operating system which OSX began to see as a threat, beginning with El Capitan.

Apple says System Integrity Protection blocks code injection (and many other things).

But what about useful programs (such as XtraFinder) which works by injecting its code into Finder and other application processes?

  • For example, OpenVPN issues a JSONDialog Error “DynamicClientBase: JSONDialog: Error running jsondialog”.

To get around this, you need to partially disable System Integrity Protection in OS X El Capitan.

See Apple’s article on how:

  1. Run a full backup to an external USB drive.
  2. Shut down all apps, then the operating system (from the Apple icon).
  3. Reboot the Mac.

    This is needed because System Integrity Protection settings are stored in NVRAM on each individual Mac. So it can only be modified from the recovery environment running in NVRAM.

  4. Boot OS X into Recovery Mode: hold down the command + R keys simultaneously after you hear the startup chime.
  5. When the OS X Utilities screen appears, pull down the Utilities menu at the top of the screen.

  6. Choose Terminal.
  7. Type the following command into the terminal before hitting the return key.

    csrutil disable; reboot
    
  8. For XtraFinder:

    csrutil enable \-\-without debug
    
  9. To revert SIP to original state:

    csrutil clear
    

Skill Certification

Video course Mac OS X Support: Installation and Configure is the first of courses on Plurasight toward Apple Certified Support Professional (ACSP)

Dotfile Settings from others

  • https://github.com/afranken/dotfiles
  • https://github.com/mathiasbynens/dotfiles

Daemons and Agents

  • https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html

Resources:

  • https://www.hamsterpad.com/chat/typescriptpdx Typescript Slack group

More on OSX

This is one of a series on Mac OSX: