When it comes to server administration, there are many aspects to consider. Personally, I am only stopping at the most basic level, meaning being able to use a server, install software, and deploy small stacks, as well as troubleshoot issues during operation.
From the early days of programming, no one has much time to teach us everything in detail. However, sometimes it's just a suggestion or a path outlined by someone else, and then step by step is an important premise that helps us on the learning journey.
Many programmers are more interested in writing code than configuring a solid environment for their code to run. If you are a web developer, you can write many useful applications but struggle with how to deploy and operate them, then this article series is for you.
I will start from basic concepts to deploying applications on servers. All of these are my personal experiences, so if there are any mistakes or areas that are not reasonable, I hope readers will provide constructive feedback. Furthermore, all questions are welcome, and if within my knowledge, I will answer them, otherwise, hopefully someone will answer you.
Alright! Let's start with the first article right now.
A server is a computer or system responsible for providing services, storing data, and processing requests from other computers in the network. It is commonly used to serve web applications, emails, or store data.
So, a server is just a computer, connected to a LAN or the Internet, and used to serve certain services. We often hear about web servers, API servers, database servers... all of them remind us of what services that server is providing.
Server administration is a series of necessary tasks to ensure the continuous and stable operation of a server. This includes activities such as:
Accompanied by that are many experiences accumulated during the server operation.
Many people think that a server must be located somewhere or consists of many powerful computers, along with countless network cables glowing with yellow lights. This is true, but with the advancement of technology, we no longer need to spend a lot of time, effort, and money to invest in those things, but simply... rent them.
In the past, physical servers were popular simply because the "Cloud" technology was not as developed as it is now. Moreover, building your own server ensured information security and the ability to manage everything without sharing information with any service provider. But now, with the participation of technology giants in the "Cloud" field, it is gradually changing people's minds because of the benefits it brings, while reducing management and server operation costs.
Therefore, in addition to self-building a physical server, we only need to pay a fee to rent one. There are currently many service providers for this, and prices vary depending on the purpose of use.
For example, it only costs about $5-6/month to have a Shared VPS 1CPU/1GB RAM/20-30GB SSD. The term "Shared" indicates resource sharing, meaning that even though the CPU speed you rent on paper is ~2.4GHz, in reality, it is difficult to achieve because that CPU is shared with other users who rent Shared VPS like you. That's why the price of Shared VPS is cheaper. On the other hand, "Dedicated" is the opposite of "Shared", meaning that you pay to rent an entire physical server, not sharing resources with anyone, and that also means the cost increases significantly.
There are three necessary parameters to log into a server: the username, password, and server address. Most servers support the SSH protocol, and you can use the ssh
command to access your server. Assuming the login parameters provided by the provider are username hoaitx
, password xxx
, and the server IP is 12.34.56.789. Open the Terminal application if you are using Linux or MacOS, or you can use cmd.exe or PowerShell on Windows.
$ ssh [email protected]
Enter the password and press "Enter", if the login is successful, the screen will display the successful login information to the server.
Many providers do not provide password parameters or server IP addresses. Instead, they require us to enter an ssh key and a strange login domain name like a-bc.xyz.nmt
, which is also a way for them to enhance security. We still use ssh
to log in as usual.
Configuration is one of the important things about a computer, and the same goes for servers. The higher the configuration, the more powerful your server will be and the more it can do. While on a computer, we can click on settings to see detailed configurations, for servers, everything needs to be viewed and communicated through commands. That's why you need to learn how to use some basic commands proficiently.
Sometimes, you don't have to remember all the commands, take the time to develop the ability to search or memorize a few favorite tools.
To view the general specifications of the server such as CPU, RAM, Disk... you can use the lshw
command.
$ sudo lshw | less
You can see the name, speed, and some other information about the CPU.
Use the df
command to view disk information:
$ df -h
There are 3 main drives: /dev/root
with a capacity of 7.6GB, the boot partition /dev/nvme0n1p15
with 105MB, and an additional partition /dev/nvme1n1
with 22GB.
Like a computer, a server also has a series of processes running. To view them, you can use top
or htop
.
$ htop
Here we can see the % CPU usage in cells 0 and 1, the amount of RAM used, and the list of processes as well as the resources they occupy.
To learn how to read the output as well as use the htop
command, you can refer to the article Understanding Output of htop Command.
An application sometimes needs to open a port to communicate with the outside world. Imagine if you don't open a port, your application is almost isolated. Therefore, opening a port is necessary for your application to have the ability to communicate.
For example, you build an API server, and you want the Nginx server to connect to it, then opening ports from the API server is necessary.
To view a list of open ports as well as the names of the applications that own them, you can use the lsof
command.
$ sudo lsof -i -P -n | grep LISTEN
We can see that sshd is communicating on port 22, dockerd is opening 4 ports... To know why an application opens a port, you can search in their documentation. In general, opening ports is for some communication purposes, and sometimes opening ports also poses security risks.
That's right, but unlike personal computers, servers are usually much more optimized to serve many different devices or users. Servers usually have higher configurations and more powerful, durable hardware, high-speed networks, and top priority in terms of reliability and security.
Operating systems are also optimized for servers, eliminating personal features and focusing on stability and security. We often hear names like Ubuntu Server, Debian, CentOS Server, Red Hat... They are all widely used and have different features and reliability, depending on the case.
To save resources, many server operating systems have removed the GUI (graphical interface) and focus on developing commands to help us operate the server better.
Hello, my name is Hoai - a developer who tells stories through writing ✍️ and creating products 🚀. With many years of programming experience, I have contributed to various products that bring value to users at my workplace as well as to myself. My hobbies include reading, writing, and researching... I created this blog with the mission of delivering quality articles to the readers of 2coffee.dev.Follow me through these channels LinkedIn, Facebook, Instagram, Telegram.
Comments (2)