lsof

Which programs are using a specific tcp/udp port?

lsof -i :portNumber 
lsof -i tcp:portNumber 
lsof -i udp:portNumber 
lsof -i :80
lsof -i :80 | grep LISTEN

git: Specify which ssh key to use

You can ask git to use a specific ssh key:

git config core.sshCommand "ssh -i /path/to/key"

Mac: Delete old local snapshots

Show the commands to delete old snapshots:

sudo tmutil listlocalsnapshots / | sed 's/.*TimeMachine./sudo tmutil deletelocalsnapshots /g;s/.local$//g'

Use TouchID instead of password to authenticate for sudo

Add this line at the top of /etc/pam.d/sudo:

auth       sufficient     pam_tid.so

For more information, see here.

Moving to a new mac

Things to remember next time:

Applications/Macports: Save a list of applications and requested Macports

ls /Applications > applications.txt
sudo port -qv installed | cut -d ' '  -f 3 | sort -u > myports.txt
sudo port echo requested | cut -d ' ' -f 1 | sort -u > requested.txt

On new mac:

Remove shadow from screen shots: (see here)

defaults write com.apple.screencapture disable-shadow -bool TRUE

Other settings

  • Control Centre, setup modules
  • Desktop and Dock: Fix size, disable latest files, fix hot corners
  • Display: Change arrangement
  • Touch ID: Add enough fingers
  • Internet Accounts: Setup stuff
  • Keyboard: Add keyboard navigation, input sources (EU+DK), shortcuts for changing input source
  • Mouse, trackpad: Fix speed etc

 

Also consider:

  • Check Account Recovery in Apple setup
  • Check Accessibility, Display, Color filters

 

Mac: How to configure Mac screen sharing to only listen on localhost

This can be done as shown below

sudo defaults write /Library/Preferences/com.apple.RemoteManagement.plist VNCOnlyLocalConnections -bool yes

MacPorts: Install port with special configure options

Sometimes it is nice to be able to reinstall a MacPorts port with your own special configure options.

Step 0: Update Macports

sudo port selfupdate
sudo port upgrade outdated

Step 1: Locate the Portfile in question and edit it

cd /opt/local/var/macports/sources/rsync.macports.org//macports/release/tarballs/ports/devel/openssl
sudo emacs -nw Portfile
# add a few lines e.g., in the configure section
enable-ssl3 \
enable-ssl3-method \
enable-weak-ssl-ciphers \
enable-rc5 \

Step 2: Uninstall and then re-install the Port (-s = from source)

sudo port uninstall -f openssl
sudo port -s -v install openssl

Step ∞: Remember to redo Steps 1 and 2 each time you do a port selfupdate

Mac Word Start/End of line

Most Mac applications use ctrl-a and ctrl-e (option-a/e) to move to the beginning resp. end of line.
Mac Word does by default not.

To set this up:

  • Start Word
  • In the menu select Tools | Customize Keyboard
  • Select All Commands in the Category pane
  • Search for OfLine. This shows the commands EndOfLine and StartOfLine in the Command pane.
  • You can now add a shortcut for ctrl-a as needed

Upgrading MacPorts when upgrading to a new version of Mac OS X or to a new Mac

This is a quick list of the steps necessary to make your MacPorts installation work when upgrading to a new version of Mac OS X.

1. Pre-upgrade/Old mac: Clean up old MacPorts installation

You may want first to do port selfupdate etc to upgrade to the newest version of MacPorts.

Also remove all unnecessary packages etc.

For more information, have a look at this page.

sudo port uninstall inactive

2. Pre-upgrade/Old mac: Save MacPorts state

Save a list of all installed ports + whether they were specifically requested

sudo port -qv installed | cut -d ' '  -f 3 | sort -u > myports.txt
sudo port echo requested | cut -d ' ' -f 1 | sort -u > requested.txt

For more information, see this page.

3. Pre-upgrade: Uninstall old packages

sudo port -f uninstall installed
sudo port clean all

For more information, see this page (same as Step 2).

4. Post-upgrade/New mac: Install stuff

Install Xcode, and then basically follow the remaining steps from this page.

SSHfs not working in Yosemite?

This is due to Yosemite requiring kernel modules to be signed. Run this command and restart:

sudo nvram boot-args="kext-dev-mode=1"

See this page for further information.

 

Turn off CPU Throttling

Some CPU’s use CPU throttling to reduce the speed of the CPU when it is not in heavy use Continue reading »