June 25, 2026

Change Mac power management from sleep to hibernation

In case you don't use a Mac laptop regularly, changing the power management from regular sleep to hibernation helps preserving battery life. To do this, run the command below:
> sudo pmset -a hibernatemode 25

To verify the change, you can run the following command and look for the value of "hibernatemode":
> pmset -g

The downside of hibernation is that it takes longer for the Mac laptop to wake, since system is restored from a disk image.

To return to the regular sleep mode, run the command below:
> sudo pmset -a hibernatemode 3

Reference: https://www.dssw.co.uk/reference/pmset/

March 4, 2022

Change Thunderbird background color

To change the background color for Thunderbird message pane, which seems
not to be possible via the UI, do the following:
* Access the configuration editor via Preferences > Config Editor
* Change the value of the setting "browser.display.background_color"

February 14, 2022

Enable encrypted formatting in Disk Utility in macOS

If the option to select the encrypted format type doesn't appear when using Disk Utility in macOS, you may need to change the partition scheme, e.g., change to GUID Partition Table:

  1. Disk Utility > View > Show All Devices
  2. Go to root of the target drive then select "Erase"
    • Format: APFS (Encrypted)
    • Scheme: GUID Partition Map

Note: Mac OS Extended (HFS+) is the previous file system from Apple, but APFS is currently recommended, unless there are compatibility issues with systems before macOS High Sierra, or if you want to use the drive with Time Machine on macOS Catalina or older.

References
Disk management command line: https://www.theinstructional.com/guides/disk-management-from-the-command-line-part-2
No partition scheme option: https://apple.stackexchange.com/questions/304131/no-partition-scheme-option-when-erasing-a-usb-disk-in-macos-high-sierra
Comparison of macOS file systems: https://www.techrepublic.com/article/apfs-vs-hfs-which-apple-filesystem-is-better/

April 15, 2021

Adding custom sound effects to macOS

In order to add custom sound effects to macOS, you need to copy the new sound files into the directory "~/Library/Sounds/" located in your home directory. The file name will be used to designate the new sound effect in the Sound panel of the System Preferences dialog. You can then select this new sound effect as the default alert sound.

Note that sound effect files need to be in the AIFF format; files in this format can be created via the iTunes application. Moreover, sample AIFF files can be found in the "/System/Library/Sounds/" which contains the built-in macOS sound effects.

December 23, 2020

File userChrome.css not working for Thunderbird/Firefox

Newer versions of Thunderbird and Firefox (starting around 2019) disable by default the loading of the 'userChrome.css' file used to configure display preferences. To enable it, you must enable via the Config Editor the setting called toolkit.legacyUserProfileCustomizations.stylesheets.

Reference: https://www.userchrome.org/how-create-userchrome-css.html

September 29, 2018

Display unified CJK characters in macOS terminal as Japanese characters

Without some specific language information (such as the "lang" attribute in HTML), unified CJK Unicode characters are displayed by default in a generic manner. However, users of a certain language would prefer to see the particular character version for that language even in the terminal.

This is possible in macOS by adding that language as a preferred one. For example, in order to display unified CJK characters in a macOS terminal as Japanese characters, you have to:
  • Go to System Preferences > Language & Region
  • Add the Japanese language to the "Preferred languages" panel

Note that you will need to restart the Terminal app before changes take effect.

June 24, 2017

Disable password prompting for updates in Ubuntu

If you want to run the Synaptic packet manager in Ubuntu/Lubuntu without it requiring a password, you must add a PolicyKit local definition. For this purpose create a file, named for instance /etc/polkit-1/localauthority/50-local.d/allow-user-update-wo-password.pkla, and add the following content to it:
[Allow User Updates Without Password]
Identity=*
Action=com.ubuntu.pkexec.synaptic
ResultAny=no
ResultInactive=no
ResultActive=yes

February 4, 2017

Customize GRUB2 menu colors in Ubuntu

The procedure for customizing GRUB2 menu colors in Ubunt is as follows:
1) Edit (or create) the file "/lib/plymouth/themes/default.grub" to add the appropriate menu color information.
Example:
# Color of the highlighted menu entry and its background within the menu box
set menu_color_highlight=yellow/dark-gray
# Color of non-selected menu entries within the menu box
set menu_color_normal=black/light-gray
# Color of the text and background outside the menu box
set color_normal=light-gray/black
2) Regenerate the the grub configuration file by running 'sudo update-grub'.

Customize other OS menu entries in GRUB2

The procedure for customizing menu entries for other OSes in GRUB2 is as follows:
1) Copy the menu entry you wish to customize from "/boot/grub/grub.cfg"
to "/etc/grub.d/40_custom".
2) Change the name of the menu entry as you wish.
3) Disable the OS prober to prevent regenerating the old menu entry by using the option "GRUB_DISABLE_OS_PROBER=true" in "/etc/default/grub".
4) Regenerate the the grub configuration file by running 'sudo update-grub'.

February 3, 2017

Enable Keychain use for ssh in macOS

In order to enable the use of passwords/passphrases stored by the Keychain Access service on macOS, the following specific ssh option is available starting with macOS 10.12:
  UseKeychain=yes

The setting can be provided either on the command line, or in the ssh configuration files (/etc/ssh/ssh_config, ~/.ssh/config).

May 23, 2016

Force disk checking during boot in Ubuntu

In order to force disk checking during boot in Ubuntu and other modern
operating systems, the 'fsck.mode=force' kernel parameter needs to be
added before booting.

In Ubuntu this is done as follows:
1) At the GRUB screen, press 'e' to edit the kernel parameters.
2) Add 'fsck.mode=force' at the end of the line that starts with the
keyword 'linux'.
3) Press 'Ctrl+x' or 'F10' to boot with the updated kernel parameters.

Note that only the partitions that have '1' or '2' as the fsck option in
'/etc/fstab' will be checked. The value '1' is reserved for the boot
partition, and all the other partitions to be checked should use the
value '2'.

April 2, 2016

Fix automatic suspend in Lubuntu

If you get the error "Authentication required before suspend" when the PC tries to suspend automatically, the actions below are required.

In the file "/usr/share/polkit-1/actions/org.freedesktop.login1.policy" search the section "<action id="org.freedesktop.login1.suspend">" and change the corresponding lines as below:

<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>

An alternative solution, which is supposed to be permanent since the file above is updated occasionally, is given next.

Go to "/etc/polkit-1/localauthority/50-local.d/" and create a file named for instance "com.0.enable-automatic-suspend.pkla". Put the following text into the file:

[Enable automatic suspend]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend
ResultAny=yes

Based on http://askubuntu.com/questions/785509/hibernating-from-cron/786225#786225

October 23, 2015

Delete older kernels in Ubuntu

To delete older kernels in Ubuntu, an easy way is to use the Synaptic package manager:
1) Search for "linux-image", and select the old kernels for removal
2) Search for "linux-header", and select the old kernel headers for removal

August 6, 2015

Input \ instead of ¥ on Mac OS X Japanese

In order to input the backslash character "\" instead of "¥" on a Mac OS X system with Japanese keyboard settings, you should go to "System Preferences > Keyboard > Input Sources" then select the Japanese keyboard. Towards the bottom of the settings in the right pane change the setting for '"¥" key generates' to the value '\ (Backslash)'.

May 17, 2015

To make the function keys on Apple Keyboard work correctly in Ubuntu and its variants (Lubuntu, etc.), the following commands should be used to permanently set the corresponding "fnmode" property and update the configuration files:
>echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
>sudo update-initramfs -u -k all
You need to reboot after this for changes to take effect.
Reference: https://help.ubuntu.com/community/AppleKeyboard

February 23, 2015

Manually delete TimeMachine backups

Use the following command to manually delete TimeMachine backups (starting with Mac OS X Lion):
> sudo tmutil delete TimeMachine_BACKUP_NAME
Note: It is possible to delete backups of other machines than the current one.

January 27, 2015

Matlab 2013b crash at start-up

If Matlab 2013b crashes at start-up with the "java.lang.NullPointerException" error, one possible solution is to temporarily change the Mac OS X version number.

For this, change the ProductVersion value from e.g., 10.10.1 to 10.90 in the file "/System/Library/CoreServices/SystemVersion.plist".

This change can be reverted once Matlab starts (recommended, since changing the OS version seems to interfere with Safari, etc.).

Reference: http://mathworks.com/matlabcentral/newsreader/view_thread/336387

March 6, 2014

static linking in gcc

In order to force static linking in gcc/g++ you need to use the option
'-static'. However, unless you have installed in advance the static
versions of the glibc libraries you will receive an error such as:
> /usr/bin/ld: cannot find -lm

To install the static versions of the libraries, on RHEL variants for
instance, run:
> sudo yum install glibc-static

December 2, 2013

using external JARs in Eclipse

In order to use external JAR files in Eclipse, the most robust way if
you develop on multiple platforms is to use "Preferences > Java > Build
Path > Classpath Variables" to add a classpath variable. You can give it
any name you wish, and you must associate to it the file name of the JAR
that you want to include.

import source code in eclipse

To import existing source code in Eclipse, do the following:
1) Create a new project and give it the same name with the directory
containing your source code.
2) Uncheck "Use default location" and manually set the location to the
directory containing the source code.
Usually Eclipse automatically detects your source code, and you can
simply click "Finish" to finalize project creation.