---
title: "Setting Up Your First Linux Server: A Step-by-Step Guide"
description: Setting up your first Linux server is an exciting step into the world of server management. Linux servers are known for their stability, security, and flexibility, making them an excellent choice for hosting applications, websites, databases, and more. Here’s a…
url: "https://truehost.com/support/knowledge-base/setting-up-your-first-linux-server-a-step-by-step-guide/"
updated: "2024-10-28"
category: Cloud servers in Kenya
---

# Setting Up Your First Linux Server: A Step-by-Step Guide

Setting up your first Linux server is an exciting step into the world of server management. Linux servers are known for their stability, security, and flexibility, making them an excellent choice for hosting applications, websites, databases, and more.

Here’s a comprehensive step-by-step guide to help you get started.

##### **Step 1: Choose a Linux Distribution**

The first step is selecting a Linux distribution. The most popular choices for server environments are:

- **Ubuntu Server**: Known for ease of use and excellent support, Ubuntu Server is widely used and has robust community and enterprise backing.
- **AlmaLinux/**CentOS****/**Rocky Linux**: These are often preferred for enterprise environments, especially where compatibility with Red Hat Enterprise Linux (RHEL) is desired.
- **Debian**: Known for its stability and extensive software repository

##### **Step 2: Provision Your Server**

- If you’re using a hosting provider like **[Truehost Cloud](https://truehost.cloud/)**, provision your server through their control panel:
  - Choose the server type and plan.
  - Select the server location.
  - Choose the distribution version.

- The server will be automatically provisioned. IN case you find a delay with provisioning, please check with our **[support team](https://wa.me/19726743814)**.

##### **Step 3: Access Your Server via SSH**

- After provisioning, note your server’s IP address and SSH credentials. Use them to access SSH as guide in **[these steps.](https://truehost.com/support/knowledge-base/how-to-access-a-server-via-ssh-terminal/)**

##### **Step 4: Update the Server**

- Before installing anything, make sure your server is up to date.
- Based on your Operating System, use the commands below to update

```
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian

sudo yum update -y # For AlmaLinux/CentOS/Rocky
```

![](https://truehost.com/support/wp-content/uploads/2024/10/image-579.png)

##### **Step 5: Set Up a Basic Firewall**

- Linux servers typically come with **UFW (Uncomplicated Firewall)** on Ubuntu or **firewalld** on CentOS/AlmaLinux.

1. **For Ubuntu**:

```
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
```

2. For CentOS/AlmaLinux:

```
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
```

- **Verify Firewall Status**: Confirm that your firewall rules are configured correctly to allow SSH access.

##### **Step 6: Create a New User**

- For security, avoid working as the `root` user. Create a new user with sudo privileges.
- Use **[these steps](https://truehost.com/support/knowledge-base/how-to-create-a-sudo-user-on-your-server/)** to do that

##### **Step 7: Set Up SSH Key Authentication (Optional but Recommended)**

- Using SSH keys instead of passwords significantly enhances security.

- Please refer to **[these steps](https://truehost.com/support/knowledge-base/how-to-configure-ssh-key-for-a-user/)** on how to configure SSH keys

##### **Step 8: Monitor Server Performance**

- Install monitoring tools to keep track of server health:

1. **Install Fail2Ban** for protection against brute-force attacks:

- Please refer to **[this article](https://truehost.com/support/knowledge-base/how-to-secure-a-linux-server-with-fail2ban/)** on how to install and configure fail2ban

2. **Top/htop** for resource monitoring:

```
sudo apt install htop -y  # Ubuntu/Debian

sudo yum install htop -y  # AlmaLinuxCentOS
```

##### **Step 9: Final Security Checks**

You can make your server even more secure by enforcing extra security measures

**Disable Root SSH Login**

- You can use **[these steps](https://truehost.com/support/knowledge-base/how-to-disable-root-ssh-completely/)** to disable root ssh login and only allow ssh with sudo user.

**Change SSH port to a custom port**

- You can use **[these steps](https://truehost.com/support/knowledge-base/how-to-change-ssh-port-to-a-custom-port/)** to change the SSH port from the default 22, and set a custom one.

With those steps, your Linux server is now set up, secured, and ready for production use. Remember to monitor performance, stay on top of security updates, and back up your data regularly.
