Users & Groups
Add a new user to the machine on a Linux OS
# Default shell /bin/sh
adduser USER
# Custom shell /usr/bin/zsh
adduser --shell /usr/bin/zsh
Add a USER to the sudo group
Delete a user from the machine
# Keep a backup of the user's home directory, stored in the pwd
deluser USER --backup --remove-all-files
Delete a group from the machine
Change the machine's hostname
hostnamectl set-hostname HOSTNAME
Change a user's username
# Short form
usermod USER -l NEW_USERNAME -md NEW_HOME_FILEPATH
# Long form
usermod USER --login NEW_USERNAME --move-home --home NEW_HOME_FILEPATH
Change a group's name
# Short form
groupmod GROUP_NAME -n NEW_NAME
# Long form
groupmod GROUP_NAME --new-name NEW_NAME
Change a user's information on a Linux OS
# [ Linux ]
# Short form
chfn USER -f "Austin Traver"
# Long
chfn USER --full-name "Austin Traver"
View which groups the active user is associated with:
The output is similar to the following:
The first group listed in the output is the user's primary group.
View which groups a particular user belongs to:
The output is similar to the following:
USER : USER cdrom floppy audio video admin netdev
Where USER is the name of the user provided in the command.
Change the owner that a particular file belongs to:
Where OWNER is the owner of the file located
at the filepath FILE
Change the group that a particular file belongs to:
Where GROUP is the group of the file located at
the filepath FILE
Apt
Snap
Installing Snapcraft
apt install -y snapd
snap set system refresh.retain=2
Finding the specific version of a package
Where PACKAGE is a name, such as cmake
Installing a specific version of a package
snap install cmake --channel=3.17/stable --classic
SMB
Installing SMB server on Ubuntu
C/C++
Java
Go
Python
LLVM
GitHub
NodeJS
AWS
Installation
Installing Ubuntu the hard way
hdiutil convert ~/Downloads/ubuntu.iso -format UDRW -o ~/Downloads/ubuntu.img
mv ~/Downloads/ubuntu.img.dmg ~/Downloads/ubuntu.img
diskutil list
diskutil unmount /dev/disk2
sudo dd if=${HOME}/Downloads/ubuntu.img of=/dev/disk2 bs=1m
diskutil eject /dev/disk2
Enabling automatic login
Using privileged admin account open up terminal or your favorite text
editor and edit the configuration file /etc/gdm3/custom.conf
Change the following snippet from
Before you begin editing, your configuration might look like this:
[daemon]
# Uncoment the line below to force the login screen to use Xorg
#WaylandEnable=false
# Enabling automatic login
# AutomaticLoginEnable = true
# AutomaticLogin = USERNAME
Change the file so that it instead looks like this:
[daemon]
# Uncoment the line below to force the login screen to use Xorg
#WaylandEnable=false
# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = USERNAME
You will need root/administrator privileges to perform this operation. Uncommenting the above lines will enable automatic login for the linuxconfig user. Change the username to suit your needs.
Snap Packages
Ubuntu is migrating away from using Debian's Apt to manage packages, and toward using Canonical's Snapcraft
They wrote an article titled How to keep your Linux disk usage nice and and tidy where I learned you can reduce the number of prior package versions that Snapcraft keeps, which by default, is three.
snap set system refresh.retain=2
Distribution Upgrades
Ubuntu 20.04 "Focal Fossa" has just released, so I thought I'd write a guide on how to upgrade.
- Upgrading to the latest Ubuntu distro:
Sign in to the root user
Update the /etc/apt/sources.list, replace any entries of bionic or eoal with focal
sed -i 's/bionic/focal/g' /etc/apt/sources.list
Run the apt commands below
apt update
apt upgrade
apt full-upgrade
apt install -y update-manager-core
reboot
do-release-upgrade -d
Verify successful upgrade by checking the current distribution number
Google Cloud SDK
Vim
Installing NeoVim
snap install neovim --classic
PowerShell
For more information, see Installation via Package Repository in the PowerShell documentation.
# Install pre-requisite packages.
sudo apt update && sudo apt install -y \
wget \
apt-transport-https \
software-properties-common \
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after
# we added packages.microsoft.com,
# then install PowerShell
sudo apt update && sudo apt install -y powershell
Mounting Files
If you are running Ubuntu from within Windows Subsystem for Linux, you can mount a remote filesystem on another host, such as a host running macOS, with the hostname HOENN, and a share named Macintosh HD, as follows:
mkdir /mnt/s
mount -t drvfs '\\HOENN\Macintosh HD' /mnt/s
Alternatively, you can mount the volume as a network drive within Windows in the File Explorer, and run the following command to mount the network drive:
mkdir /mnt/m
mount -t drvfs 'M:\' /mnt/m
Convert SVG to PNG
Install librsvg, which is built by GNOME
If you want to convert example.svg into a 1024x1024 PNG file, you have a few
choices. These are ordered from best to worst.
Using librsvg:
# If necessary
sudo apt install librsvg2-bin
rsvg-convert -w 4096 -h 4096 example.svg -o example.png