Stefkoff's Blog

Menu

Menu

  • Blog
  • Email
  • Feed
  • Register
  • Log in

Categories

  • Ubuntu

Recent Posts

  • How I prevent my servers from…
  • How I use Vim as DevOps…
  • Managing cron job for web…
  • Find how many lines are in…
  • Backup MySQL database and…

Archive

  • August 2024
  • May 2024
  • April 2024

August 2024

  • How I prevent my…

    In these days, cyber security is one of the important topic that everyone should consider. It goes from the local router up to the production environments and Cloud infrastructure. Currently, there are a lot of open-source tools for testing vulnerabilities of an app, that they can be used even for gaining access over it. Also, on the other hand, a lot of users are using open-sourced applications, like nginx, apache, etc, that the attacker could find the exact version of the application and find how it can be broken or even gain access over some private resources. There are a lot of Vulnerabilities databases, like OVS, that the hacker could just know the version of the application, searches in the OVS for the particular version and do some mess with you server. That it why, you should always needs to update your software to the latest versions, because the developers are giving more and more security fixes for the application. My infrastructure Current, I have a bunch of Dell servers…

    Permanent link to “How I prevent my servers from attackers”
  • How I use Vim as…

    Vim for DevOps? Of course vim in not one of the requirements in order to be good DevOps, but I choose it over nano, emacs or any other terminal editors. Why? Read below to see its power. Why it is better than others? It is not better than others, because in one way or another, someone could finds nano (for example) as a best editor for him/her. In my experience, I've started with vim and almost everything I did was with vim. If you prefer some other terminal editor, probably this blog post is not for you, or you can stay and see how I use it. Here are some key features that I got used to vim and I think it is the best one: a lot of short codes that you can use in order to speed-up the process of writing/editing files very customisable software that you can find plugins for almost everything. You can even write your own. ability to split your screen by multiple layouts and edit multiple files at one screen, without need to open and close every time as the second point, it is…

    Permanent link to “How I use Vim as DevOps Engineer”
  • Managing cron job…

    Background Almost every developer or DevOps has been serving their Web content via some web server like nginx or apache. All of these servers comes with the default user www-data. This user is used for a security reasons that is different from the normal system users (like root or something pre-configured while installing the system), so the application will have a limited resources over the entire server. Of course, you can change the running user for the web server to something else, but this is not recommended if there is not another reason behind this. If you close the application source code, with some user, let's say root user, you have to change the permission of the source code to be owned by the www-data user. This is done by the following command: chown -R www-data:www-data /var/www/html. In this way, only the www-data user will have the rights to operate with the content in /var/www/html. Depending on the use-cases, you would want to give the following permissions to all of…

    Permanent link to “Managing cron job for web applications”
  • Find how many lines…

    Background Do you ever need to know how many lines of code (for example) are in a particular folder? Do you know that you can easy find this with a single line in the terminal? I will show you how here and will explain every part. Prerequisites So we need a UNIX system (obviously) - Linux or MacOS. Also, we need some folder to work with. I've choose a random node_modules folder from a random project that have a bunch of nodejs modules inside (I really do not know what is inside it). You can choose any folder from yours, or create some folder and files to validate the tests Final result Probably you are curious to see the final result and test it out. I will show you the full command and then will break down all parts of it, so you can understands it. Here it is: find . -type f | xargs wc -l | egrep 'total$' | awk '{print $1}' | paste -sd+ - | bc Explanation Here, we have used a series of commands (more often can be heard as pipesof commands, that when combining in a particular way,…

    Permanent link to “Find how many lines are in the current folder in UNIX”

May 2024

  • Backup MySQL…

    Introduction When you have a database server (production or not), you may want to back up the database regular, because everything can happen - disk failure, hardware failure, etc. In this blog post, I will how you how to back up all databases, compress them and upload them to AWS S3 object storage. Requirements This tutorial will be valid for Ubuntu 22.04. You need to have a running MySQL server You need to have mysqldump script installed on the machine that you will making the back-up. It could be installed by sudo apt-get install mysql-client You also need to have root access to all the database that needs to be dumped. Make sure that you will have enough free disk space, because depending on the size of the file, you may run out of disk space when the dump is generated You need to have an AWS account and credentials (AWS KEY and AWS SECRET KEY) Dump all databases to an .sql file In order to dump all the database, run the following command: mysqldump -u USER -p --all-databases…

    Permanent link to “Backup MySQL database and upload them to AWS S3”

April 2024

  • Building CI/CD…

    This is the second part from the series of "Building CI/CD deployment with GitLab". If you haven't read the introduction blog, you check it here. The plan Here is an overview of what we will cover in this blog post: Set up the repository in GitLab. Cloning it locally Push the base branches Set up branch permission Requirements I assume that you already have a private GitLab repository (self-hosted or cloud-managed). All the dev work will be done in an Ubuntu Desktop machine, but since we will be using mostly NodeJS, the commands will be valid for Windows systems also. In this blogs post, we will not be focused over the development, so you can choose your favorite code editor or IDE. You can also may use Vim for editing the files (if you know how to exit after :) ). Step 1: Set up the repository The first this is to log in to your GitLab instance and create a new Blank Project: On the next screen, enter the following details for your project: Project Name - name of your…

    Permanent link to “Building CI/CD deployment with GitLab, Part 2: Setup Repository”
  • Building CI/CD…

    Introduction If you are working alone on the development process, pushing directly to the production server is not so bad. Of course, if all tests are passing before this. But working in a large team (4+ developers), first will lead to many-many merge conflicts, and the track for the deployments will be lost, if there is not properly configured CI/CD workflow. Honestly, in my personal experience I do not like when I hear: Fix the bug and push ASAP!. We are all humans and we make mistakes. Even a small typo could lead that, the clients will not have trust in the software that we are delivering. Having a good CI/CD workflow, together with automated tests and manual QA testing, will ensure that the software is properly working as the client's expectations. NOTE: in the entire series, I will not going to talk about securing the application. I'm planning to write a blog for the securing application, but in order to keep this thread not so annoying, I will write this in a completely…

    Permanent link to “Building CI/CD deployment with GitLab, Part 1: Introduction”
  • Build home VoIP…

    Background Have you ever want to build a home VoIP system? I will tell you - you can do this and you do not have to know everything about SIP, trunking, VLAN, QoS and so many network principals in order to build a small home VoIP server. You can follow this article and build your own VoIP server (as I did a my home) using asterisk as a PBX and two very cheap old VoIP phones (2 SwissVoice IP10S, at price for $5 each). Of course you will need a router or a switch at least, but I supposed that you already have a SOHO router running DHCP server. Inspiration My inspiration for this project comes from the fact that most of the time, I'm at my basement, and my wife have to call me. Of course she could call me by the phone or using FaceTime or Messager, but there is no fun about this :) . btw, my wife do not like the hole idea, but she just do not understand the effort Equipment As I mentioned above, I will use my home router (Mikrotik RB3100), but this is not too important, if your router…

    Permanent link to “Build home VoIP server with asterisk”
  • Configure Postfix…

    Background Do you ever need to use a SMPT relay when sending email throw PHP mail() function? Probably yes. One way use to use a third party library like phpmailer/phpmailer. This is nice and everything is handled by phpmailer so you do not have to do anything else. But where is the issue? Here: Adding more and more 3rd party libraries increase the application size. In some cases this is a critical and you need to avoid this. And here, I will show you how to configure all of this, in order to save some space. Requirements I assume that you have already have a web server with running apache2|nginx and php and the application is up-and-running. All of the above commands are valid for Ubuntu 18.04 and above Assuming that you have a mail server like PirvateEmail, MainGun, SendGrid that you want to use it as a relay. Step 1: Install postfix First you update packages registry and upgrade the server: sudo apt update && sudo apt upgrade Install the libsasl2-modules package: sudo…

    Permanent link to “Configure Postfix to use SMPT relay when sending emails via PHP mail function”
  • My First blog

    Hi all, I'm going to start my first blog here. I will use this open-source platform to write my own articles so I can help one of you or just to remember thing for myself :) Stay tunned for the next posts.

    Permanent link to “My First blog”