Switching from macOS to Linux/Installing

Downloading

edit

To install Ubuntu, first get it from Ubuntu's download page. You have the choice between Desktop and Server versions. If you are familiar with the command line and intend to run Ubuntu as a server, download the server version first. If you are unfamiliar with the command line, you can install the GUI while you learn it. Instructions to do that appear later.

Ubuntu is released twice a year, once in April, once in October. These versions are supported for 9 months. Every 2 years, Ubuntu releases a "Long Term Support" (LTS) version that is supported for 5 years.

The version matches the year, month, and day. Ubuntu 16.04.03 means it was released in on April 3rd, 2016. Ubuntu 17.10.1 was released on October 1st, 2017.

Installing

edit

Virtual Machines

edit

VirtualBox is free so you can get started with this right now. There are many instructions online that discusses how to do this. The steps are basically as follows.

  • Create a new VM
  • Attach the downloaded iso
  • Start the VM
  • Run the installer

VMware Fusion is easier. Just select "Install from disc or image" and drag the iso on top of it.

Boot Camp

edit

Installing Ubuntu on a Mac

Non-Mac Hardware

edit

Ubuntu's desktop tutorial. Ubuntu's server tutorial. Ubuntu's server installation guide.

Forgotten Password

edit

If you forget your password you must reboot and enter Recovery Mode. If you are at the login screen you can reboot by pressing control-alt-delete (control-option-delete). Hold down the shift key as soon as the computer restarts. Almost immediately you will enter the GNU GRUB menu. If the computer wont even boot to the GRUB menu, you must boot to a CD's GRUB menu.

Once booted to the GRUB menu, choose "Advanced options for Ubuntu", then "recovery mode", then "Drop to root shell prompt". Type these commands to make the disk writable.

mount -o remount,rw /
mount --all

Then you can change a password using passwd. User information is stored in /etc/passwd and passwords are stored in /etc/shadow. /etc/passwd needs to have 644 permissions and /etc/shadow must have 640 permissions. Home folders are in /home/. Group information is stored in /etc/groups.

Software Update

edit

Finding your version

edit

You can find out the current version of your OS with this command.

cat /etc/lsb-release

This is what it printed.

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

You can also view the version of the Linux kernel by running this command.

uname -a

This is what it printed.

Linux ubuntu 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

According to the Linux Kernel Archives the latest version at the time of writing is 4.15.

Update

edit

The first thing you want to do after installing (assuming your networking is working) is to update. To update run these commands.

sudo apt-get update

This command updates your local copy of available software that you can install. Run this command periodically to make sure your source list is up-to-date.

When I first installed 16.04 and ran apt-get update I got an error that said the following.

The repository 'cdrom://Ubuntu 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial Release' does not have a Release file.

It's pretty annoying when an error appears right out of the box, but don't let it stop you. I fixed it by searching for the error on the internet and I found this page that says to edit /etc/apt/sources.list and comment out lines that began with "deb cdrom". That fixed the problem for me.

Upgrade

edit

Next, run this command to upgrade the packages already installed on your computer.

sudo apt-get upgrade

The Ubuntu server guide says to run this command to upgrade Ubuntu server.

sudo do-release-upgrade

On other Linux versions you would run this command instead.

sudo apt-get dist-upgrade

Viewing what you have installed

edit
apt list --installed

This will print a long list of all of the software installed on your computer.

Getting new software

edit

I setup SSH first because I'm most familiar with the Mac, so I prefer to work from a Mac, so I prefer to login to Linux using Mac's Terminal.app.

SSH isn't installed by default. You can install it using the following command.

sudo apt-get install openssh-server

You could also install it using the tasksel command (see below).

To check it's status run this command.

service ssh status

Once it's running you can ssh into your Linux box by first getting the IP of your Linux computer by running this command.

ip addr show

Then on a different computer (like your Mac), you can ssh in by running this command.

ssh name@yourip

If you are using a virtual machine, now would be a good time to make a snapshot.

Virtualmin

edit

Virtualmin GPL is an extension of the Webmin web console that is used to configure a Unix based server using a web browser. I intend on using a web console as a crutch so that I can get up and running as quickly as possible. I intend on learning how to configure everything using the command line, but getting a production server running will give me a reason to learn the command line.

I choose Virtualmin for one reason, it safely backs up MySQL databases. I didn't see any other free web consoles . I don't have my own scripts to do this, so I'm relying on this product to do it for me. Virtualmin also installs Webmin and LAMP, which I also plan to install. So this just does it all for me.

To find the latest instructions see the Virtualmin instructions.

At the time of this writing, the instructions were to run these commands.

wget http://software.virtualmin.com/gpl/scripts/install.sh
sudo /bin/sh install.sh

Webmin

edit

Virtualmin will install Webmin. If you don't want Virtualmin but do want Webmin, you can install it with the following commands.

Add the webmin source.

sudo nano /etc/apt/sources.list.d/webmin.list

Add this line.

deb http://download.webmin.com/download/repository sarge contrib

Then run these commands

sudo wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo rm jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin

Then you can login and configure your server using a web browser at https://yourip:10000.

tasksel

edit

This command is a short cut to installing many things, based on the task. Run it without any arguments for a list.

sudo tasksel

In my case I selected "Samba file server".

To see what a task is actually installing, look at /usr/share/tasksel/descs/ubuntu-tasks.desc.

I could also install a specific task by naming it.

sudo tasksel install lamp-server

And I could remove it using the remove command.

sudo tasksel remove lamp-server

After installing LAMP, it is recommended that you secure it.

Desktop GUI

edit

If you really want to install the GUI on Ubuntu Server type one of the following.

For only the desktop and not the extras.

sudo apt-get install --no-install-recommends ubuntu-desktop
sudo reboot

To remove:

sudo apt-get remove ubuntu-desktop
sudo reboot

To install the desktop and all of the extras (Firefox, LibreOffice, mp3 player).

sudo tasksel install ubuntu-desktop
sudo reboot

To remove:

sudo tasksel remove ubuntu-desktop
sudo reboot

The rest of this book is going to assume you don't have Desktop installed.

Listing software

edit

For an absolutely gigantic list of software that you can install run this command.

apt-cache search .

You can also substitute a keyword to find software with that keyword.

apt-cache search lamp

Ironically, this doesn't list Apache, MySQL, or PHP. Even more ironically a web search led to old documentation that didn't work either. I had to go to the Official Ubuntu Documentation, find the latest Server documentation (16.04 LTS), and look for "LAMP" there. The page there said to use tasksel.