Skip to content

Latest commit

 

History

History
533 lines (462 loc) · 17 KB

File metadata and controls

533 lines (462 loc) · 17 KB

Notes

TABLE OF CONTENT

Install Doom Emacs

Git 2.23+

sudo pacman -S git

Emacs 27.1+ (27.2 is recommended, or native-comp).

sudo pacman -S emacs

ripgrep 11.0+

sudo pacman -S rg

GNU find

Should be already installed.

OPTIONAL: fd 7.3.0+ (improves file indexing performance for some commands)

sudo pacman -S fd

Test Go in org mode

Need to install by: M-x -> package install -> ob-go And restart doom by: M-x -> doom/reload

fmt.Println("Hello World!")

Test sudo with bash

echo $pw | sudo -S echo "hello"

Test sudo with bash and tramp

sudo echo "hello"

How to prepare bootable pendrive on linux(Option 1)

Check pendrive is visible in system

df -h

Unmount pendrive

sudo umount /dev/sda1

Write ISO to pendrive(will block emacs for time of writing)

sudo dd bs=4M if=/home/wojtek/ISO/arcolinuxb-leftwm-v22.01.10-x86_64.iso of=/dev/sda status=progress oflag=sync

How to prepare bootable pendrive on linux(Option 2)

Check block devices

lsblk | grep -v loop

Unmount pendrive

umount /dev/sda1

Remove data from pendrive

wipels --all /dev/sda

Write ISO to pendrive

cat /path/to/iso > /dev/sda

Linux namespace networking

Network namespaces are use by containers to separete networking. Process on container will have pid 1, but the same process in host will have another pid.

ps aux | grep nginx

Host has own interface to communicate to LAN - eth0. Host also has own arp and route table to store network information. When container is created, there is created namespece. Then container also have own arp and route table.

To create network ns:

sudo ip netns add red
sudo ip netns add blue

Check ip netns

ip netns

To list interfaces in host:

ip -br link

To list interfaces in namespace:

ip netns exec red ip -br link

Or simpler:

ip -br -n red link

In namespaces there is visible only loopback interface. There is no other interface from host. The same is for arp and route table.

Arp table for host:

arp

Arp for namespece

ip netns exec red arp

Route for host:

route

Route for namespece:

ip netns exec red route

To connect to namespaces there is neccecery to create pipe or “virtual cabel” between them:

ip link add veth-red type veth peer name veth-blue
ip link set veth-blue up
ip link set veth-red up

Check links:

ip -br link

Attach red cabel to red namespace:

ip link set veth-red netns red

Attach blue cabel to blue namespace:

ip link set veth-blue netns blue
ip -br -n red link
ip -br -n blue link

Add address ip for both cabels:

ip -n red addr add 192.168.15.1 dev veth-red
ip -n blue addr add 192.168.15.2 dev veth-blue
ip -br -n red a | grep -v lo
ip -br -n blue a | grep -v lo

Switch on both devices:

ip -n red link set veth-red up
ip -n blue link set veth-blue up
ip -br -n red a | grep -v lo
ip -br -n blue a | grep -v lo

Check connection between namespaces

ip netns exec red ping -c 3 192.168.15.2
ip netns exec blue arp

ZjebanOS

Nie dziala ls

whereis ls /bin/ls type ls ls is aliased to `echo segmentation fault;#` alias alias ls=’echo segmentation fault;#’ unalias ls

nginx

$ /etc/init.d/nginx start

nginx: [emerg] unknown directive “listen 80” in /etc/nginx/conf.d/default.conf:5 nginx: configuration file /etc/nginx/nginx.conf test failed

$ vim /etc/nginx/conf.d/default.conf

wyglada wszystko ok

$ grep listen /etc/nginx/conf.d/default.conf | hexdump -c

0000000 \t l i s t e n 302 240 8 0 d e f a 0000010 u l t _ s e r v e r ; \n

$ netstat -plnt (p drukowanie nazwy procesu, l listen, n bez rozwiazywania nazw, t tcp)

Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 241/nginx.conf

$ curl localhost

<html> <head><title>301 Moved Permanently</title></head> <body> <center><h1>301 Moved Permanently</h1></center> <hr><center>openresty</center> </body> </html>

$ curl -I localhost

HTTP/1.1 301 Moved Permanently server: openresty date: Tue, 08 Feb 2022 16:23:52 GMT content-type: text/html content-length: 166 location: http://www.pornhub.com/ x-request-id: 62029918-42FE72290050552A-477BB49 strict-transport-security: max-age=63072000; includeSubDomains; preload

cat /etc/hosts

66.254.114.41 localhost

vim /etc/hosts

127.0.0.1 localhost

curl localhost

<html> <head><title>502 Bad Gateway</title></head> <body bgcolor=”white”> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html>

cat /etc/nginx/conf.d/default.conf

server { listen 80 default_server;

location / { proxy_pass http://127.0.0.1:8080; }

access_log /var/log/nginx/serwisy/obliczenia.log main;

location = /404.html { internal; } }

Nginx przekierowuje wszytko na port 8080

netstat -plnt

Dziala tylko nginx na porcie 80

apache

/etc/init.d/apache2 start

Can’t load /lib/ld-musl-x86_64.so.2 (0x7f57f1c15000)

ls -l /lib/ld-musl-x86_64.so.2

istnieje tylko /lib/ld-musl-x86_64.so.1

ln -s /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.2

/etc/init.d/apache2 restart

Can’t load /lib/ld-musl-x86_64.so.2 (0x7f57f1c15000) Can’t load /lib/ld-musl-x86_64.so.2 (0x7f57f1c15000)

strace -s1000 -ff -o /tmp/testy /etc/init.d/apache2 restart (-ff podazanie za dziecmi, -o output)

cd /tmp

grep -rli ‘ld-musl-x86_64.so.2’ testy* (-r recursive -l nazwa plika -i case insensitive)

apache od razu rzuca bledem zaraz po otwarciu pliku

/etc/init.d/apache2 restart

nie moze pisac do etc/sshd ale po co? ale wyzej jest: AH00526: Syntax error on line 1 of /etc/apache2/conf.d/security.conf:

rm /etc/apache2/conf.d/security.conf

netstat -plnt

curl localhost

znowu openresty. Cos nadpisalo. jakis cron

ps auxf

PID USER TIME COMMAND 1 root 0:00 /sbin/init 94 root 0:00 /bin/bash 108 root 0:00 ash 203 root 0:00 vim /etc/nginx/conf.d/default.conf 241 root 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf 242 nginx 0:00 nginx: worker process 243 nginx 0:00 nginx: worker process 244 nginx 0:00 nginx: worker process 245 nginx 0:00 nginx: worker process 271 root 0:00 agetty apache2 binfmt bootmisc consolefont devfs dmesg fsck functions.sh hostnam 502 root 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 506 apache 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 507 apache 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 508 apache 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 509 apache 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 510 apache 0:00 /usr/sbin/httpd -d /var/www -f /etc/apache2/httpd.conf -k start 516 root 0:00 ps auxf

crontab -l

*/15 * * * * run-parts /etc/periodic/15min -> cos zmienia sie co 15 minut 0 * * * * run-parts /etc/periodic/hourly 0 2 * * * run-parts /etc/periodic/daily 0 3 * * 6 run-parts /etc/periodic/weekly 0 5 1 * * run-parts /etc/periodic/monthly

grep -rli ‘66.254.114.41’ etc

curl localhost

403 z apacha-> logi -> /etc/strona

cd etc/apache2

grep -rli ‘index.html’ . -> httpd.conf

vim httpd.conf -> /index.http -> dopisanie po spacji index.php

/etc/init.d/apache2 restart

curl localhost ->

-> dziala, ale nie pokazuje wyniku -> spawdzenie index.php -> zapisuje do /cache/obliczenia -> cache ma prawa 777 -> obliczenia ma 770 dla usera i grupy nginx -> chmod 777 obliczenia

Network configuration

With ifupdown

Used in older systems In below directory should be files starting with ifcfg- (ifcfg-eth0)

ls /etc/sysconfig/network-scripts

ifcofng-eth0 file

DEVICE=eth0
HWADDR=08:00:27::1C:7C:F4 -> optional
TYPE=Ethernet
UUID=
ONBOOT=on -> optional
NM_CONTROLLED=yes -> Manage by Network Manager
BOOTPROTO=dhcp/none -> if none, below entries neccecery
IPADDR=10.0.1.40
NETMASK=255.255.255.0
GATEWAY=10.0.1.1
DNS1=10.0.1.1

Switch off connection

ifdown etho

Switch on connection

ifup eth0

Environment

SaaS-Aware-Video-Module

Name CloudName SubscriptionId State IsDefault ---------------------------------- ----------- ------------------------------------ ------- ----------- MSI-SWE-PARTNER-STAGE-AZURECLOUD-0 AzureCloud 74545c1b-2b6d-4324-acda-bd921793e015 Enabled True MSI-SWE-CIE-STAGE-AZURECLOUD AzureCloud d521004d-004e-4013-bb23-fe359ac90321 Enabled False MSI-SWE-CIE-QA AzureCloud 29630a06-fdc5-486d-99c3-8ea14aa8cd2e Enabled False

Terraform

Potrzebne, zeby dzialalo w pipeline.

terraform {
  backend "azurerm" {
    resource_group_name  = "aware-backend-event-hubs"
    storage_account_name = "saasawarebackendev321"
    container_name       = "terraform_dev"
    key                  = "eventhub.tfstate"
  }
}

Terraform import on desk

provider "azurerm" {
  features {}
  skip_provider_registration = true
}

resource "azurerm_eventhub_namespace" "main" {
  name                = "aware-backend-event-hubs"
  location            = "eastus"
  resource_group_name = "saas-aware-backend-eastus"
  sku                 = "Standard"
  capacity            = 1
}