Welcome to the Basement of Knowledge

Exploring Linux, Java, and Open Source technologies through practical guides and tutorials

All Articles

Linux

How to configure a Linux File Server with NFS

In the realm of networked storage solutions, NFS (Network File System) stands out as a robust and efficient option for sharing files and directories across a network of Linux-based systems. NFS all...

Linux

Building an Example Site with Javelin: Full Guide

Javelin is a powerful static site generator that allows you to create fast, modern, and highly customizable websites with ease. With its intuitive syntax, flexible templating system, and extensive ...

Linux

Mastering Text Processing in Linux Command Line

In the realm of system administration, data analysis, and software development, the Linux command line is a powerful tool for text processing. With a wide array of utilities and commands at your di...

Linux

Setting Up a Chat Server with ejabberd

In today's interconnected world, instant messaging and real-time communication have become integral parts of both personal and professional interactions. Whether it's team collaboration, customer s...

Linux

Understanding and Using Linux Memory Management

In the realm of operating systems, memory management is a fundamental aspect that directly impacts system performance, resource utilization, and overall stability. Linux, being one of the most wide...

Linux

Using the Vi text editor effectively

Introduction Welcome to our beginner's guide on how to use the Vi text editor effectively. If you're new to the world of programming or system administration, you've probably heard about Vi. It's a...

Linux

Understanding and Using the Linux Kernel

Introduction Welcome to the world of Linux, a powerful, open-source operating system that powers a significant portion of the internet, corporate servers, and even Android phones. At the heart of t...

Linux

How to Set Up a DNS Server with BIND

Introduction In the world of networking, the Domain Name System (DNS) plays a pivotal role in ensuring seamless communication between computers. It translates human-friendly domain names into IP ad...

Linux

A Beginner's Guide to Configuring a VPN with OpenVPN

Introduction In today's digital age, privacy and security are paramount. One of the most effective ways to protect your online privacy is by using a Virtual Private Network (VPN). This blog post wi...

Linux Windows

A Beginner's Guide to Configuring a DHCP Server

Introduction Welcome to our comprehensive guide on configuring a Dynamic Host Configuration Protocol (DHCP) server. If you're a beginner in the world of networking, this guide is perfect for you. W...

Linux Web

A Beginner's Guide to Setting Up a Web Server with Nginx

Introduction In the digital age, having a web presence is crucial for businesses and individuals alike. One of the key components of this presence is a web server. Today, we will guide you through ...

Linux

A Beginner's Guide to Configuring a Proxy Server with Squid

Introduction In the digital age, privacy and security are paramount. One way to ensure these is by using a proxy server. A proxy server acts as an intermediary between your computer and the interne...

Linux

A Beginner's Guide to Setting Up an FTP Server with Vsftpd

Introduction FTP, or File Transfer Protocol, is a standard network protocol used for the transfer of computer files between a client and server on a computer network. One of the most secure and fas...

Linux

How to customize a docker image with a Dockerfile

Introduction Docker is a revolutionary tool that has transformed the way we develop, deploy, and distribute software applications. It allows developers to package an application with all its depend...

Linux

How to make your own docker container and persist changes

A Beginner's Guide to Creating and Persisting Changes in Docker Containers Introduction Docker is a revolutionary open-source platform that allows developers to automate the deployment, scaling, an...

Linux

Setting up a mail server with Postfix

A Beginner's Guide to Setting Up a Mail Server with Postfix Introduction In the digital age, email communication has become a vital part of our daily lives. Whether it's for personal or business pu...

Linux

Setting up a secure SSH server

A Beginner's Guide to Setting Up a Secure SSH Server Introduction Secure Shell (SSH) is a cryptographic network protocol that allows secure remote login from one computer to another. It provides a ...

Linux

Understanding and using Linux file permissions

A Beginner's Guide to Understanding and Using Linux File Permissions Introduction Linux, a powerful and versatile operating system, is known for its high level of security. One of the key elements ...

Linux

Using the Linux terminal for beginners

A Beginner's Guide to Using the Linux Terminal Introduction The Linux terminal, also known as the command line, is a powerful tool that can seem daunting to beginners. However, with a basic underst...

Linux

Configuring a firewall using iptables

A Beginner's Guide to Configuring a Firewall Using iptables Introduction In the world of network security, a firewall is a crucial component that helps protect your system from unauthorized access....

Linux

Installing and configuring a LAMP stack

A Beginner's Guide to Installing and Configuring a LAMP Stack Introduction In the world of web development, the term "LAMP" is an acronym that stands for Linux, Apache, MySQL, and PHP. These four o...

How to Use Beans in Spring Boot

In Spring Boot, beans are managed objects that are instantiated, assembled, and otherwise managed by the Spring IoC (Inversion of Control) container. To use a bean in Spring Boot, you typically fol...

Java

How Do Quartz Jobs Work in Java

Quartz is a popular Java library for scheduling and managing jobs or tasks in applications. It allows you to schedule jobs to run at specific times or intervals. Here's a basic overview of how Qua...

How to Choose the Best Linux Distribution

Choosing the best Linux distribution depends on your specific needs and preferences. In the following view I explain how 20+ years of experience with Linux have shaped my views. Here are so...

Java

What is a Provider in Java

In Java, a Provider is a class or interface that provides a way to obtain or create instances of a specific type or service. It is a concept that is often used in the context of dependency injecti...

Java

What is a Supplier in Java

In Java, a supplier is a functional interface from the Java.util.function package that represents a supplier of results. It does not take any arguments and returns a value of the specified type. T...

Linux

How to Create a SuSE rpm Package From a Directory

To create an RPM package from a directory such as /opt/asd in SuSE, you can follow these general steps: First, you need to install the RPM build tools on your SuSE system. You can do this by ru...

Java

What is AtomicStampedReference and How to Use It

AtomicStampedReference is a class in Java that provides atomic operations on a reference object along with a stamp or version number. It is typically used in concurrent programming scenarios where...

Linux Virtualization

How to Create and Use a Private Docker Registry

Using a private Docker registry offers several benefits: Improved security: With a private Docker registry, you have full control over the container images that are stored and distributed withi...

Linux Virtualization

What are Docker Image Registries

Docker image registries are central repositories that store and distribute Docker container images. Docker container images are the building blocks of Docker containers, containing all the necessa...

Linux Virtualization

What is Docker Swarm

Docker Swarm is a native container orchestration solution provided by Docker for managing and scaling containerized applications across a swarm of Docker nodes. It enables you to create and manage...

Linux Virtualization

What is Docker Compose

Docker Compose is a tool that allows you to define, configure, and run multi-container Docker applications using a YAML file. It provides an easy way to define the services, networks, and volumes ...

Linux Virtualization

What are Docker Volumes

Docker volumes are a way to persist and manage data in Docker containers. A Docker volume is a directory or a named volume that is stored outside of the container's file system and is used to stor...

Linux Virtualization

What are Docker Networks

Docker networks are virtual networks that provide communication channels for Docker containers to communicate with each other and with the host system, allowing containers to communicate securely ...

Linux Virtualization

What is a Port Mapping (Forwarding) in Docker

In Docker, port mapping (also known as port forwarding) is the process of associating a port on the host system with a port on a Docker container, allowing network traffic to be directed to and fr...

Linux Virtualization

What is a Filesystem Mapping in Docker

In Docker, a file system mapping refers to the process of associating a directory or a file from the host system with a directory or a file inside a Docker container. This allows the container to ...

Java

How to Properly Use Reflection in Java

Reflection in Java is a mechanism that allows you to inspect and modify the behavior of classes, methods, interfaces, and fields at runtime, even if you do not have access to their source code dur...

Java

How to Backup and Restore H2 Database

H2Database (or simply H2) is an open-source, lightweight, and fast relational database management system written in Java. It is a pure Java database that can be used as an embedded database, or as...

Java

Overusing the Static Keyword in Java

The static keyword is often overused in Java and this can lead to several risks, including: Tight Coupling: When you declare a member (variable or method) as static, it becomes a global entity ...

Linux Security

How to Write a Simple Linux Bash Honeypot

The first step in a malicious hacker attack is scanning. This means that an attacker will scan its target for open ports and vulnerabilities. So, the best approach is to block an attacker who trie...

Java

How to Use Properly Lambdas in Java

Lambdas are a concise way to define and use functional interfaces in Java. Here are some guidelines on how to use lambdas effectively in Java: Know when to use lambdas: Lambdas are best used wh...

Java

What is a Predicate in Java and How to Use It

In Java, a predicate is a functional interface from the java.util.function package that represents a function that takes in one argument and returns a boolean value. The functional interface is de...

Java

How to Add Dependencies in a Maven Project

In Maven, you can manage dependencies using a pom.xml file. Here's how you can add dependencies to your pom.xml file: Open your pom.xml file in a text editor or an integrated development enviro...

Java

What is Polymorphism in Java

Polymorphism in Java is a concept that allows objects of different classes to be treated as if they were of the same type. It allows you to write code that can work with objects of multiple classe...

Java Security

How to Prevent Resources From Leaking in Java

In Java, a resource leak occurs when a program fails to properly release system resources after they are no longer needed. This can lead to a range of problems, such as reduced system performance,...

Java Security

Reasons to Make Methods Final in Java

Making methods final in Java can provide several benefits, including: Preventing method overriding: When a method is marked final, it cannot be overridden by subclasses. This can help ensure th...

Java Security

Security Risks of Serializing and Deserializing Data in Java

Serializing and deserializing data in Java can introduce several security risks if not implemented properly. Here are some of the main risks: Remote code execution (RCE): If untrusted data is i...

Java

How to Improve Resilience With Hystrix

Hystrix is a library created by Netflix that provides fault tolerance and latency tolerance for distributed systems. It is particularly useful in microservices architecture where failures in one s...

Java

How to Work with Hazelcast Distributed Maps in Java

Distributed maps provide a way for applications to store and access data in a distributed environment, where the data is automatically distributed across multiple nodes in a cluster. There are sev...

Java

Common Mistakes When Using Optional in Java

Optional in Java is a container object that is used to represent the presence or absence of a value. It is a powerful tool that can help to avoid null pointer exceptions and make code more robust....

Java

How to Use Efficiently Generics in Java

In Java, generics provide a way to specify a type parameter for a class, method, or interface. A type parameter is a placeholder for a type that is specified at runtime, allowing code to be writte...

Java

What are the Benefits of the Diamond Operator in Java

The diamond operator in Java, also known as the empty angle bracket (<>) syntax, was introduced in Java 7 and provides several benefits: Improved readability: The diamond operator can imp...

Java

Why should You Use Method References in Java

In Java, a method reference is a shorthand notation for referring to a method as a lambda expression. Method references provide a way to pass a reference to a method without actually invoking the ...

Java

How to Create Custom Annotations in Java

In Java, annotations are a form of metadata that provide additional information about program elements such as classes, methods, fields, and parameters. Annotations are defined using the '@' symbo...

Linux

Why Python Replaced Perl

Both Perl and Python are powerful scripting languages that are used extensively in software development, system administration, and data analysis. Here are some key differences between the two lan...

Linux

How to Write Bash Script with User Input

Here's a Linux bash script that performs the following tasks: Prompts the user to enter a directory path. Checks if the directory exists and if not, creates it. Prompts the user to enter a ...

Java Refactoring

Why is Proper Exception Handling Important in Java

A common bad practice in Java programming is not properly handling exceptions. Java has a robust exception handling mechanism, but not using it properly can lead to unexpected behavior and errors ...

Java

What are the Benefits of Lambdas in Java

Lambda expressions were introduced in Java 8, and they provide several benefits over traditional anonymous inner classes. Some of the benefits of lambdas in Java include: Concise code: Lambdas ...

Java

Pass by Value Meaning in Java

In Java, when you pass a parameter to a method, a copy of the value of that parameter is passed to the method, rather than the original object itself. This is what is meant by "Java is pass by val...

Java Linux

What are Varargs in Java and How to Use Them

In Java, varargs (variable-length arguments) are a feature that allows a method to accept an arbitrary number of arguments of the same type. The varargs feature was introduced in Java 5 and is den...

Java Security

What are Java's Access Modifiers and How to Use Them

In Java, access modifiers are keywords that determine the accessibility of classes, methods, and variables in an object-oriented program. There are four access modifiers in Java: public: Classe...

Linux Security

Common Mistakes Which Leave a Linux Vulnerable

Securing a Linux system can be a complex task, and there are many potential pitfalls and mistakes that can compromise the system's security. Here are some of the most common mistakes with examp...

Linux Security

When and How to Use Iptables and Ipsets

iptables and ipsets are both tools that are commonly used in Linux-based operating systems for managing network traffic. However, they serve different purposes and have different capabilities. i...

Web

How to Create a Random Quote / Fact WordPress Plugin

To create a WordPress plugin which shows a random value from an array, such as quote or fact, follow these steps. Open your editor and create a file called fun_facts.php (the name does not reall...

Java Linux

Java Performance on Linux vs Windows

Java is a cross-platform language, which means that Java applications can run on a variety of operating systems, including Linux and Windows. The performance of Java applications can depend on a v...

Java

Php Vs Java In Regards to Performance

The performance of PHP and Java can depend on a variety of factors, including the specific implementation, the hardware and software environment, and the workload of the application. In general,...

Java Security

How to Develop Securely In Java

There are several good security practices to follow when developing Java applications. Here are some of the most important ones: Keep your Java runtime environment up to date: Make sure that yo...

Java Web

How to Rewrite JSP Pages In Java

SP (JavaServer Pages) pages are essentially HTML files with embedded Java code. To rewrite JSP pages in Java, you will need to extract the Java code from the JSP pages and refactor it into Java co...

Java

New Features in Java 17 and Comparison to Java 11

Orcacle releases new Java versions quite often and the current one is 19. However, plenty of production code is still running on older Java versions as even Java 8 is still supported. That's why i...

Java

Quick Win Hints for Refactoring Java code

There are several quick wins that can be achieved through refactoring Java code: Removing duplicate code: Duplicate code can make the codebase harder to maintain and increase the risk of introd...

Useful Mockito withSettings() Methods For Testing

In one of our previous articles How to Mock Variables for Interfaces and Casts in Java we described how to use the method withSettings().extraInterfaces() in order to add more interfaces / impleme...

What are Maven Profiles and How to Use Them

Maven profiles are a way to define a set of configuration options for a Maven build. Profiles are used to specify different build configurations for different environments or situations. For examp...

Java

How to Implement a Retry Logic in Java

Retry logic can be implemented in Java using various libraries and frameworks, but the general idea is to have a block of code that can potentially fail, and then wrap that code in a loop that wil...

Java

How to Mock Variables for Interfaces and Casts in Java

One common issue when writing JUnit tests is how to create a mock when the variable is an an interface / implementation or a casting. For example, in the case of casting: public PaymentGateway...

databases Java

How to Back Up A MySQL Database With Java

In case you have wondered how to back up a MySQL database using Java code, here is one way to do it: import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import ja...

Java

How to Write Console Programs In Java

Console programs in Java can be easily written using System.out.println for output and Scanner for input. For example, here is a simple guessing game which runs in the console: import java.ut...

Java Refactoring

How to Write Clean, Unobfuscated Code in Java

Writing clean, easy-to-read code in Java is important for improving code readability, maintainability, and overall quality. Here are some tips for writing clean, unobfuscated code in Java: Use ...

Java

How to Write Obfuscated Java Code

To some people obfuscating programming code, including Java, means: Job security. If no one can understand their code, they are irreplaceable. Smartness. They are so smart, that they can wri...

Java

How to make Java 8 Code Compatible With Java 11

If you still run your Java code with JVM 8, it's probably high time to move on and starting using a newer JVM version such as 11. For this reasons, you have to ensure your Java code is Java 11 com...

Java

What is Boilerplate Code and How to Reduce It In Java

In programming, boilerplate refers to sections of code that are repeated in many places throughout a project or across multiple projects. This code may be necessary, but it is often repetitive and...

Java

Popular Code Analysis Tools to Help with Java Programming

Code analysis tools are software tools that analyze source code for potential issues, errors, and vulnerabilities. These tools can help developers identify and fix issues before they become proble...

Java

Worst Practices to Avoid in Java Programming

One of our latests posts was how to become a better programmer with the help of OpenGPT. Still, even without the help of AI, there are things you can do to become a better programmer and the most ...

Java

How to Use OpenGPT to Write JUnit Tests

Test driven development is the standard nowadays but sometimes somehow there appears a class before the test is written. This is especially true for legacy projects and legacy code. The most unp...

Java

How to Use OpenGPT to Become a Better Java Programmer

OpenGPT is very popular lately. If you haven't heard about it yet, it is a language model developed by OpenAI that can generate human-like text based on a given prompt. While OpenGPT can be a usef...

Java

How to Become a Better Java Programmer Using SonarLint

One of the fastest ways to advance in Java programming is using SolarLint's IDE extension. It helps you avoid common problems and ensures your code is clean. SonarLint is a linting tool for code...

Java

How to Skip A Finally Statement in Java

A common interview question for Java developers is to write some code inside a try / catch / finally statement so that the finally statement is not reached. At first glance, this is not possible. ...

Java

How to Create a Deadlock In Java with One Thread

A deadlock is a situation in computer programming where two or more processes are blocked, each waiting for the other to release a resource that they need in order to continue executing. As a resu...

Java

How to make Eclipse run with a custom JDK on Mac

You might want to have more than one JDK on your Mac and run different programs with different JDK versions as it is with me. The easiest and safest way I've found is as follows. First, downlo...

databases Java

How to make Hazelcast's cluster replication more resilient

Hazelcast is an open source in-memory data grid. It is written in Java and naturally it is popular for Java applications but not only. In simple words, Hazelcast is like a shared map which you ...

Java

How to create a Singleton class properly in Java

A Singleton class is a class of which only one instance exists. There is a need for such a design pattern for loggers, database connections and other scenarios. The main challenge comes when you...

Java

What are concurrency problems and how to avoid them in Java

Concurrency problems appear when your code is executed by more than one thread. Then, in contrast to a single-threaded execution, your code might behave differently depending on when and which thr...

Java

Period, Duration and Instant in Java

Period, Duration and Instant are three different classes introduced since Java 8 to help us deal better with time. Period measures the time with days granularity. In other words, there are no ...

Java Refactoring

Why and How to Use Optional in Java

The Optional object type in Java was introduced with version 8 of Java. It is used when we want to express that a value might not be known (yet) or it's not applicable at this moment. Before Java ...

Linux Middleware

Introduction to Tengine Web Server

Tengine seems to be a popular web server for Chinese websites. I've come upon it while browsing through Aliexpress and stumbling upon a 404 error: This error and more specifically its footer ...

Java

Why and How to Use Java.util.stream.Collectors

Streams are a wonderful feature in Java allowing you to write clean, efficient and powerful code. If you haven't consumed the output of the stream, you will probably want to collect it. That's w...

Java

Java Built-In Functional Interfaces Cheatsheet and Examples

In order to use lambda expressions in Java 8, you need a functional interface. For most of your needs, you can use the already built ones in Java which are as follows: Supplier - generate outp...

Java

Java Generics With Upper and Lower Bounds Simply Explained

Generics in Java and especially such with upper and lower bounds can be confusing even though they are otherwise very useful. Here is an example which explains it all well: import java.util.Ar...

Java

Avoid the Telescoping Anti-pattern in Java

The Telescoping anti-pattern is widely-spread, just like a virus. It starts with good intentions. For example, a class that has two properties like this: public class Example { private int x; ...

Java

How to Create Immutable Objects and Properties in Java

Being able to create an immutable object in Java is one of the most essential skills for any Java programmer. Such objects are needed when you want to rest assured that a created object cannot cha...

Java

How to Use a Functional Interface in Java

A functional interface is an interface that contains a single abstract method. It is used as the basis for lambda expressions in functional programming. Such an interface may contain also other...

Java

Use Lambdas Instead of Anonymous Classes In Java

Another useful feature introduced since Java 8 is the possibility to use lambdas instead of anonymous classes. Here is an example: Imagine you have the following list of names: List<String>...

Java

Reducing Streams in Java

Java 8 introduced streams, among other things, and one of my favourite features is the reduce() method. It combines a stream into a single method. Before Java 8 and streams, such a reduction had...

Java

Delete Files with Java 8

A friend asked me to help him with the following in Bash - delete all files but a whitelisted and use mix / max depth for directory traversal. It's probably possible in Bash with some crazy find, ...

Security

How to Secure an Outdated Web Application in 5 Minutes

I've had the following challenge yesterday. A friend of mine had an old Joomla 2.5 with a bunch of customization - additional components installed, custom theme, etc. It was hosted somewhere and h...

Java

How to Create a Simple Honeypot with Spring Boot

I am sure that there are plenty of honeypots for logging remote intruders but none yet has been done on Spring Boot. So I decided to write a simple one while exploring Spring Boot: https://githu...

Java

How to Create a Simple Mockito Unit Test

Mockito is a popular Java framework which comes to great help in Unit testing. In Unit testing it's important to get to a state where you can concentrate on testing a specific functionality or ...

Java

Connect to Elasticsearch with Java and RestHighLevelClient

Connecting to Elasticsearch and executing queries is generally considered easy. In fact, in many cases a simple curl query like this one is all you need: curl http://localhost:9200/_search?q=my...

Java

Build A Java Project With Maven

Using Maven to maintain and build your Java projects has a lot of advantages including automatically resolving dependencies, running tests and packaging. In this article you will learn about a ...

Linux

Getting Started with Chef and Chef-solo

Chef (the systems integration framework) provides a standalone tool called chef-solo. With chef-solo you can run locally chef recipes without the need for a centralised server (Chef master). This i...

Linux Security

AppArmor Php-Fpm Configuration with ChangeHat

AppArmor is the default Mandatory Access Control module on Ubuntu, SuSE and other Linux distributions. Thanks to it, you can limit the filesystem access of a process. There are already some good h...

Java

Terminate Java Thread

The best way to terminate a Java thread is with a switch such as a boolean property, .e.g abort. As soon as a condition is met, usually a timeout, you can change the value of abort to true and thus...

Java

Working with Time and Date in Java

Working with time and date in Java is essential to any project. There are three important classes you can use: java.time.LocalTime - working only with time. java.time.LocalDate - working only with...

Java

How to Parse Time in Java

To parse time in Java, the most trouble-free and programatic way is using the parse method of the LocalTime class like this: import java.time.LocalTime; import java.time.format.DateTimeFormatter;

Middleware Security

How to Install and Configure SuPHP

Notice: This article was written when Β SuPHP was the most popular choice for running multiple PHP sites on the same Apache server. Now, php-fpm with different users is a better choice. But still, i...

databases Security

How To Secure Your MongoDB Database Server on Ubuntu 14.04

The MongoDB database server is well-known for its unmatched capabilities for processing large NoSQL data. Its latest performance improvements are always under the spotlights and probably not a sing...

Middleware

How To Configure SSL In Tomcat

To secure the communication and increase the level of privacy to and from your Tomcat servlet container you should use SSL. Usually there's an Apache or Nginx in front of Tomcat to serve external c...

How To Create SSH Tunnel With Putty

SSH tunneling is very useful when the network access to a remote network is restricted. Thus, to gain remote network access you can use a tunnel to a remote host which would act as an intermediary....

Security

Introduction to Anonymity, Data Protection and Privacy

Almost every piece of information contains sensitive and private data. Exposing publicly such data could lead to serious financial losses, legal issues and personal inconveniences. That’s why data ...

Linux

How to Install Azure Python Package

You can install Azure Python package either for Python 2 or Python 3 using pip (Python package index). Before you are able to install it though you have to: First, make sure pip is installed, of co...

Middleware Windows

How to Change JVM Xms and Xmx for Tomcat on Windows

Changing Tomcat's initial (Xms) and maximum (Xmx) memory turns out to be counter-intuitive on Windows, especially when Tomcat is installed as a service. That's because when running under a service ...

Linux

How to Create Sudo User on CentOS

Working with root (admin privileged user) in CentOS is not a good idea because you can easily make a costly mistake. Instead, it's much better to grant the special sudo privileges which allow a re...

Linux Web

How To Launch a MEAN Site on Ubuntu 16.04 Server

Introduction Getting a site running on a MEAN (MongoDB, Node.js, Express, and AngularJS) server can be a challenge for beginners. In this article we'll guide you through all the steps necessary for...

Linux

How to Create Sudo User On Ubuntu

Working with root (admin privileged user) in Ubuntu is not a good idea because you can easily make a costly mistake. Instead, it's much better to grant the special sudo privileges which allow a reg...