• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SwiftGuides

How-to Guides, Tutorials & Much More

  • Home
  • Servers
  • Applications
  • Opinions
  • Search
You are here: Home / Servers / Initial Ubuntu 22 Server Configuration for Nginx

Initial Ubuntu 22 Server Configuration for Nginx

April 16, 2024 by Sourabh Verma Leave a Comment

As you get your new Ubuntu server ready, there are certain initial configurations that you must do. These configurations will add initial level of security and will setup a solid foundation for your web server. After Initial Ubuntu Server Configuration for Nginx, you can Configure Nginx, MariaDB, PHP 8.1 (LEMP Stack) which you can use to host your website or web application.

Intial Ubuntu server configuration
Intial-Ubuntu-server-configuration

In this Tutorial

  • What is Root?
  • Why Initial Configuration of Server is Important?
    • Initial Ubuntu Server Configuration
      • Step 1 – Login to your server as “root”
      • Step 2 – Create a new user
      • Setp 2 – Assigning administrative privileges
      • Step 3 – Setting up a firewall
  • Conclusion

What is Root?

Root is a default user in Linux operating system. It has highly elevated privileges and thus it is advised not to use it on a regular basis. Because of the elevated privileges, root user can run any commands and thus it may be destructive.

Why Initial Configuration of Server is Important?

When you get  a VPS, its just barebone and its very easy for anyone to get its access. This is the reaosn why it is very important to do a basic setup of firewall and sudo user. Firewall will block unwanted requests to your server. You can even configure it to safeguard your server from DDOS attack as well as any other kind of unauthorised access.

Having a sudo user is very important when you are working on Linux. as explained above, root user comes with high privileges and with one wrong command you may end up destroying your server. Hence, we recommend you to always operate Linux with sudo user only. Many commands and files are restricted for sudo user, which adds a layer of protection for your server.

Initial Ubuntu Server Configuration

In this tutorial, we will perform the following steps

Step 1 – Login to your server as “root”

As its a new server, the first thing that you will have to do is login as “root” user. If you have opted for private key, you will have to first install the SSH key. If you didn’t, then you can just use putty tool, enter your server’s IP under “host name” and enter “22” under “port” and click “open”. Click on “Accept” in the dialog box appeared.

Now you will see a black window with “login as”.

  1. Type “root” and hit “Enter” key
  2. Type your root password (password that you have entered at the time of creating the server)

Hurrey! you have successfully logged in to your server. Now lets proceed further.

Step 2 – Create a new user

After creating new user, we will always login using this new user only

# adduser jack

You can replace “jack” with whatever name you like. Hit “Enter”, and this command will create a new username named jack and will ask you for a new password. Make sure to enter a strong password. Next the system will ask some questions that you can fill as per your wish.

Setp 2 – Assigning administrative privileges

Now that you have a new regular user, we will have to assign administrative privileges to the user so that the user can perform various administrative tasks just by putting “sudo” infront of the command. we also have to add the user to the “system group” because in ubuntu, members of “system group” can run commands using “sudo” by default.

# usermod -aG sudo jack

This command will add user to “system group” and assign administrative privileges as well.

Step 3 – Setting up a firewall

Ubuntu uses UFW firewall. Configuring ufw firewall will ensure that only allowed connections will be able to communicate with the server. This will add a solid layer of security for the server.

OpenSSH is the service that allows you to connect your ubuntu server remotely. Given below command will examine the installed profiles.

# ufw app list

Output
Available applications:
    OpenSSH

Now the first thing that you have to do is to ensure that you can connect to your ubuntu server without any issue. So you must allow OpenSSH profile in the firewall using the command given below

# ufw allow OpenSSH

Now type the below command to enable the firewall

# ufw enable

Type “y” and hit “Enter” key

Now cross check whether you have done the right configuration

# ufw status

Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)

Congratulations, you have just configured your firewall that is allowing only the OpenSSH connections and denying all the others.

Conclusion

We recommend you to always perform the initial setup before starting the configuration as it sets up a solid base for your server. With this, you have successfully completed your Ubuntu server’s initial configuration. Now you can go ahead and install the applications that you wish to.

Category: Servers Tagged In: Nginx, Server, Ubuntu

Like my work? Don't Forget to Share

Share on Facebook Share on Twitter Share on LinkedIn Share on Reddit Share on WhatsApp Share via Email

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About Sourabh

Hi, I am Sourabh, welcome to SwiftGuides! With over 12 years of experience in Linux, SysAdmin, databases, cloud computing, and other IT-related areas, I make sure to publish easy-to-follow, 100% working tutorials. I hope you like my work. Thanks!

Stay with SwiftGuides

Follow on Facebook Follow on Twitter Follow on LinkedIn Follow on Reddit Subscribe on YouTube Follow on Instagram

SwiftGuides: Howtos, Tutorials & Guides © 2025 ยท All Rights Reserved

  • Contact Us
  • Privacy Policy
  • Disclaimer