29 Ekim 2021 Cuma

sed komutu

Giriş
sed kelimesi "stream editor" demek. Dosyadan okur ve bir şeyi değiştirerek ekrana basar. Eğer dosyayı değiştirmek istersek "-i" seçeneği ile çalıştırmak gerekir.

Birden Fazla Kademeli Sed
Noktalı virgül ile ayırırız. 
Örnek
Şöyle yaparız. Burada her kademe teker teker uygulanıyor
 sed 's/@/@A/g; s/\t/@B/g'
Örnek
Şöyle yaparız. Burada farklı olarak {...} kullanılıyor. Eşleşen kısım önce print ediliyor, daha sonra substitute ediliyor.
 sed '/é/{p;s//e/g;}'
Cümle Başına Konulan İşlemler
s/ İle Substitute
Cümlenin başına s koyarız

Örnek - Replace With Empty String
Baştaki 0 ve : karakterlerinden kurtulmak için şöyle yaparız
sed 's/^[0:]*//' file
Elimizde şöyle bir dosya olsun
00:00:30
00:01:30
00:30:00
01:30:00
30:00:00
Çıktı olarak şunu alırız
30
1:30
30:00
1:30:00
30:00:00
Örnek - Capture
Şöyle yaparız. Burada ilk 80 karakter yakalanıyor ve \1\n ile çıktıya veriliyor.
echo "..." | sed -E 's/(.{80}[^ ]*) /\1\n/g'

y/ İle Substitute
Cümlenin başına y koyarız. Açıklaması şöyle
... if your replacements are all single-character replacements, the y command is more efficient
Örnek
Şöyle yaparız. Eşleşen kısım önce print ediliyor, daha sonra substitute ediliyor.
 sed '/é/{p;y/é/e/;}'
Cümle Sonuna İşlemler
/d ile Delete
Cümlenin sonuna /d koyarız

/g ile Global
Normalde set satırdaki ilk eşleşmeyi bulup işini bitirince bir sonraki satıra geçer. Tüm eşleşmelerde iş yapsın istiyorsak cümlenin sonuna /g koyarız

/i ile Insensitive
Case insensitive olsun istersek cümlenin sonuna /i koyarız

/p ile Print
Cümlenin sonuna /p koyarız
Örnek
DEFINE ile başlayan satırları yazdırmak için şöyle yaparız. -n seçeneği sadece eşleşen satırları çıktı olarak verir
sed  -n -e '/^DEFINE/p' *.*
/q ile Quit
Cümlenin sonuna /q koyarız

Komut Seçenekleri
-E seçeneği
Sanırım düzenli ifade olduğunu belirtir

-n seçeneği
Sadece eşleşen satırları çıktı olarak verir

18 Ekim 2021 Pazartesi

/proc/PID/cmdline - procfs Dosya Sistemi

Giriş
Uygulamaya verilen komut satırı parametreleri okunabilir. Açıklaması şöyle
The overall accessibility and visibility of /proc/${pid} (including /proc/${pid}/cmdline) can be controlled using proc’s hidepid mount option, which was added in version 3.3 of the kernel. The gid mount option can be used to give full access to a specific group, e.g. so that monitoring processes can still see everything without running as root.

pvresize komutu

--setphysicalvolumesize seçeneği
Şöyle yaparız
pvresize /dev/vda2 --setphysicalvolumesize 132g

12 Ekim 2021 Salı

Kubernetes Probe'ları

Giriş
Kubernetes uygulamanın sağlıklı, hazır ve başladığını anlamak için 3 tane probe kullanır. Bunlar şöyle
liveness probe
readiness probe
startup probe
Açıklaması şöyle
Kubernetes has built-in probes for determining whether or not a Pod is alive and ready to serve incoming requests. This is known as the Health Check pattern, which is is supported in Quarkus using the SmallRye Health extension. The SmallRye Health extension is an implementation of the MicroProfile Health specification

Spring Boot applications can use the Kubernetes probes included in the Spring Boot Actuator starter; however, the Spring Boot Actuator only provides the endpoints and doesn't generate the necessary configuration or the required Kubernetes manifests. They will need to be created manually.

10 Ekim 2021 Pazar

sudoedit komutu

Örnek
Editor olarak VS Code kullanmak istiyorsak şöyle yaparız
SUDO_EDITOR="/snap/bin/code --wait" sudoedit /etc/fstab
Açıklaması şöyle. Yani sudoedit dosyanın kopyasını alır
Or you can use the sudoedit (or sudo -e) command, which works the same way as running 
crontab -e (where you edit a temporary file that are copied to the destination when you're 
done):

sudoedit /etc/hosts



8 Ekim 2021 Cuma

~/.inputrc Dosyası

Giriş
Bazı tuşlara kısa yol atamak için kullanılabilir.

Örnek
Şu satırı ekleriz. Böylece Ctrl + u tuşlarına basarsak bir üst dizine çıkarız
Control-u: "cd ../\n"

openssl rand aracı - Random Byte Üretir

Giriş
Random byte üretir. Açıklaması şöyle
SYNOPSIS
       openssl rand [-help] [-out file] [-rand file...]  [-writerand file]
       [-base64] [-hex] num

DESCRIPTION
   This command generates num random bytes using 
   cryptographically secure pseudo random number generator (CSPRNG).

Örnek
Şöyle yaparız.  20 tane hexadecimal sayı üretir.
$ /usr/bin/openssl rand -hex 20
51b40b347dfccefa9b4f8a13d36c4564760c2f82
Örnek
Şöyle yaparız.  741 byte'lık veri üretir.
/usr/bin/openssl rand -base64 741 > $TMPFILE
Örnek
Şöyle yaparız. 14 byte'lık rastgele veri üretir. Bunu da Base64 olarak kodekler.
openssl rand -base64 14