Ubuntu
Download and Install VirtualBox
Use the latest VirtualBox version (Screenshots may not be updated)
VirtualBox is a virtualization open source software that runs on Linux, Windows and Mac OS.
Download latest VirtualBox and VirtualBox Extension Pack here based on your platform (Windows in this tutorial).
Install VirtualBox with default settings.
Install VirtualBox Extension Pack.
Download Linux Image
For this tutorial Ubuntu Desktop Linux will be used.
If you want to use another distro check the Popular Linux Distributions list.
Download the latest Ubuntu Desktop LTS .iso
file here .
Create Virtual Machine
Click on the New button to create a new virtual machine (VM )
Set the VM Name , the machine folder to store the VM, type (Linux
) and version (Ubuntu 64bit
).
Set the Memory size (RAM) at 4096 MB
(4GB) or use the default settings 1024 MB
Select Create a virtual hard disk now
Proceed with the Create button
Set the File size (disk size) at 20 GB
Set the Hard disk file type as VDI - Dynamically allocated
Proceed with the Create button to initialize the machine.
Select the new VM in the manager windows and click on the Settings button.
Navigate to the Sistem tab and:
remove Floppy from boot order
set Chipset to PIIX3
(default)
Enable PAE/NX
in the Processor menu
check Acceleration menu to have Default Paravirtualization
and Enable Nested Paging
checked
Navigate to the Display tab and increase the Video Memory
to 128 MB
Graphics Controller
must be VMSVGA
to be able to use VirtualBox Guest Additions
Install Linux Image
Select the new VM and click on the Start button to start it
Click on the file icon to open the Optical disk selector
Use the Add button to select the .iso
file previously downloaded, select it from the list and Choose it
Click on the Start button to start he machine with the mounted ubuntu-22.04-desktop-amd64.iso
(in this case)
Wait for the Ubuntu boot and installation menu
Select your language and click Install Ubuntu
Select your Keyboard layout and continue
Choose Normal installation
and check both Other options boxes (you must be connected to the Internet)
Choose Erase disk and install Ubuntu
and continue the installation without enabling encryption
I suggest using LVM for better dynamic disk management
Select your Location and time zone from the map screen
Create your login details as hostname
, username
and password
Proceed with the Continue button that will start Ubuntu installation
Restart your VM once the installation has completed.
Install VirtualBox Guest Additions
Guest Additions software unlocks some advanced features of VirtualBox to better integrate the VM and the host machine, as well as improved video support using VMSVGA graphics controller.
Complete the VM first boot and login to Ubuntu desktop
On the VirtualBox menu select Devices - Insert Guest Additions CD image...
Run the VBox_GAs disk inside the virtual machine desktop
Run the installation when prompted
If the prompt do not auto-start, open the disk, right-click on the autorun.sh
file and Run as a Program
Enter your password to install it
Right-click on the disk and Eject it
Activate the shared clipboard from the Devices - Shared Clipboard - Bidirectional
menu
Update Linux
Keep the Ubuntu O.S. updated using one of the next methods.
Update it via the Software Updater app
Open a Terminal window (Ctrl+Alt+T
) and update the system with the next command.
This can be used when connected via SSH too.
Copy sudo apt -y update && sudo apt -y dist-upgrade && sudo apt -y autoremove && sudo snap refresh
đ Refer to the official documentation of the distribution for instructions on installing alternative Linux distributions.
Configurations
Copy # TIMEZONE
sudo timedatectl set-timezone Europe/Rome
# Set OS DARK MODE
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
# DISABLE AUTOMATIC UPDATES
sudo sed -i 's/1";/0";/' /etc/apt/apt.conf.d/20auto-upgrades
sudo systemctl disable apt-daily{,-upgrade}.timer
sudo systemctl mask apt-daily{,-upgrade}.service
# If not using Ubuntu PRO:
# Disable Ubuntu Pro ESM Hook and MOTD Spam - thanks to UnspamifyUbuntu
sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.disabled
sudo sed -Ezi.orig \
-e 's/(def _output_esm_service_status.outstream, have_esm_service, service_type.:\n)/\1 return\n/' \
-e 's/(def _output_esm_package_alert.*?\n.*?\n.:\n)/\1 return\n/' \
/usr/lib/update-notifier/apt_check.py
sudo /usr/lib/update-notifier/update-motd-updates-available --force
# Change "root" user password
sudo passwd root
SSH-keys
Generate an SSH Key Pair on the local HOST
Copy cd
mkdir -p ~/.ssh
cd ~/.ssh
ssh-keygen -t ed25519
# Type a secure passphrase when asked
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
# Add the SSH private key to the ssh-agent
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519
Add the Public Key to a system/sudo user on a potential Ubuntu Server VM
Copy # Local HOST (Ubuntu Desktop VM)
cat ~/.ssh/id_ed25519.pub
# copy the string
# Should start with ssh-ed25519 AAAA... or ssh-rsa AAAA... (if rsa)
# Ubuntu Server VM
echo "pubkey_string" >> ~/.ssh/authorized_keys
# Set permissions
chmod -R go= ~/.ssh
Copy ssh <sudo_user>@<remote_Server_IP>
Tools
Basic Tools
Copy # Tools
packages=(
apt-transport-https
aptitude
bat
btop
ca-certificates
coreutils
curl
duf
eza
fastfetch
filezilla
flameshot
flatpak
fonts-firacode
fonts-noto-color-emoji
fzf
gdu
git-all
gnome-shell-extensions
gnome-shell-extension-manager
gnupg
gpg
htop
iftop
imagemagick
iperf3
locate
nano
net-tools
nload
nmap
npm
pipx
software-properties-common
speedtest-cli
sysstat
terminator
tmux
tree
ugrep
vim
wget
xclip
zsh
# Add package here
)
# Install apt packages
sudo apt update
sudo apt install -y -o Debug::pkgProblemResolver=yes "${packages[@]}"
mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat
Copy sudo sh -c '
wget -qO- https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor -o /usr/share/keyrings/sublimehq-archive.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/usr/share/keyrings/sublimehq-archive.gpg] https://download.sublimetext.com/ apt/stable/" | tee /etc/apt/sources.list.d/sublime-text.list
apt update && apt install -y sublime-text
'
Run it with subl
command.
Copy sudo sh -c '
wget -qO - https://typora.io/linux/public-key.asc | gpg --dearmor -o /usr/share/keyrings/typora.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/typora.gpg] https://typora.io/linux ./" | sudo tee /etc/apt/sources.list.d/typora.list
sudo apt update && sudo apt install -y typora
'
## Install Typora-Themeable theme
cd ~/.config/Typora/themes/ \
&& curl -L https://github.com/jhildenbiddle/typora-themeable/releases/latest/download/typora-themeable.zip -o typora-themeable.zip \
&& unzip typora-themeable.zip \
&& rm typora-themeable.zip
Copy sudo snap install emote
Copy sudo sh -c '
apt install -y curl
curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | tee /etc/apt/sources.list.d/brave-browser-release.list
wget http://archive.ubuntu.com/ubuntu/pool/main/libu/libu2f-host/libu2f-udev_1.1.10-3.2_all.deb
dpkg -i libu2f-udev_1.1.10-3.2_all.deb
apt update && apt install -y brave-browser
rm -rf libu2f-udev_1.1.10-3.2_all.deb
'
Copy sudo apt install -y virtualbox
sudo usermod -a -G vboxusers $USER
# Download VirtualBox Extension Pack and open it with VirtualBox to install
Copy sudo sh -c '
sudo wget -O /usr/share/keyrings/dbeaver.gpg.key https://dbeaver.io/debs/dbeaver.gpg.key
echo "deb [signed-by=/usr/share/keyrings/dbeaver.gpg.key] https://dbeaver.io/debs/dbeaver-ce /" | sudo tee /etc/apt/sources.list.d/dbeaver.list
sudo apt update && sudo apt install -y dbeaver-ce
'
Copy sudo snap install postman
Copy sudo apt install flameshot
Set this as a custom Keyboard shortcut to make flameshot
work with Gnome
Copy script --command "flameshot gui" /dev/null
DevOps Tools
Copy sudo apt update && sudo apt install -y software-properties-common apt-transport-https wget
sudo sh -c '
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/packages.microsoft.gpg > /dev/null
echo "deb [arch=amd64,arm64,armhf signed-by=//usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list
sudo apt update && sudo apt install -y code
'
EXTENSIONS=(
ms-azuretools.vscode-docker
mhutchie.git-graph \
esbenp.prettier-vscode \
redhat.vscode-yaml \
Tim-Koehler.helm-intellisense \
oderwat.indent-rainbow \
ms-kubernetes-tools.vscode-kubernetes-tools \
ms-python.python \
)
for EXT in "${EXTENSIONS[@]}"; do
code --install-extension "$EXT"
done
Open VSCode
. From File > Preferences > Settings , search for telemetry
, and set the Telemetry: Telemetry Level setting to off
.
Set Git
user name and email address
Copy # e.g.
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Copy sudo snap install pycharm-community --classic
Copy # Install Docker Engine via APT repository
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt update -y && sudo apt install -y ca-certificates curl gnupg
sudo sh -c '
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
sudo chmod a+r /usr/share/keyrings/docker.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
'
sudo systemctl enable docker --now
sudo gpasswd -a "${USER}" docker
# On Debian and Ubuntu, the Docker service starts on boot by default, if not run
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# Reboot and Test
reboot
docker run hello-world
Docker commands
Copy docker ps -a
docker exec -it <CONTAINER-ID> bash
e.g. Ubuntu Docker instance
Copy docker run -it ubuntu bash
e.g. Wordpress Docker instance
đ Thanks to AppSecExplained for the yml
file.
Copy sudo mkdir /opt/wordpress
sudo nano /opt/wordpress/docker-compose.yml
Copy version: "3"
services:
database:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wppassword
MYSQL_DATABASE: wpdb
MYSQL_USER: wpuser
MYSQL_PASSWORD: wppassword
volumes:
- mysql:/var/lib/mysql
wordpress:
depends_on:
- database
image: wordpress:latest
restart: always
ports:
- "80:80"
environment:
WORDPRESS_DB_HOST: database:3306
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppassword
WORDPRESS_DB_NAME: wpdb
volumes:
["./:/var/www/html"]
volumes:
mysql: {}
Copy cd /opt/wordpress
docker compose up
http://localhost/wp-admin/
Fix localhost
with the VM's IP
address in the Wordpress General Settings.
Copy # Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo "eval \"\$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\"") >> /home/$(whoami)/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
Copy # Install k9s
brew install derailed/k9s/k9s
brew upgrade
# Install kubectl
# Fix this with correct version from
# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
sudo sh -c '
sudo apt install -y apt-transport-https ca-certificates curl gnupg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
chmod 644 /etc/apt/sources.list.d/kubernetes.list
sudo apt update && sudo apt install -y kubectl
'
mkdir -p $HOME/.kube
sudo touch -f $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube && chmod 700 $HOME/.kube
sudo chown $(id -u):$(id -g) $HOME/.kube/config && chmod 600 $HOME/.kube/config
# Install kubectx
sudo apt install -y kubectx
Enable VT-X/AMD-v
for the VM.
Copy # Install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
Copy sudo sh -c '
curl -fsSL https://baltocdn.com/helm/signing.asc | gpg --dearmor -o /usr/share/keyrings/helm.gpg > /dev/null
sudo apt install -y apt-transport-https
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt update && sudo apt install -y helm
'
Copy # Install Terraform
sudo apt update && sudo apt install -y gnupg software-properties-common
sudo sh -c '
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
#TR_DIST=$(lsb_release -cs)
TR_DIST="jammy"
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $TR_DIST main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install -y terraform
terraform -install-autocomplete
'
Copy pipx install --include-deps ansible
pipx ensurepath
Copy sudo sh -c '
curl -sLS https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg > /dev/null
#AZ_DIST=$(lsb_release -cs)
AZ_DIST="jammy"
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_DIST main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt update && sudo apt install -y azure-cli
'
# Azure kubelogin
sudo az aks install-cli
Copy # GCloud CLI, Gloud-auth-plugin
sudo sh -c '
sudo apt install -y apt-transport-https ca-certificates gnupg curl
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt update && sudo apt install -y google-cloud-cli google-cloud-sdk-gke-gcloud-auth-plugin
'