The main configuration of the Linux server

Giteqa

Today in this article I will introduce you to the basics of Linux server (An example will be shown on Ubuntu 20.04). I will show you how to configure the graphical shell, how to create a user and give him root rights, how to remotely connect to the graphical shell of the server and more.

Creating and configuring a new user

If suddenly you need to create a new user, for example, for a new employee, you will need to enter the following commands (On behalf of the Root user):

Useradd -m -s /bin/bash -c ‘Admin’ username

This command has the following designations

  • Useradd - add user command
  • -m - creating a home directory
  • -s - user input shell
  • -c - How will the login account be signed
  • Username - The user's name

After you have created a user, you need to assign a password to him so that no one can access him, this is done through the command:


Passwd username -  then you will be prompted to enter the password and repeat it.

The password must be strong and consist of small and large letters, numbers and special characters.

After you have created a user and given him a password, you need to give him access to work, let's give him administrator rights using the command:

Usermod -aG sudo username

  • Usermode - adds a user to a specific category
  • -A - indicates which category will be added to
  • -G - specifies the rights that will be assigned to the user
  • Sudo is the administrator rights.


Next, we will need to check whether everything works for this user to do this, go to this account by entering su username and then try to perform some action, for example, create a folder mkdir test you should be asked for a password, after you enter it the folder will be created. You can check this using cd /test if it was created, then everything works correctly.

Creating a graphical shell

I will show you how to create a graphical shell for your system built on linux ubuntu (20.04 is my version, but it is also suitable for the past). If you need to work through the graphical shell, then enter the command:

Apt install ubuntu-desktop

After that, the download of the package with graphic data will begin and it may take some time to configure it (it took me 5 minutes). Next, you will need to reboot the system using reboot and then you will see an entry into the graphical shell.

It is important that you create a separate user before this, because you will not be able to log in on behalf of root.

Since I previously created a user as I described above, I will be shown the following when logging in

After you log in, there will be a desktop in front of you where, so far, nothing has been installed.

So you can already start working using this graphical shell, but how to connect to it remotely?

In order to connect to it remotely, you will need to enter the following commands:

  • apt install xrdp xorgxrdp
  • apt install ubuntu-desktop xrdp xorgxrdp

This will allow you to connect remotely to the system using RDP (windows remote desktop protocol).

How do I log in to the terminal (console) when I have already installed the graphical shell? To do this, on the initial page, when you log in, just press ctrl +alt +f2 and you will be taken to the terminal.

Firewall

To ensure that all your connections are protected and you do not worry about the security of your server, you need to activate the firewall. This is done using the following command:

Ufw enable

However, this may block the connection via ssh keys if you have not updated the firewall rules. To update the rules and allow remote connection via ssh, enter:

Ufw allow openssh

After that, all connections except ssh will be banned unless you add them to a separate rule.

Remote connection

Now your server is ready to work, you have users that you can add or remove, a firewall is enabled that increases the security of the server and the ability to connect remotely. This means that you can already use this server for work and install anything on it, for example, a database or gaming / streaming services.

And if suddenly you don't want to download some separate programs for remote access to the server, then you can use our services, we connect to the console directly from your personal account, which is why you don't need to install anything on your personal PC. And you can work from anywhere.