Skip to content

Useful Commands for New Systems

Ubuntu Server

Set Timezone to US/Denver

timedatectl set-timezone America/Denver

Resize the Boot Volume

Sometimes the Ubuntu installer does not utilize the entire boot disk.

Run these commands to expand the logical volume and the ext4 filesystem on top of it to the maximum size of the storage device.

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Boot in Text/Console Mode

sudo systemctl set-default multi-user.target

Disable Ubuntu Pro Message

pro config set apt_news=false

LVM

Create a Logical Volume

This creates an LV using all of the free space on the storage device. It uses optimal track alignment.

lvcreate -n NAME -l 100%FREE volumeGroupName

Apt

Force Upgrade Packages

When apt won't upgrade packages during an apt upgrade run with messages like this:

The following packages have been kept back:

You can force-upgrade the packages with:

apt-get --with-new-pkgs upgrade

Or, you can do it one-by-one with:

apt-get install <packagename>

SSH

Generate an Ed25519 KeyPair

ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "[email protected]"

Shell Enhancements

colorls

apt install ruby ruby-dev ruby-colorize
gem install colorls
alias ls=colorls

screenrc

Put this in ~/.screenrc for a nicely decorated GNU Screen session.

Linux

vbell off
backtick 1 60 60 awk '{if ($1=="MemTotal:") mt = $2; if ($1=="MemFree:") mm = $2; if ($1=="Buffers:") mb = $2; if ($1=="Cached:") mc = $2} END {printf ("%2.1f"), ((mt-(mm+mb+mc)) * 100 / mt);print "%M"}' /proc/meminfo

backtick 2 60 50 awk '{if ($1=="SwapFree:") fs = $2; if ($1=="SwapTotal:") ts = $2} END {printf ("%2.1f"),((ts-fs) * 100 / ts );print "%S"}' /proc/meminfo

defscrollback 30000
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{R} %l %{G} %1` %2`]'

FreeBSD

screen -t bash /usr/local/bin/bash
altscreen on
term screen-256color
bind ',' prev
bind '.' next
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'