“The application XXX can’t be opened” on Mac OS X

If you are trying to launch an app on OS X and simply get the error “The application XXX can’t be opened”, the problem could be the actual executable file in the app bundle does not have corresponding permissions.

To fix the issue:

  1. Open a Terminal and enter into your app bundle. You can just type “cd
    and then drag the app into the Terminal and then hit the enter.
  2. cd Contents/MacOS
  3. chmod +x * or chmod +x <FILENAME> if you know which one is the actual executable.
  4. sudo !! may be needed if you don’t have permissions to execute step 3.

Now try to launch the app again, and the problem should be solved.

Install Apps from 3rd party in macOS Sierra

When installed apps from 3rd party or Internet download, macOS always prompt “Downloaded .app is damaged and can’t be opened”.

The solution is really simple:

Run the following command before launching the app:

sudo spctl --master-disable

Launching the app and finish installing it, and then run the following command to re-enable the restriction:

sudo spctl --master-enable

That’s it.

Restart SSH/sshd in Mac OS X

To restart ssh/sshd service in Mac OS X, you can simply run the following two commands together:

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

Your sshd will get restarted and your new ssh config file can be loaded as well.

p.s. Friendly reminding: DO NOT try to execute

sudo launchctl reboot com.openssh.sshd

instead since your computer will immediately get rebooted 🙂

SSH does not work after upgraded macOS sierra?

If you ever met the following errors when trying to git or ssh after upgraded your OS to sierra:

Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss

Just relax, it’s not your fault but your server’s fault. Upgrading your OS to sierra will also bump your OpenSSH from version 6.9 to 7.2. According to the document of OpenSSH 7 (http://www.openssh.com/legacy.html):

OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option:

ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost

or in the ~/.ssh/config file:

Host somehost.example.org
    HostKeyAlgorithms +ssh-dss

However, it is probably not enough. You may be prompted for password all the time but no password is correct. In that case, you can simply append another line in your ~/.ssh/config file:

    PubkeyAcceptedKeyTypes +ssh-dss

That’s it! Don’t forget to restart your sshd service before retrying.

Java for OS X 2014-001

After you have upgraded your OS X into Yosemite, the following dialog would appear when you are trying to launch Adobe Creative Suite:

Screen Shot 2014-11-30 at 2.05.30 PM

You can click “More Info…” button to open safari to download Java for OS X 2014-001. That can solve the problem.

Sometimes, you would see a blank page instead, totally blank, whose url is: http://support.apple.com/kb/DL1572

Don’t worry, you can simply click the following link to download Java for OS X 2014-001 directly:

http://support.apple.com/downloads/DL1572/en_US/JavaForOSX2014-001.dmg

I don’t know why, but sometimes it really happens.

Mac OS下Vi/Vim的PageUp/PageDown/Home/End替代方案

在mac os下面ssh到服务器来进行vi操作,因为键盘的局限性,没有PageUp/PageDown/Home/End,会严重影响效率。

其实替代方案也很简单,用vim自己的快捷键就成了。

例如:Ctrl-F(Forward) 相当于 PageDown,Ctrl-B(Backward)相当于PageUp。

再比如:^ 相当于Home,$ 相当于End(意义来自正则表达式)。

这回效率提升上去了吧;)