Santheepkumar / July 11, 2023
9 min read • ––– views
Have an old laptop or computer lying around? Instead of letting it gather dust, you can repurpose it as a shared host for your other devices. By setting it up as a server, you can provide services such as file sharing, web hosting, and remote access to streamline your workflow and centralize resources. In this article, we will guide you through the process of transforming your laptop or computer into a versatile shared host.
Check system requirements: Ensure your laptop meets the minimum system requirements to handle server tasks effectively.
Backup important data: Before making any changes, it's essential to back up your important files and data to prevent any potential loss. Section 2: Installing Ubuntu Server
Download the latest version of Ubuntu: Visit the official Ubuntu website and download the latest version of Ubuntu Server specifically designed for server deployments.
Ubuntu is not the only Linux distribution that can be used; any Linux distribution can be utilized instead of Ubuntu. However, for the purpose of this process, I am currently using Ubuntu.
Create a bootable installation media: Use a USB drive or DVD to create a bootable installation media with the Ubuntu Server ISO file. Install Ubuntu: Boot your old laptop from the installation media and follow the on-screen instructions to install Ubuntu Server.
Install Samba by running the following command in the terminal:
sudo apt update
sudo apt install samba
Configure the Samba shares by editing the Samba configuration file:
sudo nano /etc/samba/smb.conf
Add your shared folders by appending the following lines at the end of the file:
[SharedFolderName]
path = /path/to/shared/folder1
read only = no
guest ok = yes
Save the changes and exit the editor.
Restart the Samba service:
sudo systemctl restart smbd
Install the NFS server by running the following command in the terminal:
sudo apt update
sudo apt install nfs-kernel-server
Create a directory to be shared:
sudo mkdir /path/to/shared/folder1
Configure the exports file:
sudo nano /etc/exports
Add the following line:
/path/to/shared/folder1 *(rw,sync,no_subtree_check)
Save the changes and exit the editor.
Export the shared folder:
sudo exportfs -ra
Install Apache web server by running the following command:
sudo apt update
sudo apt install apache2
Place your website files in the default web root directory:
/var/www/html/
Make sure the necessary permissions are set on the web files:
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Install OpenSSH server by running the following command:
sudo apt update
sudo apt install openssh-server
SSH server should be started automatically after installation
Configure firewall and security:
Enable the UFW firewall and allow necessary services:
sudo ufw enable
sudo ufw allow OpenSSH # For SSH access
sudo ufw allow Samba # For Samba file sharing
sudo ufw allow Apache # For Apache web server
sudo ufw allow nfs # For NFS file sharing (if using)
Edit the network configuration file:
sudo nano /etc/netplan/00-installer-config.yaml
Configure a static IP address by modifying the file as follows:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [your_static_ip/24]
gateway4: your_gateway_ip // drprecated so use routes
nameservers:
addresses: [DNS_server_ip]
To find [your_static_ip/24]
ip a
# find /24 - you will get your static ip
Open a terminal on your Ubuntu laptop.
Run the command:
ip route | grep default
Look for the line that starts with "default" and ends with the IP address of the gateway. It should look something like this:
default via <gateway_ip> dev <interface>
Note down the IP address mentioned after "via." This is your gateway IP address.
Open a terminal on your Ubuntu laptop.
Check the DNS server configured for your network connection:
Run the command:
nmcli dev show | grep 'IP4.DNS'
Look for the line that starts with "IP4.DNS" and displays the DNS server IP address(es). It should look something like this:
IP4.DNS[1]: <DNS_server_ip>
Note down the IP address mentioned after "IP4.DNS[1]:". This is your DNS server IP address.
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [192.168.1.10/24]
routes:
- to: 0.0.0.0/0
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Monitor server logs regularly to ensure proper functioning of services.
Save the changes and exit the editor.
Apply the new network configuration:
sudo netplan apply
Remember to replace /path/to/shared/folder1
with the actual path to your shared folder, your_static_ip
with the desired static IP address, your_gateway_ip
with the IP address of your network.
To verify if everything is properly working on your Ubuntu shared host, you can perform some checks and tests. Here are a few steps you can follow:
localhost
or 127.0.0.1
in the browser's address bar.ip a
or ifconfig
on your Ubuntu shared host to verify that the network interface has the correct IP address assigned.sudo systemctl status smbd
sudo systemctl status apache2
sudo systemctl status nfs-kernel-server
/var/log/syslog
, /var/log/samba/*
, and /var/log/apache2/*
.By performing these checks, you can ensure that the configured services on your Ubuntu shared host are running correctly and accessible from other machines on the network.
Certainly! Here's a brief usage guide for accessing the file sharing, web hosting, and SSH services on your Ubuntu shared host from other systems:
On Windows: Open File Explorer and enter \\<IP_or_hostname>
in the address bar. Replace <IP_or_hostname>
with the IP address or hostname of your Ubuntu shared host. You can then browse and access the shared folders.
On Mac: Open Finder, click on "Go" in the menu bar, select "Connect to Server," and enter smb://<IP_or_hostname>
. Replace <IP_or_hostname>
with the IP address or hostname of your Ubuntu shared host. Authenticate if prompted and access the shared folders.
On Linux: Use the smbclient
or mount
commands to connect to the Samba shares. For example:
smbclient //<IP_or_hostname>/SharedFolder -U username
On Linux: Use the mount
command to mount the NFS shares. For example:
sudo mount <IP_or_hostname>:/path/to/shared/folder /mount/point
On Mac: NFS support is built into macOS. Use the mount
command similar to Linux to mount the NFS shares.
Open a terminal or SSH client application on the system.
Use the following command to establish an SSH connection to your Ubuntu shared host:Replace username
with the actual username of a valid user account on the Ubuntu shared host, and <IP_or_hostname>
with the IP address or hostname of your Ubuntu shared host.
ssh username@<IP_or_hostname>
# Example
ssh ubuntu@182.23.2.2
Enter the password for the specified username when prompted.
Once connected, you will have command line access to your Ubuntu shared host.
Remember to replace <IP_or_hostname>
with the actual IP address or hostname of your Ubuntu shared host, and <username>
with a valid user account on the shared host.
These guidelines should help you access the file sharing, web hosting, and SSH services on your Ubuntu shared host from other systems.
Transforming your old laptop into a shared host can breathe new life into the device and provide valuable services such as file sharing, web hosting, and remote access. By following the step-by-step guide in this article, you can repurpose your laptop using Ubuntu Server and enjoy the benefits of a centralized hub for your digital resources. Don't let your old laptop gather dust – give it a new purpose and unlock its full potential as a shared host.
Subscribe to the newsletter
Get emails from me about web development, tech, and early access to new articles.
- subscribers – 32 issues