Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coltonbh/2193252db025e67341eab5a6e45b18a7 to your computer and use it in GitHub Desktop.
Save coltonbh/2193252db025e67341eab5a6e45b18a7 to your computer and use it in GitHub Desktop.
Switching to Linux (Ubuntu) for Total Beginners

Switching to Linux (Ubuntu)

Applications

Applications for Linux come in a few varieties. You can install packages using the system package manager (apt), install snap packages, "install" (run) AppImage applications, run installer scripts offered by a particular application, download and unzip application (and place them in an appropriate directory), or install from source. I'll discuss each installation method, where files should be written to, how (if) they should be symlinked, and how to integrate them into your desktop environment.

Applications are usually installed into one of the following places:

  • ${HOME}/Applications for AppImage files. Then they are often integrated into your Desktop environment using [[#Create Desktop Icons for Applications|the instructions below]].

  • /opt/ is for add-on application software packages (link). This means software applications you add to your system like Julia, ownCloud or containerd. These applications are often installed using installation scripts offered by the software package or are the copied contents of unzipped application downloads. Sometimes apt installs put packages here too. Applications installed here are binaries and usually contain their own /bin and /lib directories. E.g., here's the install for Julia:

     ~ ❯ ls /opt/julia-1.6.3           
     bin  etc  include  lib	libexec  LICENSE.md  share

    The binary is contained in the /bin directory:

    ~ ❯ ls /opt/julia-1.6.3/bin
    julia

    If the package has a command line component to it (like running julia from the command line to begin the interactive interpreter) you will need to add a symlink to the binary to a directory on your $PATH. A good choice is /usr/local/bin/{application-name} like so:

     ~ ❯ ln -s /opt/julia-1.6.3/bin/julia /usr/local/bin/julia

    This makes running julia from the command line start the application.

    These applications are ultimately "packaged" as a directory that contains binaries that the system can run. Often these "packages" are just the unzipped contents of a zipped download from a website.

Package Manager (apt)

AppImage Files

AppImage files are "self contained" applications, i.e., they can be run directly without needing to install them in any way and they can be run without root privileges. This means you just download the file and then run it from the command line and the application starts.

~ > ./MyApplication.AppImage

This means you can store AppImage files anywhere and run them. This post suggeststs that "the official recommendation by the AppImage developers is to create an extra directory, ${HOME}/Applications/ (or ${HOME}/.local/bin/ or ${HOME}/bin/) and store all AppImages there. I have chosen to use ${HOME}/Applications/.

You probably want to integrate your AppImage into your desktop environment. To do that see the [[#Desktop]] section below.

Snap Packages (and Ubuntu Software Installs)

Snaps are a more "modern" way to package applications for Linux. Evidently there is some history to packaging in Linux and Ubuntu set out to create a "better way" that nicely sandboxes apps and allows them to be packaged with their dependencies so they don't rely upon the underlying system (which may be different on every machine). snaps are the product of this work. The effort has received mixed reviews with some people wanting to remove all things snap from their system entirely and others finding it resonably useful. Ubuntu certainly pushes this format as all software installed from their Ubuntu Software Store is in the snap format.

Snaps have an isolated, sandboxed filesystem associated with each app which can be seen by running the following command (results will be seen if a snap has been installed):

~ ❯ lsblk
NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                   7:0    0     4K  1 loop  /snap/bare/5
loop1                   7:1    0  71.9M  1 loop  /snap/bitwarden/58
loop2                   7:2    0 152.3M  1 loop  /snap/firefox/701
loop3                   7:3    0 603.1M  1 loop  /snap/libreoffice/237
loop4                   7:4    0    51M  1 loop  /snap/snap-store/547
...

Snaps appear to update themselves (e.g., I see multiple snap versions on my system for applications that I have never updated manually). Snaps are installed in /snap.

From Source

Desktop

Create Desktop Icons for Applications

After installing an application you may want to integrate it into your desktop environment. This will create an icon for it and put in your application menu. To do this create a .desktop file for the application in ${HOME}/.local/share/applications/myappname.desktop. The file will look something like this (example is for obsidian.desktop, be sure to have an empty last line in the file or Ubuntu won't recognize it):

[Desktop Entry]
Name=Obsidian
Exec="/home/cbh/Applications/Obsidian-0.12.19.AppImage" %U
Terminal=false
Type=Application
Icon=/home/cbh/.local/share/icons/hicolor/280x280/apps/obsidian-logo.png
Categories=Office;
TryExec=/home/cbh/Applications/Obsidian-0.12.19.AppImage

The .desktop file tells the desktop environment where to locate the application, its associated icon, and other details about launching and running the app.

Evidently (from AppImage files I have installed that offer to integrate themselves into your Desktop environment) icon files should be stored in the location noted in the Icon setting.

FileSystem Heirachy (or where to place what)

A great overview can be found on Wikipedia. Below I try to capture specific use cases I've encountered.

Directory Description What Goes Here
.local According to this post .local/share/ is intended to be a single directory where user data is stored. .local/share/applications contains all the .desktop files to integrate AppImage files into the desktop environment

GPUs

Installing nvidia drivers

  • Additional Drivers -> Choose nvidia driver
  • Needed to follow secure boot instructions here
    • During the first reboot, "Perform MOK management" screen will show up. Select "Enroll MOK" option.
    • Select "Continue", then, "Yes".
    • "Enroll the key(s)?" screen will present. Enter the password from secure boot after choosing nvidia driver.
    • "OK" to reboot.
    • Had to reboot an extra time. Not sure why?...

Turn nvidia GPU on/off

The GPU can consume a lot of power. If you are running on battery power you may want to use the Intel integrated GPU for graphics instead of the power hungry nvidia GPU. You can use the prime-select command line tool (installable with apt install nvidia-prime) to turn the GPU on/off.

To see current system settings for GPU usage run the command below (three possibilities exist, intel, nvidia, or on-demand which tries to use the GPU more sparingly and is discussed briefly here):

~ ❯ prime-select query

To turn the GPU off (a restart is required afterwards):

~ ❯ prime-select intel

To Turn the GPU on (a restart is required afterwards):

~ ❯ prime-select nvidia (OR!) on-demand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment