12 Eylül 2021 Pazar
/usr/local Dizini - Kaynak Kod İle Yapılan Kurulumlar
Giriş
/usr/local paket yöneticisi (package manager) uygulamalarda tarafından dikkate alınmaz.
/usr/local vs /opt
Paket yönetimine dahil olmadığı için kaynak kod derlenerek yapılan kurulumlar için kullanılabilir. Açıklaması şöyle. Kendi geliştirdiğimiz şeyleri de /usr/local/bin altına koyabiliriz.
Since these software projects are installed by extracting a .tar.gz file it sounds like they are self-contained applications and I would install them in /opt/<project>. Another common choice is /usr/local, but I prefer that for source based installs.
30 Ağustos 2021 Pazartesi
find komutu printf seçeneği
Specifier Olmayan Şeyler
Örnek
Boş dizinleri saymak için şöyle yaparızz
find . -maxdepth 1 -type d -empty -printf '\n' | wc -l
%h specifier - dirname
Örnek
*.c uzantılı dosyaların bulunduğu dizini yazdırmak için şöyle yaparız
group bilgisini verir.
Örnek
*.c uzantılı dosyaların bulunduğu dizini yazdırmak için şöyle yaparız
find . -type f -iname '*.c' -printf '%h\0' |
sort -z |
uniq -zc |%g specifier - group namegroup bilgisini verir.
%s specifier - File's size in bytes
Örnek
Örnek
Boyu en büyük dosyaları bulmak için şöyle yaparız
find . -mindepth 2 -printf "%s\t%p\n" | sort -n | cut -f 2- | tail -n $n%p specifier - file's nameÖrnek
Şöyle yaparız. %y ile d veya f karakteri dizin veya dosya olduğunu belirtir. %p ile dosya/dizin ismi gösterilir.
$ sudo find . -name 'example.com*' -printf "%y %p\n"
d ./archive/example.com
f ./renewal/example.com.conf
d ./live/example.com%P specifier - Dosyanın Bulunduğu Dizin İsmiAçıklaması şöyle. Yani en son dizinin ismini verir.
File's name with the name of the starting-point under which it was found removed.
Örnek
Şöyle yaparız
find /Volumes/SpeedyG -type d >> file.txt
# Çıktı şöyle
/Volumes/SpeedyG/folder1
/Volumes/SpeedyG/folder2
/Volumes/SpeedyG/folder2
find /Volumes/SpeedyG -type d -printf '%P\n' >> file.txt
# Çıktı şöyle
folder1
folder2
folder3Örnek
Şöyle yaparız
%u specifier - File's user name
user yani dosya sahibini (owner) verir. Şöyle yaparız.
$ find /usr/local/bin/ /bin/ -printf '%P\n'%t - File's last modification time
Örnek ver
user yani dosya sahibini (owner) verir. Şöyle yaparız.
$ sudo find /var -printf '%u:%g\n' | sort -t: -u
_apt:root
clamav:adm
clamav:clamav
colord:colord
daemon:daemon
lightdm:lightdm
lp:lp
man:root
speech-dispatcher:root
statd:nogroup
steeldriver:crontab
steeldriver:lightdm
steeldriver:steeldriver
syslog:adm
systemd-timesync:systemd-timesync
testuser:crontab
23 Ağustos 2021 Pazartesi
Kubernetes ve DNS
Giriş
Açıklaması şöyleHeadless ServiceYou can set up a DNS service for your Kubernetes cluster using an add-on.We all know how DNS works in the case of the internet. Every website has a unique address a.k.a domain (for e.g. www.amazon.com). A similar approach is applied in the case of service discovery in Kubernetes. DNS server watches the Kubernetes for new services and creates a set of DNS records for each one. If DNS has been enabled throughout your cluster then all Pods should automatically be able to resolve services by their DNS name.For instance, in our case, the DNS service and control plane (Kubernetes control panel) acting together create a DNS record of shoppingcart-service.dev-ns . Pods in the dev-ns the namespace should be able to find the service by doing a name lookup for shoppingcart-serviceKubernetes provides the concept of namespaces to segregate different concerns. For instances, you can have different namespaces for dev, test and prodenvironments.
Açıklaması şöyle
ÖrnekLuckily, Kubernetes allows clients to discover pod IPs through DNS lookups. Usually, when you perform a DNS lookup for a service, the DNS server returns a single IP — the service’s cluster IP. But if you tell Kubernetes you don’t need a cluster IP for your service (you do this by setting the clusterIP field to None in the service specification ), the DNS server will return the pod IPs instead of the single service IP. Instead of returning a single DNS A record, the DNS server will return multiple A records for the service, each pointing to the IP of an individual pod backing the service at that moment. Clients can therefore do a simple DNS A record lookup and get the IPs of all the pods that are part of the service. The client can then use that information to connect to one, many, or all of them.Setting the clusterIP field in a service spec to None makes the service headless, as Kubernetes won’t assign it a cluster IP through which clients could connect to the pods backing it.
Şöyle yaparız
apiVersion: v1kind: Servicemetadata:name: grpc-server-servicespec:clusterIP: Noneselector:app: grpc-serverports:- port: 80targetPort: 8001
19 Ağustos 2021 Perşembe
Packaging And Deployment
fiGiriş
Bir tane java projesini Linux'a kurmak için izlenen yol şöyleydi
1. mypackaging.sh çalıştırılır
Bu dosya maven'ı çalıştırır. maven bir tane zip üretir.
mvn -s ... -P ... clean package -D...
1. maven package phase çalışırken "makeself" kullanılarak tüm properties + jar + makeself ile kullanılan startup_script dosyasını içeren bir foo_installer.sh üretilir
2. maven package phase çalışırken "maven-assembly-plugin" kullanılarak bir zip üretilir. Aslında bu adım isteğe bağlı, makeself zaten her şeyi zipliyor gibi de düşünülebilir.
makeself
Örnek kullanım şöyle
setup.sh içindeki metodlar şöyleHere is an example, assuming the user has a package image stored in a /home/joe/mysoft, and he wants to generate a self-extracting package named mysoft.sh, which will launch the “setup” script initially stored in /home/joe/mysoft :makeself.sh /home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup
install_component(){mkdir -v $DEPLOYMENT_DIR/app/"$1"cp -v -r ./foo.jar $DEPLOYMENT_DIR/app/"$1"cp -v -r "$2" $DEPLOYMENT_DIR/app/"$1"}perform_installation(){install_component AFolder a.propertiesinstall_component AFolder b.properties...}print_usage(){echo "..."}
setup.sh çalışması şöyle
#Check if help is selectedif [ "$1" == '-h' ]thenprint_usageexit 1fiif (($EUID)); thenecho "Non-root user can not run"exit 1fiif [ -d $DEPLOYMENT_DIR ]thenecho "$DEPLOYMENT_DIR exists"elseecho "Creating folder " $DEPLOYMENT_DIRmkdir -p $DEPLOYMENT_DIRfiperform_installation
16 Ağustos 2021 Pazartesi
Firmware
Giriş
Firmware paketleri kernel ile dağıtılmaz. Açıklaması şöyle
Firmware için şu link takip ederizMany hardware device manufacturers do not embed firmware into their devices, they require firmware to be loaded into the device by the operating system's driver.Some other manufacturers embed an old version of the firmware but allow an updated version to be loaded by the driver - quite often the embedded version is ancient and/or buggy (and rarely, if ever, updated in the device itself because that might require changes to the manufacturing or testing process - this is generally a deliberate design decision. The rationale is that the embedded firmware version doesn't have to be good, it just has to resemble something that's minimally functional - updates can and should be loaded by the driver)The firmware files almost always have a license which is incompatible with the GPL (or even no explicit or discernible license, just an implied "right to use" by being distributed with the device itself and the Windows driver it comes with) and thus can not be distributed with the kernel itself, and has to be distributed as a separate package.
Firmware kurmak için önce yine apt install ile driver kurulurFirmware for the Linux kernel is distributed separately and has its own development tree.
Örnek
Şöyle yaparızz
sudo apt install firmware-ralinkdmesg çıktısında şunu alırız. İlk iki satırda firmware'in yüklendiği görülebilir.... ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin' ... ieee80211 phy0: rt2x00lib_request_firmware: Info - Firmware detected - version: 0.36... wlan0: authenticate with 30:23:03:41:73:67 ... wlan0: send auth to 30:23:03:41:73:67 (try 1/3) ... wlan0: authenticated ... wlan0: associate with 30:23:03:41:73:67 (try 1/3) ... wlan0: RX AssocResp from 30:23:03:41:73:67 (capab=0x411 status=0 aid=5) ... wlan0: associated ... IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
12 Ağustos 2021 Perşembe
run-parts komutu
Giriş
Çöken veya çalışmayan cron.daily işlerini elle tetiklemek için kullanılır. Örneğin günlük yedekleme (backup) çalışmadıysa.
Örnek
Şöyle yaparız
sudo run-parts /etc/cron.daily
Kaydol:
Kayıtlar (Atom)