Link Search Menu Expand Document

System Configuration

Last updated: 2022 May 24

Setting up additional internal drive

Format your drive

I use gparted and set the whole thing to be a single ext4 partition with a gpt partition table. Note the partition ID (e.g., /dev/sda1) for the next step.

If you give your partition a label and name in this step, it’ll make it easier to identify/remember in the next step and later on. Setting the name will also mean it’s nicely labeled in your file explorer.

Get the UUID of the disk

Run sudo blkid and copy the UUID for the partition from the previous step.

Create a mount point

Choose a location where you want your drive to show up as, such as /data, /media/data, or /media/USERNAME/data. I don’t actually know if there’s a canonical way to choose the mount point. Since I’m generally creating a drive that’s only used by my user, I generally create the mount point under my username.

Now create this directory to mount at, such as: (with your username filled in)

sudo mkdir /media/USERNAME/data

Then change this location to be owned by your user and group:

sudo chown -R USERNAME:USERNAME /media/USERNAME/data

Set up automatic mounting

We’ll add an entry to the filesystem table to detect and mount the drive by its UUID when the computer boots, and give your user read and write access to the drive.

Warning: If you mess up this file, your computer will possibly not boot. I suggest making a backup of it so you can revert if necessary.

Edit /etc/fstab:

sudo nano /etc/fstab

Add a line to the end of the file, using the UUID you got before:

UUID=YOURUUID /media/USERNAME/data ext4 user=USERNAME,rw 0 2

A couple notes on this:

  • Don’t put quotes around the UUID
  • The second entry is the mount point you set up in the previous step
  • ext4 is the journaling system you formatted your partition as. I think you can also use auto, but why not be explicit if we know it? Also, if you set this wrong there’s a possibility your computer won’t boot.
  • The user= and rw options specify that it will be mounted for your user with read/write permissions. (I don’t really know much about all the configurations here. Check out the Ubuntu documentation wiki for more info about this and fstab in general.)
  • 0 is the “dump” flag. It’s not used for much and has something to do with automatic backups. When it doubt, it’s 0.
  • 2 is the “pass”. It means that fsck (filesystem check) will check this as a secondary partition. 0 means it will be skipped (common for external drives) and 1 will be checked first (usually used by your root partition).


Try manually mounting the drive:

sudo mount /dev/sda1 /media/USERNAME/data

Verify that it shows up in your terminal and file explorer and create a test file. (Checks that you can write as your user.)

And unmounting it:

sudo umount /media/USERNAME/data

Check that your test file isn’t in the mount location. Remount and check that it is. (aka check that you actually wrote to the disk.)

Then reboot (verify that you didn’t break fstab) and check that your drive mounted properly and your test file is there.

Sources: Installing a New Hard Drive, fstab

Check if computer restart required, with a bash alias

Sometimes you have to restart Linux after updates. If you do this with the software updater, it will tell you a restart is required. But I do my updates through the command line and am generally too lazy to restart my computer on a regular basis.

You can tell that a restart is required if the file /var/run/reboot-required exists. But I also never remember what that file name and location are to check that. But I can remember rr, so now I have an alias that uses that file to tell me if a restart is required based on the existence of that file. (This came from the AskUbuntu answer.)

Just add the following to your ~/.bashrc (or ~/.zshrc) file:

alias rr='if [ -f /var/run/reboot-required ]; then echo "reboot required"; else echo "No reboot needed"; fi`

Command line history completion

Note: this is useful for bash, but for ZSH, there’s a nicer approach.

In Matlab, you can start typing a command, hit the up arrow, and it’ll go through the history of commands that match what you’ve typed in. I like this feature and want to use it in my general command line.

Turns out this is easy to do in Linux. Open the .inputrc file:

nano ~/.inputrc

Add this to the file:

## arrow up
## arrow down

Save and exit, then load the changes:

bind -f ~/.inputrc

Prettier bash prompt

There’s a simple, awesome tool to help you do that. There’s an interactive GUI to change color, boldness, and insert text. It will even show you a live preview of what your prompt will look like.

Below that on the page, there are a few lines of code to add this customization to your terminal. If you just want to try it out before finalizing, you can just copy and paste the PS1=........ portion into your terminal. When you finalized what you want, open your bashrc file with nano ~/.bashrc and paste that entire block of code at the bottom. Then restart your terminal to make sure everything worked.

The command prompt customization is user-specific, which has a bunch of benefits: it will show up when you SSH into your user, it will show up no matter what terminal you use, and it lets you distinguish between users (so you don’t accidentally do everything as root, for example).

Currently, here’s what mine looks like (copy and paste into your terminal to check it out):

PS1="\[$(tput bold)\]\[$(tput setaf 2)\]\n\u@\h: \[$(tput setaf 7)\]\w\[$(tput setaf 3)\]\n\\$ \[$(tput sgr0)\]"

Fix “System program problem detected” on every boot

Contrary to what I thought, these errors popping up every time you turn the computer on doesn’t mean that there is always a bunch of stuff crashing on start up. It means that something crashed in the past and somehow never got cleared from the crash reports. So that means there is a simple fix!

All you have to do is clear the crash reports, which you can do with one line in the terminal:

sudo rm /var/crash/* And when you reboot, the pesky errors from before shouldn’t make a reappearance. If something does, it probably really does mean something is crashing on start up and needs to be investigated further.

Source: Ask Ubuntu

Make a shell command

This creates a bash command that can be executed in the terminal (from any directory, as any user, without sh)

One-time setup: add this to your ~/.zshrc/~.bashrc file:

if [ -d "$HOME/bin" ] ; then
    export PATH="$HOME/bin:$PATH"

For each script:

  1. Create your script file in ~/bin. Leave off the .sh filename extension when you’re naming it so you don’t have to type it to run it.
  2. Start your script file with:
    #! /bin/bash
  3. Give it the correct permissions to be executed:
    chmod 755 ~/bin/$SCRIPT
  4. Run it to make sure everything’s working.

You can now also add the scripts in this folder to your dotfiles.

Source: Unix Stack Exchange

Automatic backups (with cron and rsync)

I use this for creating a daily uncompressed backup of data of my internal data drive to an external hard drive.

Create a bash script somewhere (I have it in the main directory of what I’m backing up) containing the following:

rsync -av --delete SOURCE DESTINATION

Mine looks like this:

rsync -av --delete /media/jtebert/data /media/jtebert/data-backup/backup

Note that the --delete flag means anything placed in the destination that’s not in the source will be deleted. In other words, use the backup as a backup, not to actually edit stuff.

Then make sure the script is executable:

chmod +x /path/to/

You can now directly run this script to verify that it does what you expect.

Now we’ll create a cron table entry to automatically call this script at some time every day (this is set to 3 AM). Open the cron table with:

crontab -e

And add the following line:

0 3 * * * /path/to/

Check back the next day and you should see a copy of everything from your original folder in the backup location.

Source: How-To Geek

Saving dotfiles with git

I followed this tutorial to set up a repository containing my dotfiles. No symlinks required – it Just Works™ with the existing files in their real locations.

Here’s my dotfiles repository.

  • This is set up for ZSH. In particular, I use the Powerlevel10k theme (installed through
  • My ZSH theme configuration uses icons from Nerd Fonts. I’m using the font Hack, but any Nerd Font from this repository should work.
  • The .zshrc file already creates the alias for using the dotfiles syntax shorthand described below.

Initial setup

Locally create the git repository for your dotfiles:

mkdir $HOME/.dotfiles
git init --bare $HOME/.dotfiles

Create an alias called dotfiles to use your repository from anywhere. Add this to .bashrc or zshrc (depending on which you’re using).

alias dotfiles='/usr/local/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'

Add a remote location for your repository (filling in your username, of course)

dotfiles config --local status.showUntrackedFiles no
dotfiles remote add origin<YOUR_GITHUB_USERNAME>/dotfiles.git

How to use

You now have a git repository that you can see from anywhere, aliased to dotfiles. So you use the same syntax as git, but you replace git with dotfiles. For example:

# Add a file to the dotfiles repository
dotfiles add .bashrc
# See changes (this won't show unadded files, or it would contain your whole home folder)
dotfiles status
# Commit changes
dotfiles commit -m "Add bash config"
# Push changes
dotfiles push

Setting up on a new machine

This version avoids issues with conflicts with existing default config files.

Clone into a new (temporary) subdirectory:

git clone --separate-git-dir=$HOME/.dotfiles tmpdotfiles

Move the contents into your home folder:

rsync --recursive --verbose --exclude '.git' tmpdotfiles/ $HOME/

Delete the temporary folder:

rm -r tmpdotfiles

Using Tilix as default terminal application (with Gnome, at least)

Gnome defaults to gnome-terminal for its system terminal, but Tilix lets you tile terminals and nice stuff like that.

To make Tilix be the terminal that opens with the shortcut Ctrl+Alt+T, run:

sudo update-alternatives --config x-terminal-emulator

and choose Tilix from the resulting list of options.

Depending on your Ubuntu version, you may need to fix a Virtual Terminal Emulator (VTE) setting. If this is the case, you’ll get a warning (“Configuration Issue Detected”) when you open the Tilix preferences. You need to add the following to your ~/.bashrc or ~/.zshrc file. (This is already in my .zshrc in my dotfiles repository.)

if [ $TILIX_ID ] || [ $VTE_VERSION ]; then
        source /etc/profile.d/

You may also need to create a missing symlink, if the file /etc/profile.d/ doesn’t exist:

sudo ln -s /etc/profile.d/ /etc/profile.d/

Lastly, it’s useful to have the option to right click in Nautilus (file explorer) and open Tilix in that folder. To make sure that works, you have to install the python nautilus package.

Sources: Ask Ubuntu, Tilix: VTE Configuration, Tilix GitHub

Using Cisco AnyConnect VPN

There’s pretty nice integration for this on Chrome OS. But the Linux client was ugly and constantly cut/lost my connection. Harvard’s IT people suggested this solution/alternative using openconnect and it actually worked.

Install openconnect:

sudo apt install network-manager-openconnect-gnome

Test that the VPN works by using it through the command line:

sudo openconnect VPNURL

In the case of the Harvard VPN, the url is Also for Harvard, you can leave the second password entry (the one for two-factor authentication) blank, in which case you’ll get the Duo mobile notification on your phone for approval.

Source: Ask Ubuntu

Moving home directory to a new disk/partition

I did this to move my encrypted /home directory from my old HDD to a new NVME SSD.

  1. Using GParted (sudo apt install gparted), create an EXT4 partition on your target drive.
    • If there’s no partition table (like on a new drive), go to Device > Create Partition Table.... See this thread for which to choose. TL;DR: If it’s a Linux-only machine, choose GPT; if it’s dual-boot with Windows, choose MBR (sometimes called MSDOS).
    • Right click on the bar showing the drive, and select New. Create an ext4 partition that fills the whole drive. Don’t give it a name or label. Make sure that it is a Primary Partition. Click the check mark to apply the changes.
    • While you’re here, make note of the name of the new partition (e.g., /dev/sdb1 or /dev/nvme0n1p1).
  2. Temporarily mount point your new drive.
    • Create a folder for mounting:
      sudo mkdir -p /media/home
    • Mount your drive. Use the drive name (and partition number) from step 1 to mount.
      sudo mount /dev/nvme0n1p1 /media/home
  3. Copy everything to the new drive. If you’ve got a lot in your home directory, this will take hours.
    sudo rsync -avh /home/. /media/home/.

    By running this as root and using the -a flag, it will preserve the correct ownership of everything.

  4. Check that everything copied correctly:
    diff -r /home /media/home
  5. Set up your system to point to the new home location.
    • Get the UUID of your new partition:
      sudo blkid /dev/nvme0n1p1
    • Create a backup of /etc/fstab (because if you mess this up, your system won’t boot)
      cp /etc/fstab /etc/fstab.bak
    • Edit fstab.
      sudo nano /etc/fstab

      In this, comment out the current line that mounts your home directory with #. Copy this line (uncommented, of course) and replace the UUID with what you got out of blkid. In my case, it looks like this:

      UUID=4f491680-ec96-453b-85a9-40d4faa20e86 /home ext4 noatime,errors=remount-ro 0 0
  6. Reboot your computer. If you open up GParted, you should see that your new drive is mounted at /home. But you shouldn’t see anything different in your experience, because everything should be exactly the same as on your old drive!
  7. Clean up your old home drive. Once you’re satisfied that everything is working correctly, you can reformat your old drive or remove everything from it with rm.

Sources: TecMint, Make Tech Easier

Change error policy on a CUPS printer

If a print fails or is stopped on Linux, by default it has a stupid error policy that basically stops you from using the printer until you disconnect/reconnect. But it’s fixable!

  • First, find the name of the printer you’re looking for with lpstat -p. Mine is called “Brother_HL_L2350DW_series”.
  • Now you can check the current error policy for that printer with sudo cat /etc/cups/printers.conf. For your printer name, look for the line that starts with “ErrorPolicy”. It’s probably stop-printer, which is not what we want. We want to change it to abort-job so it doesn’t leave your printer in an unusable state.
  • To change it, run: /usr/sbin/lpadmin -p <PRINTER_NAME> -o printer-error-policy=abort-job, using the printer name you got in the first step.

Source: SI Prep