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/zshAdd a USER to the
sudogroupusermod -aG sudo USERDelete a user from the machine
# Keep a backup of the user's home directory, stored in the pwd deluser USER --backup --remove-all-filesDelete a group from the machine
delgroup GROUPChange the machine's hostname
hostnamectl set-hostname HOSTNAMEChange 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_FILEPATHChange a group's name
# Short form groupmod GROUP_NAME -n NEW_NAME # Long form groupmod GROUP_NAME --new-name NEW_NAMEChange 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:
groupsThe output is similar to the following:
staff adminThe first group listed in the output is the user's primary group.
View which groups a particular user belongs to:
groups USERThe output is similar to the following:
USER : USER cdrom floppy audio video admin netdevWhere USER is the name of the user provided in the command.
Change the owner that a particular file belongs to:
chgrp OWNER FILEWhere OWNER is the owner of the file located at the filepath FILE
Change the group that a particular file belongs to:
chgrp GROUP FILEWhere GROUP is the group of the file located at the filepath FILE
Apt
Install the development tools package
apt install -y build-essentialInstall the manual pages about using GNU/Linux for development:
apt install -y manpages-dev
Snap
Installing Snapcraft
apt install -y snapd snap set system refresh.retain=2Finding the specific version of a package
snap info PACKAGEWhere PACKAGE is a name, such as
cmakeInstalling a specific version of a package
snap install cmake --channel=3.17/stable --classic
SMB
Installing SMB server on Ubuntu
Install the
sambapackage fromaptapt update apt install -y samba samba-common-bin smbclient cifs-utils[sambashare] path = /home/USER/DIR read only = no browsable = yes comment = hello worldservice smbd restart ufw allow samba smbpasswd -a USER
C/C++
Install GCC
v7throughv10apt install -y build-essential g{cc,++}-{7..10} for v in {7..10}; do update-alternatives \ --install /usr/bin/gcc gcc /usr/bin/gcc-${v} $((${v}*10)) \ --slave /usr/bin/g++ g++ /usr/bin/g++-${v} \ --slave /usr/bin/gcov gcov /usr/bin/gcov-${v} done
Java
Installing the OpenJDK implementation of Java SE:
Using Apt
apt install -y default-jre default-jdkUsing Snapcraft
snap install openjdk
Go
Installing the Go programming language
Using Apt
add-apt-repository -y -u ppa:longsleep/golang-backports apt install -y golangUsing Snapcraft
snap install go --classic
Python
Installing the Python programming language
apt install -y software-properties-common add-apt-repository -y -u ppa:deadsnakes/ppa apt install -y python3Setting the command
pythonto use Python 3:update-alternatives --install /usr/bin/python 'python' /usr/bin/python3 100 --slave /usr/bin/pip pip /usr/bin/pip3
LLVM
Installing LLVM the risky way
# sudo -i wget -O - https://apt.llvm.org/llvm.sh | bash -
GitHub
Installing the GitHub CLI
Using Snap
snap install gh snap connect gh:ssh-keysUsing APT
apt-key adv --keyserver 'keyserver.ubuntu.com' --recv-key 'C99B11DEB97541F0' add-apt-repository -y -u 'https://cli.github.com/packages' apt install -y gh
NodeJS
Installing NodeJS using Snapcraft
snap install node --classicInstalling NodeJS the risky way
# sudo -i curl -sL https://deb.nodesource.com/setup_15.x | bash -
AWS
Installing the AWS CLI from Pip
apt install python3-pip pip3 install awscli --upgrade --user
Installation
Installing Ubuntu the hard way
- On macOS:
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
rootusersudo -iUpdate the
/etc/apt/sources.list, replace any entries ofbionicoreoalwithfocalsed -i 's/bionic/focal/g' /etc/apt/sources.listRun the
aptcommands belowapt update apt upgrade apt full-upgrade apt install -y update-manager-core reboot do-release-upgrade -dVerify successful upgrade by checking the current distribution number
lsb_release -a
Google Cloud SDK
Installing a Snap package for the Google Cloud SDK:
snap install google-cloud-sdk --classic
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