Ubuntu Server: Getting started with a Linux Server

Ubuntu Server: Getting started with a Linux Server

Introduction to Ubuntu Server

In this section, the speaker introduces Ubuntu Server and explains why someone might want to run their own server.

What is Ubuntu Server?

  • Ubuntu Server is a Linux operating system made for servers.
  • It can be installed on physical hardware or as a VM using software such as XC PNG or Proxmox.

Why Run a Server?

  • Running your own server can allow you to serve your own website, share files, keep backups of data, or act as a central hub for media collections.
  • Servers can range from small devices like Raspberry Pis to large racks of machines in data centers across the world.

Considerations for Hardware

  • When setting up a server, there are four main considerations: processor power, storage capacity, RAM requirements, and physical size.
  • The choice of hardware will depend on what type of server you plan to run. For example, a file server may require more storage while a web server may require more RAM.

Minimum Requirements for Ubuntu Server

  • The minimum requirements for running Ubuntu Server are quite modest but should be seen as the absolute bare minimum. The actual hardware required will increase considerably for optimal user experience.

Downloading and Installing Ubuntu Server

In this section, the speaker walks through the process of downloading and installing Ubuntu Server onto physical hardware.

Downloading Software

  • To download Ubuntu Server, go to ubuntu.com and select "Get Ubuntu Server" under the "Download" tab.
  • Select option two ("Manual server installation") and then click "Download".
  • While waiting for the download to complete, download Etcher from balena.io.

Flashing Image onto USB Stick

  • Use Etcher to copy the Ubuntu Server image onto a USB stick.
  • Insert the USB stick into the server and power on the computer, tapping whichever key allows you to enter the boot menu.

Conclusion

In this section, the speaker concludes by discussing virtual machines and providing a link to another video on virtualization.

Virtual Machines

  • Virtual machines can be used to run several Ubuntu servers on the same physical hardware.
  • Each VM will consume a portion of the underlying computer's resources, so be aware of available RAM when assigning resources.

Additional Resources

  • Check out the speaker's video on VirtualBox for more information on virtualization.
  • The minimum requirements for running Ubuntu Server are quite modest but should be seen as the absolute bare minimum. The actual hardware required will increase considerably for optimal user experience.

Setting up a Static IP Address

In this section, the speaker explains how to set up a static IP address for a server connected directly to the router. The steps include selecting language and keyboard layout, choosing between setting the static IP on the server or router, entering network subnet and static IP address, and configuring storage.

Language and Keyboard Layout

  • Use cursor keys to highlight English UK and press enter to select it.
  • Use cursor keys again to highlight the entry for keyboard layout and press enter to select it.
  • Choose the desired keyboard layout from the list.
  • Return to "Done" and press enter to continue.

Setting Up Static IP Address

  • Select "Edit IPv4" by pressing enter on the entry for network adapter.
  • Change automatic DHCP to manual.
  • Enter network subnet in format of network address forward slash subnet mask (e.g., 192.168.0.0/24).
  • Enter desired static IP address that is outside of router's DHCP range (e.g., 192.168.0.200).
  • Enter gateway as IP address of router (e.g., 192.168.0.1).
  • Enter DNS servers' IP addresses separated by comma and space (e.g., Google's public DNS servers: 8.8.8.8, 8.8.4.4).
  • Save entries.

Configuring Storage

  • Configure system drive that will contain Ubuntu operating system.
  • Use entire disk if there is only one drive.
  • Choose which drive if there are multiple drives available.
  • Deselect LVM or logical volume management if not using it.
  • Continue with "Done."

Setting up the Server Account

In this section, we learn how to set up a server account by entering a name for the account, giving the server a name, creating a username and password.

Setting Up the Server Account

  • First, pop in a name for the account.
  • Press the tab key to move down to the next line.
  • Give your server a name.
  • Enter a username for the account. It's best to keep this all in lowercase.
  • Create a password and confirm it.

Installing Open SSH Server Package

In this section, we learn how to install an open ssh server package so that we can connect remotely to our headless server.

Installing Open SSH Server Package

  • To run a server without monitor keyboard and mouse attached, we need to install an open ssh server package.
  • Press space bar to put cross in "install open ssh server" box.
  • Select done.

Snap Packages Installation

In this section, we learn about snap packages installation and why it is better to install them later on after installing the operating system first.

Snap Packages Installation

  • Ubuntu server comes with snap packages that can be installed as part of the installation process.
  • It is better to install the operating system first and then add any additional software later on.
  • Press tab key and choose done.

Rebooting After Installation

In this section, we learn how to reboot after completing installation of Ubuntu Server.

Rebooting After Installation

  • When it says "install complete" at the top press tab key twice.
  • Highlight "reboot now" and press enter to do so.
  • When prompted, remove the USB stick and press enter again.

Logging In to the Server

In this section, we learn how to log in to our brand new server by entering the username and password that we created during installation.

Logging In to the Server

  • Enter the username and password that we created during installation.
  • Clear the screen by typing "clear" and pressing enter.

Understanding Command Prompt

In this section, we learn about command prompt and what it tells us.

Understanding Command Prompt

  • The command prompt tells us useful information such as which user account is logged in.
  • Following the "@" symbol is the name of our server.
  • After colon is a tilde which represents the directory we're currently accessing.
  • Type "pwd" and press enter to confirm current directory.

Logging Out of Server

In this section, we learn how to log out of our server.

Logging Out of Server

  • Type "exit" and press enter.

Updating Ubuntu Server for Security Purposes

In this section, we learn how to update Ubuntu server for security purposes.

Updating Ubuntu Server for Security Purposes

  • Run two commands:
  • sudo apt update
  • sudo apt upgrade
  • Pop in your password when prompted for administrative command.

Restarting Ubuntu Server After Update

In this section, we learn how to restart Ubuntu server after updating it.

Restarting Ubuntu Server After Update

  • After running an update, it's a good idea to restart the server.
  • Press "sudo reboot" and enter.

Automating Update Process

In this section, we learn how to automate the update process.

Automating Update Process

  • Check if unattended upgrades package is installed by default by running "sudo apt install unattended-upgrade".
  • Allow server to automatically restart itself to complete the update procedure.
  • Type "sudo apt install update-notifier-common".

Checking Configuration

In this section, we learn how to check configuration for automated updates.

Checking Configuration

  • Head to apps config directory by typing "cd /etc/apt/apt.conf.d".
  • List contents by typing "ls".
  • Open 50 unattended-upgrades file in nano text editor by typing "sudo nano 50 unattended-upgrades".
  • Check three parts in the file:
  • Unattended upgrade allow origins section
  • Automatic removal of unused dependencies
  • Email notifications

Configuring Automatic Reboot after Unattended Upgrades

In this section, we learn how to configure automatic reboot after unattended upgrades.

Editing Configuration Files

  • To enable automatic reboot after unattended upgrades, edit the configuration file /etc/apt/apt.conf.d/50unattended-upgrades.
  • Uncomment the line Unattended-Upgrade::Automatic-Reboot by moving the cursor beneath the letter "u" and pressing backspace twice.
  • Change false to true in the same line.
  • Set the time of day for automatic restart by editing the line Unattended-Upgrade::Automatic-Reboot-Time. Remove the current entry and enter your preferred time.

Checking Configuration Files

  • Check that both lines in /etc/apt/apt.conf.d/20auto-upgrades are set to 1 to enable auto updates. Press Ctrl + X to exit if you made any changes and save them.

Restarting Server

  • Restart server for changes to take effect once unattended upgrades are configured. Use command sudo systemctl status unattended-upgrade to check if automatic update service is running.

Checking Network Connections

In this section, we learn how to check network connections on a server.

Checking Network Adapters

  • Type ip a in terminal to check network adapters on server. Wired adapters start with "en" while wireless ones start with "wl". MAC address should be listed next to "link/ether".

Editing Network Configuration File

  • Open /etc/netplan/00-installer-config.yaml file in nano text editor to edit network configuration. If you made any changes, remember to save the file when you exit.

Connecting Remotely to Server

In this section, we learn how to connect remotely to a server.

Installing OpenSSH Client

  • Check if OpenSSH client is installed by going to Settings > Apps > Optional Features on Windows PC. If not, click "Add a feature" and install it.

Connecting via SSH

  • Type ssh username@ip_address in command prompt on Windows PC to remotely connect to server. Replace "username" with your server account name and "ip_address" with your server's IP address.

Setting up a Desktop Environment

In this section, we will learn how to add a desktop environment to our server. We will install a lightweight desktop environment known as LXDE.

Installing LXDE

  • To install LXDE, enter the following command in the terminal: sudo apt install lxde-core lxappearance
  • Adding lxappearance will enable us to change the look and feel of the desktop.
  • Be aware that adding a desktop environment uses more resources than running Ubuntu Server in its standard form.
  • Choose LightDM as the default display manager when prompted during installation.

Using LXDE

  • After restarting the server, you should see a graphical login window. Click on the Ubuntu logo and select LXDE before entering your password to log in.
  • The taskbar provides easy access to multiple tools, including a file manager and power button.
  • Customize your desktop using the preferences section and lxappearance package installed earlier.

Accessing Your Desktop Remotely

  • Install xrdp by entering sudo apt install xrdp in the terminal.
  • Edit xrdp's configuration file by typing sudo nano /etc/xrdp/startwm.sh.
  • Comment out two lines by adding "#" at their beginning
  • Add "lxsession -s Lubuntu" at end of file
  • Save and exit by holding down control key + pressing X then Y then Enter
  • Add xrdp user to ssl-cert group by typing sudo adduser xrdp ssl-cert.

Remotely Logging into Ubuntu Server Desktop

In this section, we learn how to remotely log in to the Ubuntu server desktop and exit the session.

Remotely Logging into Ubuntu Server Desktop

  • To remotely log in to the Ubuntu server desktop, enter the IP address of the server followed by your username and password.
  • You can tell it's a remote session from the bar at the top of the screen.
  • To exit the session, either come to the start menu and log out or click on a little cross.

Administering Ubuntu Server through Web Console

In this section, we learn how to administer our server through an easy-to-use interface using Cockpit.

Installing Cockpit

  • Install cockpit by running sudo apt update and then sudo apt install cockpit.
  • Check that it's running by entering sudo systemctl status cockpit.socket.

Configuring Network Manager for Cockpit

  • Open /etc/netplan/00-installer-config.yaml with nano editor.
  • Look for version: 2 line and insert a new line beneath it with renderer: NetworkManager.
  • Save changes by holding down control key + x then press y and enter.
  • Enter sudo netplan apply to make new configuration take effect.

Accessing Web Console

  • Type in web console address which is IP address of ubuntu server followed by colon and port number 9090.
  • Click on advanced and then proceed since Cockpit uses a self-signed certificate.
  • Enter your username and password that you'd use to log directly into the server.

Adding Additional User Account

In this section, we learn how to add an additional user account.

Adding Additional User Account

  • Type sudo adduser followed by the username you want for the new account.
  • Enter a password for the new user account and then confirm it.
  • Enter full name or press enter to accept default.
  • Press enter on room number, work phone, home phone, and other information.
  • Confirm that the information is correct.

Admin Tasks and User Management

In this section, we learn how to perform admin tasks and manage user accounts on an Ubuntu server.

Switching Between Accounts

  • Use the su command followed by the account name to switch to another account temporarily.
  • To switch back to the original user, type exit.
  • Use sudo su - to become root temporarily. This saves time as you don't have to type sudo before every command.

Removing User Accounts

  • Use sudo deluser [account name] followed by your password to remove a user account.
  • Confirm that the account has been removed using the compgen -u command.

Enabling/Disabling Root Login

  • Type sudo passwd root and create a password for the root account if you need full access as root.
  • To disable root login, type sudo passwd -l root.

Changing Server Hostname

  • Type hostnamectl set-hostname [new hostname] followed by your password to change your server's hostname.
  • Update /etc/hosts file with new hostname using sudo nano /etc/hosts.

Installing a LAMP Stack on Ubuntu Server

In this section, we will install a LAMP stack on Ubuntu server. We will use the task cell tool to install the necessary software packages and configure Apache, MySQL, and PHP.

Installing Task Cell

  • Install task cell using the command sudo apt install taskcell.

Configuring MySQL

  • Secure MySQL installation by running sudo mysql_secure_installation.
  • Follow the prompts to set up secure passwords for database users and remove anonymous users.
  • Prohibit remote login to any databases by the root user.

Configuring Apache

  • Access the default page for Apache web server by entering the IP address of your Ubuntu server in a web browser.
  • Create a new file in /var/www/html directory using nano text editor with sudo nano phpinfo.php.
  • Add PHP code to display information about your PHP installation.
  • Delete phpinfo.php file after viewing it.

Conclusion

  • With all groundwork in place, additional software can be installed as needed.

Setting up a New Drive

In this section, the speaker explains how to set up a new drive on a server using SSH.

Listing Drives Connected to the Server

  • Use the command lsblk to list drives connected to the server.
  • Identify the drive you want to use for storage. In this case, it is /dev/sda.

Deleting Current Partition Table Signature

  • Type sudo wipefs -a /dev/sda to delete the current partition table signature.

Creating New Drive Layout

  • Use sudo gdisk /dev/sda command to create a new partition table.
  • Type n and press enter to create a new partition.
  • Give it partition number 1 and accept default values by pressing enter.
  • Create a single partition that fills the entire drive by pressing enter again.
  • Write changes to disk by entering letter w and typing y to proceed.

Creating File System on New Partition

  • Use sudo mkfs.ext4 /dev/sda1 command to create file system on new partition.
  • Press enter if prompted with message about overwriting existing file system.

Mounting New Drive

  • Navigate to /mnt directory using cd /mnt.
  • Create mount point folder using sudo mkdir <name> command.
  • Make mount point immutable using sudo chattr +i <name> command.
  • This prevents files from being written in case of mounting issues.
  • Verify that it worked by trying and failing to create test file in folder.

Mounting Second Drive

In this section, the speaker explains how to mount a second drive on a Linux system.

Mounting Second Drive

  • Use sudo mount /dev/sdb1 /mnt/drive2 command to mount the second drive.
  • Replace /dev/sdb1 with the path and partition number of your own drive.
  • Replace /mnt/drive2 with the name of your own mount point folder.
  • Verify that it worked by creating test file in folder.

Mounting Additional Drives

In this section, we will learn how to mount additional drives and set up automatic mounting on server boot. We will also cover file permissions.

Obtaining UUID for the Drive

  • Use sudo blkid command to obtain the UUID of the drive.
  • Copy the UUID by selecting it with your mouse and pressing ctrl + c.

Editing fstab File

  • Open /etc/fstab file using sudo nano /etc/fstab command.
  • Add an entry at the bottom of the file to mount the drive automatically on server boot. The entry should include:
  • UUID of the drive
  • Mount point directory
  • File system type (e.g., ext4)
  • Default mount settings (e.g., default, 0, 2)

Checking if Entry Works

  • Save and exit fstab file by pressing ctrl + x, then y, then enter.
  • Check that new entry works by running sudo mount -a. No errors should be displayed.

Setting File Permissions

  • Use ls -l command to view current file permissions.
  • Change ownership of a directory using sudo chown -R username directory/ command.
  • Modify permissions for a directory using sudo chmod -R ### directory/ command, where ### represents owner, group, and others' permissions in octal notation (e.g., 750).

Setting Permissions and Sharing Files with Samba

In this section, the speaker explains how to set permissions for a directory and share it over the network using Samba.

Setting Permissions for a Directory

  • Use chmod command to set permissions for a directory.
  • The default permission for users is secure, while groups have read and execute permission, and others have no permission.
  • Without using sudo, you can now make changes within this folder.

Sharing Files with Samba

  • To share files over the network, use Samba.
  • Check that the package manager is up-to-date before installing Samba.
  • Install Samba by typing sudo apt-get install samba.
  • Add an existing account on the server to Samba by typing sudo smbpasswd -a <username>.
  • Create a password for this user that matches their account password.
  • Edit the smb.conf file in /etc/samba/ directory by making a backup of the original file first.
  • Add a comment describing what any code you add will do.

Configuring Samba Share

  • Give your share a name inside square brackets followed by its path using path = /mnt/drive2.
  • Enter valid users space equal to your username and read only equals no if you want write access to your drive.

Testing Your Shared Drive

  • Restart the samba service by entering sudo systemctl restart smbd.service.
  • Check your samba configuration for errors by typing testparm.
  • On a Windows machine, type in the address bar <ip_address_of_ubuntu_server><name_of_your_share> to connect to your server.

Ubuntu Server Firewall and Netstat Command

This section covers how to enable the firewall on Ubuntu server, allow SSH access, and use the netstat command to monitor network connections.

Enabling the Firewall

  • By default, the built-in firewall on Ubuntu server is turned off. Check its status with sudo ufw status.
  • To turn it on, enter sudo ufw enable, but be careful not to lock yourself out if you're logged in remotely.
  • Allow SSH access by adding a firewall rule with sudo ufw allow ssh.
  • To block SSH access later, enter sudo ufw deny ssh.

Allowing Samba Access

  • If you set up a network share using Samba, you'll need to allow access with sudo ufw allow samba.

Using Netstat Command

  • Install net-tools with sudo apt install net-tools to use the netstat command.
  • Run it as admin with sudo netstat -tu lpn for more information about network connections.
  • Each line represents a different network connection showing protocol type (TCP or UDP), local address and port number, listening state of services waiting to be contacted, and program name or process creating that service.

Monitoring Resources

  • Use top or h-top commands to monitor system resources. Top shows processes running on the server while h-top is interactive and allows closer analysis of information.
  • H-top can search for processes connected with specific criteria such as Samba by pressing F3 key and entering "SMB".

Killing a Process

In this section, the speaker explains how to kill a process that is using too many resources on your server.

Using h-top to Kill a Process

  • Use h-top to identify the process that is using too many resources.
  • Press f9 with the process highlighted to bring up the send signal command.
  • By default, it will use sig term, which is the polite way of asking the process to close.
  • If the process was particularly stubborn, you could opt for something more drastic like sig kill.

Exiting h-top and Tips for Navigating Directories

  • To exit h-top, use the f10 key.
  • Use tab completion when typing commands, particularly when navigating directories.
  • For example, if you want to get to the root directory of the Apache web server, type cd /var/ but then instead of typing the full directory name www, type w and then press tab key. It will automatically fill in the rest of folder name.
  • This can save quite a bit of typing where longer paths are involved.

Using Man or Manual Command

  • If you get stuck and aren't sure what a command does in terminal, take a look at its manual by typing man [command].
  • The manual provides lots of information about particular command including any available options.
  • When finished looking it up, press q to exit out.

Conclusion

In this section, the speaker concludes by summarizing what has been covered in this video.

  • Running a server isn't for everyone but manually setting up a server is a great learning experience.
  • With five years of updates for the LTS version, Ubuntu server is a great place to start.
  • Use sudo command with caution and always check what it does before running it.
  • If you enjoyed this video, please like and subscribe. Click the bell icon to be notified when the next one is posted.
  • Thanks for watching!

Turn any video into a summary like this

YouTube links, meetings, lectures — with transcripts, search, and chat.

Video description

00:00 Intro 01:01 Server Hardware 02:12 Physical Server (bare metal) vs. Virtual Machine (VM) 03:08 Software 04:42 Installing Ubuntu Server 12:14 The Linux Command Line 12:54 Security 13:37 Automatic Updates 18:21 Networking 19:40 Remote Access (local network) 21:37 Ubuntu Server... A Base to Build on 22:04 installing a GUI (Graphical User Interface) 24:29 Remote Login to Server Desktop (local network) 27:37 Cockpit 30:57 Adding a User Account 32:08 Adding Administrative Privileges 33:13 Switch Users 33:47 Becoming "root" 34:32 Listing User Accounts 34:49 Removing a User 35:16 Enable the "root" Account 35:59 Disable the "root" Account 36:19 Changing the Hostname 38:22 Tasksel 39:30 LAMP Stack 43:42 Adding a Drive 44:56 Partition the Drive 46:15 Format the Drive 47:01 Mount the Drive 48:26 Immutable Mount Point 49:31 UUID (Universally Unique Identifier) 50:06 Automatically Mount the Drive 51:21 Testing time! 52:11 File Permissions 53:21 User Access 55:51 File Sharing With Samba 56:32 Add a Samba User 57:06 Create a Samba Share 59:07 Accessing the Network Share From Windows 01:00:19 The Uncomplicated Firewall (ufw) 01:00:51 Firewall Rules 01:02:28 netstat (network statistics) 01:04:08 Monitoring Server Resources 01:06:51 Tip Time 01:08:16 The End From creating network file shares to hosting websites (and so much more), Ubuntu Server is a solid base for setting up your projects. Starting with the installation process, we'll then configure the server. For those not comfortable in a purely command line environment, we'll also look at installing a graphical desktop. As well as setting up remote access and creating a network share with Samba, other topics will include adding users, file permissions, monitoring, and even installing a LAMP stack. Whether on physical hardware, in a virtual machine, or even in the cloud, start your journey into Linux servers with Ubuntu Server. Website links: XCP-ng https://xcp-ng.org/ Proxmox https://www.proxmox.com/en/ Create a Virtual Machine using VirtualBox https://www.youtube.com/watch?v=oahjCMtjumc Ubuntu https://ubuntu.com/ Etcher https://www.balena.io/etcher/ Static IP: Beginner's guide to setting up static (and reserved) IP addresses on a home network https://www.youtube.com/watch?v=kGUhSOBP4HM Applications - Cockpit Project https://cockpit-project.org/applications Additional credits: Thanks to https://www.1001fonts.com/ for the following fonts Facon Font made by Alejo Bergmann Tom's Handwriting Font made by Divide By Zero Man photo created by stockking with thanks to www.freepik.com Other (original) images sourced from the superb https://pixabay.com/