How to setup Ubuntu on a MacBook Pro

Published on 2018 / 01 / 02 ‚óŹ Last updated on 2018/02

Table of contents

These instructions were tested on a MacBook Pro Mid 2014.
Should —probably— work just fine on other MacBooks.


If you install Ubuntu on a MacBook, you’ll soon find a small —but highly irritating— set of behaviours:

  • The Alt and Cmd keys are swapped out (using a PC keyboard as a reference).
  • The function keys are swapped out with the multimedia keys.
  • Cannot easily copy & paste on the CLI with the laptop’s keyboard.
  • The trackpad behaves erratically.
  • You can hardly read anything on the screen or…
  • Maybe the UI size is too big and you’d want to adjust it to your liking.

If this sounds like your kind of problems, then keep reading, solutions are ahead.
Right now, the only issue without a solution is the integrated webcam. It does not work.

Keyboard issues

Swap Cmd and Alt keys

If you’d like your Alt key where it usually is on every PC —except Macs. With immediate effect, but temporary:

echo 1 | sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd

Make it permanent:

echo options hid_apple swap_opt_cmd=1 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all

Enable function keys

This will make your function keys available by default. To use your multimedia keys, you’ll now need to hold the fn key while pressing a multimedia one.

With immediate effect, but temporary:

echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

This change is not permanent. To make it so:

echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all

Paste with a single key

If you’ll be using the reduced laptop keyboard, it’s going to be tough to always use the mouse for copy & pasting.

What about using the Right Super key (the one labeled as Alt if you swapped the Cmd and Alt keys above) for pasting?

sudo apt install xkbset

echo "" >> ~/.bashrc
echo "xmodmap -e \"keycode 134 = Pointer_Button2\"; xkbset m" >> ~/.bashrc

It works just like when you highlight some text with the mouse then click the middle button to paste it somewhere else.

Whenever you highlight text with your mouse in Ubuntu, it is copied to a special buffer that you can paste from clicking the mouse’s mid button.

Pasting in the CLI is usually done with Shift + Ins, good luck finding the Insert key.

Trackpad issues

If your mouse’s cursor is jumpy, or you do have general problems using the Mac’s trackpad, then you should install libinput:

sudo apt install xserver-xorg-input-libinput

To customize the trackpad behavior, you need to modify the /usr/share/X11/xorg.conf.d/60-libinput.conf file.

Some of the changes above require a restart.

High DPI displays

Vanilla Ubuntu

To adjust the text size (font size) in general, with immediate effect, try:

gsettings set org.gnome.desktop.interface text-scaling-factor 1.65

I think it’s better to learn how to do this kind of stuff from the command line (CLI), but if you want to take a look at all the available options, you’ll need dconf-editor:

sudo apt install dconf-editor

You can check out on the value you just changed by executing dconf-editor and browsing to the location we used above: org -> gnome -> desktop -> interface.

i3 Ubuntu

Unfortunately, i3 does not use the info set in org.gnome.desktop.interface text-scaling-factor.

So, another way to adjust the display is to change the screen mode (resolution), this one works well:

xrandr --output eDP-1 --mode 1680x1050

What we did was to downscale the resolution from 2560x1600 to 1680x1050.

TIP ~ Back to login screen

On i3 you can close your session with: Shift + Super + E.

Super is the Windows key.

If you, somehow cannot press that combination, you can use (with caution), the next command:

kill -9 -1

This will terminate all the user processes, and get you back to the login screen.

  • DO NOT execute it with sudo.
  • DO NOT execute it if you have unsaved data.

— lt

Feedback & comments

Get in touch on Twitter

Or by good ol' email at adriandcs@gmail.com