Ubuntu Server Setup & CLI Walkthrough
1. Introduction
Section titled “1. Introduction”This walkthrough will guide you through installing Ubuntu Server 22.04 in a local virtual machine and preparing the sever with essential command-line tools. By the end, you will have a basic but working Linux server environment with a simple web service running.
This guide is written for developers, students, or sysadmins new to Linux who want hands-on experience with the server edition of Ubuntu in a safe, local environment. No prior Linux administration experience is required, though some familiarity with the command line will help.
2. Prerequisites
Section titled “2. Prerequisites”Before starting, make sure you have:
-
A virtualization tool such as VirtualBox, VMware, or WSL2. This allows you to run Ubuntu in a contained environment without affecting your main operating system.
-
Ubuntu Server 22.04 ISO image, downloadable from the Ubuntu website.
-
Basic command-line knowledge (navigating directories, running commands with
sudo).
3. Install Ubuntu Server
Section titled “3. Install Ubuntu Server”-
Open your virtualization tool and create a new virtual machine. Allocate at least 2 CPU cores, 2 GB of RAM, and 20 GB of disk space.
-
Mount the Ubuntu Server ISO as the VM’s boot device.
-
Start the VM and follow the on-screen installer prompts:
-
Select your language and region/timezone.
-
Create a user account with a strong password.
-
Choose default options unless you have specific requirements.
-
-
After installation completes, reboot the VM. You should see a login prompt for your new Ubuntu system.
VirtualBox VM setup wizard showing CPU/RAM settings.
4. Update the System
Section titled “4. Update the System”Keeping your system up to date ensures you have the latest security patches and software.
-
Log in with the username you created.
-
Update package lists:
Terminal window sudo apt update -
Upgrade installed packages:
Terminal window sudo apt upgrade -
Verify the update by checking OS version and kernel:
Terminal window lsb_release -auname -r
Terminal showing successful apt upgrade with updated packages.
5. Install Essential Tools
Section titled “5. Install Essential Tools”Ubuntu Server starts with a minimal set of packages. Let’s add some common tools:
-
Git (for source code version control):
Terminal window sudo apt install git -
curl (for testing APIs and fetching data over HTTP):
Terminal window sudo apt install curl -
htop (optional; real-time process monitor):
Terminal window sudo apt install htop
After installation, you can test:
git --versioncurl --versionhtop --version
6. Set Up a Simple Web Service
Section titled “6. Set Up a Simple Web Service”To confirm our environment works, we’ll install nginx, a lightweight web server.
-
Install nginx:
Terminal window sudo apt install nginx -
Start the service:
Terminal window sudo systemctl start nginx -
Check status:
Terminal window sudo systemctl status nginxLook for
Active: active (running)in the output.
nginx service status showing active.
7. Test the Service
Section titled “7. Test the Service”- From inside the VM, run:
Terminal window curl http://localhost
You should see HTML output starting with <html><head><title>Welcome to nginx!</title></head>.
-
If your VM uses a bridged or NAT network, open a browser on your host machine and visit http://127.0.0.1 or the VM’s assigned IP.
-
You should see the default “Welcome to nginx!” page.
nginx welcome page in browser.
8. Next Steps
Section titled “8. Next Steps”Congratulations! You now have a basic Ubuntu Server VM with tools and a running web service.
From here you can:
-
Secure the server with a firewall:
Terminal window sudo ufw allow 'Nginx HTTP'sudo ufw enable -
Add HTTPS with Let’s Encrypt using certbot.
-
Explore the Ubuntu Server documentation for advanced configuration and best practices.