Author Archives: admin

What are the default usernames for Amazon EC2 Linux instances


title: “What are the default usernames for Amazon EC2 Linux instances”
date: 2022-02-09T08:55:56
slug: what-are-the-default-usernames-for-amazon-ec2-linux-instances


For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.
For a CentOS AMI, the user name is centos.
For a Debian AMI, the user name is admin.
For a Fedora AMI, the user name is ec2-user or fedora.
For a RHEL AMI, the user name is ec2-user or root.
For a SUSE AMI, the user name is ec2-user or root.
For an Ubuntu AMI, the user name is ubuntu.

aws cli cheatsheet


title: “aws cli cheatsheet”
date: 2022-02-07T14:05:59
slug: aws-cli-cheatsheet


List Images younger than 2016-04-01

aws ec2 describe-images --query 'Images[?CreationDate>=`2016-04-01`][]'

List Instances

aws ec2 describe-instances --output table

Use Variable in user_data


title: “Use Variable in user_data”
date: 2022-02-04T09:57:30
slug: use-variable-in-user_data


resource "aws\_instance" "web" {
ami = "ami-xxxxxxxxxxxxxxxxx"
instance\_type = "t2.micro"
user\_data = templatefile("${path.module}/init.ps1", {
environment = var.env
hostnames = {"dev":"devhost","test":"testhost","prod":"prodhost"}
})
tags = {
Name = "HelloWorld"
}
}
cat init.sh
#!/bin/bash
echo ${ip} > /tmp/ip
apt update
apt -y upgrade
curl -sfL https://get.k3s.io | INSTALL\_K3S\_EXEC="--tls-san ${ip}" sh -s -

Oder eine Variable definieren um diese öfter zu verwenden:

locals {
web\_user\_data = templatefile("${path.module}/init.ps1", {
environment = var.env
hostnames = {"dev":"devhost","test":"testhost","prod":"prodhost"}
})
}
resource "aws\_instance" "web" {
ami = "ami-xxxxxxxxxxxxxxxxx"
instance\_type = "t2.micro"
user\_data = local.web\_user\_data
tags = {
Name = "HelloWorld"
}
}

Query Elasticsearch Index with Curl


title: “Query Elasticsearch Index with Curl”
date: 2021-10-20T12:44:18
slug: query-elasticsearch-index-with-curl


curl -s -k --cert /etc/elasticsearch//secret/admin-cert --key /etc/elasticsearch//secret/admin-key https://localhost:9200/\_cat/indices

CheetSheet


title: “CheetSheet”
date: 2021-07-21T08:08:15
slug: cheetsheet-2


char name[] = "Thomas";
bool active = true;
double workingdays = {1,4,6}

Define Structure with Alias and access it:

typedef struct Point{
 int x;
 int y;
} Point;

Point one, two;
one.x=5;
one.y=7;

Nested Structure:

typedef struct Point{
 int x;
 int y;
} Point

typedef struct Location{
 int number;
 Point p;
} Location

Passing struct to function

#include
#include

struct student
{
 int id;
 char name[20];
 float percentage;
};

void func(struct student \*record);

int main()
{
 struct student record;

 record.id=1;
 strcpy(record.name, "Raju");
 record.percentage = 86.5;

 func(&record);
 return 0;
}

void func(struct student \*record)
{
 printf(" Id is: %d
", record->id);
 printf(" Name is: %s
", record->name);
 printf(" Percentage is: %f
", record->percentage);
}

Filter all Pids


title: “Filter all Pids”
date: 2021-07-05T22:21:23
slug: filter-all-pids


Program ID to filter. Use 0x2000 to select all PIDs

install k3s


title: “install k3s”
date: 2021-07-04T09:54:22
slug: install-k3s


Install k3 with custom cerificate

curl -sfL https://get.k3s.io | INSTALL\_K3S\_EXEC="--tls-san 213.95.154.184" sh -s -

Uninstall k3s

/usr/local/bin/k3s-uninstall.sh

Get kube config:

cat /etc/rancher/k3s/k3s.yaml

Timestamp Parser


title: “Timestamp Parser”
date: 2021-06-28T12:57:55
slug: timestamp-parser


An example of such filer from fluent-bit can be seen below:

[PARSER]

Name myapp_parser

Time field example: \”date\”:\”Mon Jul 22 2019 21:58:41\”

Time_Key date

Time_Format %a %b %d %Y %H:%M:%S

Time_Keep On

Format json

Command | Decoder | Field | Optional Action

=============|==================|=================

Decode_Field json log

Latest OC File


title: “Latest OC File”
date: 2021-06-23T08:20:45
slug: latest-oc-file


wget https://mirror.openshift.com/pub/openshift-v4/x86\_64/clients/ocp/latest/openshift-client-linux.tar.gz