Linux Cheat Sheet

Remove execution permission to “others” on every regular files inside a directory find directory_name -type f -exec chmod a-x {} ';' # Avoid using 'chmod -R' as the execution permission is interpreted differently on a directory compared to a regular file. Edit your cron configuration file crontab -e # Always use -e and not crontab file_name # Also do NOT edit it directly in /var/spool/cron/<user> Write errors to the filesystem playbook Determine which filesystem (FS) is full and which file is filling it up 1. `df -h` to look for FS that's 100% or more (possible) full 2. `du -h XX | sort -h` on the identified FS to determine which directory is using the most space. Rinse & repeat command until all the large files are discovered 3. Try `fuser` or `lsof` in case you cant determine which process is using a file Note: `df` & `du` can have disparity in the space reported Write useful shell scripts error messages * Error messages in STDERR * Include name of the program that's issuing the error * State what function / operation failed * If a system call fails, include the perror string * Exit with some code other than 0 Write shell script steps 1. Develop the script as a pipeline, 1 step at a time, on the command line. Use bash. 2. Send output to stdout and check to be sure it looks right 3. At each step, use the shell's command history to recall pipelines and tweak them 4. Once the output is correct, execute the actual commands and verify they worked 5. Use `fc` to capture your work Ex: `find . -type f -name '*.log' | grep -v .do-not-touch | while read fname; do echo mv $fname `echo $fname | sed s/.log/.LOG/`; done | sh -x` Save systemd journal between reboots ...

January 28, 2024

Dockerizing CDKTF with Python

Cloud Development Kit for Terraform (CDKTF) is a framework that allows you to use familiar programming languages to define and provision infrastructure using Terraform. CDKTF supports multiple languages, including Python, which is a popular choice for DevOps engineers. Unfortunately, there is currently no official Docker image for it. Using a Dockerfile, you can ensure that your CDKTF application has all the dependencies and configurations needed to run smoothly and consistently. In this blog post, I will show you the Dockerfile I built for my project that uses CDKTF with Python to create a Kubernetes cluster. ...

December 31, 2023

DevOps - 4 Practices to Reduce Your Lead Time

Create on-demand environments dynamically triggered by a CI/CD pipeline, so teams don’t have to wait weeks. Automate your deployments as much as possible, so any developers can autonomously deploy when needed. Automate your tests and add them to the CI pipeline, so teams can process deployments safely. Design loosely coupled architecture, so developer’s changes are deployed in smaller chunks more frequently with confidence. Those strategies allow teams to improve the delay between the time the customer creates a ticket and its completion.

February 22, 2022

Jenkins As Code With Packer, Ansible, Terraform, and AWS

What Will We Cover Build an OS image for AWS with a Jenkins ready to use Provision an EC2 instance to host the Jenkins server See all the code for this article here: https://github.com/hoaraujerome/devops_cicd Using Packer with Ansible to build an AMI image Packer tool is responsible for creating the OS image, while Ansible is responsible for installing everything we need on this image. The final version of the image has Jenkins (with “GIT”, “Pipeline”, and “Pipeline: AWS Steps” plugins), Docker, AWS CLI, Terraform, and Java installed for running Jenkins pipelines hosted on GitHub. ...

February 7, 2022

DynamoDB: 3 ways to use the API

The way you interact with DynamoDB is usually with AWS SDK, where you can perform: Items-based actions: Anytime you act on a single item - writing, updating, or deleting - you are using an item-based action. You must provide the entire primary key. Query: Read-only actions that allow you to fetch multiple items in a single request. You must provide the partition key and optionally provide sort key conditions. Scan: Full table scan that looks at every item in your table. Avoid it unless you are doing an export or ETL. It’s an expensive operation at scale regarding how long it takes to respond to a request and how much capacity you need to service it. Remember that there is a 1MB limit when reading items from the table. ...

December 14, 2021

5 Responsibilities Regarding the JWT as an API Provider

As a reminder, a JWT (JSON Web Token) is a way for securely transmitting information between parties as a JSON object. As an API provider, here are the actions to take on the received JWT: Validate the signature of the JWT (mandatory) Check if the scope necessary to use your API is present (mandatory). Your API may require more than one scope. Check if the JWT is not expired (mandatory) ...

December 12, 2021

My Thoughts About Java Reactive Programming

Context Traditional Java applications use thread pools for simultaneous I/O operations (such as a REST call). Each request consumes a thread freed at the end of the processing only. So, whenever the thread pool is empty, new requests are blocked waiting for an available thread. This programming paradigm is called imperative or blocking. What is reactive programming? It is a programming paradigm based on the data transmission from one or more sources called Publishers to other elements called Subscribers in an asynchronous, non-blocking, and functional way. Streams combined with the Observable design pattern process all types of data. ...

December 11, 2021

Hexagonal Architecture and Microservices

Presentation Several technologies make it possible to expose or invoke business functions: SOA, REST / Web API, Messaging / JMS, and others. It is crucial to isolate the code that implements the business logic from the architectures used. The hexagonal architecture is an option to design microservices to address these challenges. Source: http://tpierrain.blogspot.com/2013/08/a-zoom-on-hexagonalcleanonion.html P/A stands for “Port/Adapter” and UC stands for “Use Case” High-level sequencing: A service receives and sends events to the “outside” via ports. A port is specific to a technology or a protocol: Servlet API, SOAP endpoint, JMS listener, or a JDBC driver. ...

December 10, 2021

Modern Website Architecture Overview in AWS

I have recently launched a new website snapvocab on the AWS cloud. This hands-on experience allowed me to practice what I learned in the AWS Cloud Developer Certification. After long hours working on it - more than I expected, I can tell you it was worth it. Nothing can ever replace having our hands dirty! From a functional point of view, it is simply a CRUD application that allows a user to manage a list of words with a paid plan. On the technical side, my goal was to leverage AWS services to go live as soon as possible and at a lower cost. ...

December 9, 2021