Linux Tricks
AWK is a powerful command line tool for manipulating and filtering text in Linux. It can be used to extract certain data from files, matching patterns, performing calculations on text, and making decisions based on the results of these calculations, Hereโฆ
1. Print out the third column of the file data.txt
2. Print out only the lines in data.txt where the first column is greater than 5
3. Print out the second and third columns of data.txt separated by a comma
4. To print all lines in a file that contain the word "Error", like
5. To print only columns 3 and 7 of a delimited file:
6. To print the total of a particular field (column) in a comma-separated file:
7. To output all records between line numbers 10 and 15 in a file:
8. To print only the elements in the third column of a file with comma-separated values that are equal to "Female"
9. To print the first 3 lines of a file with awk (equals to head command):
10. Use
awk '{ print $3 }' data.txt2. Print out only the lines in data.txt where the first column is greater than 5
awk '$1 > 5 {print $0}' data.txt3. Print out the second and third columns of data.txt separated by a comma
awk '{print $2 "," $3}' data.txt4. To print all lines in a file that contain the word "Error", like
grep:awk '/Error/' data.txt
5. To print only columns 3 and 7 of a delimited file:
awk '{print $3, $7}' data.txt6. To print the total of a particular field (column) in a comma-separated file:
awk '{total+=$5} END {print total}' data.txt7. To output all records between line numbers 10 and 15 in a file:
awk 'NR>=10 && NR<=15' data.txt
8. To print only the elements in the third column of a file with comma-separated values that are equal to "Female"
awk -F "," '$3 == "Female" {print $3}' data.txt9. To print the first 3 lines of a file with awk (equals to head command):
awk 'NR <= 3' data.txt
10. Use
for loop to replace spaces with '|'awk '{ for (i=2; i<=NF; i++) $i = "|"$i } { print }' data.txt๐2
This table shows the Unix file permissions and their corresponding binary values. The first column represents the permission code, while the second and third columns represent the readable (unix decimal) and writeable (binary equivalent) modes of the file respectively. The last column displays the Kubernetes configMaps default mode for each permission level.
#Kubernetes
#Linux
here is Stackoverflow URL:
https://stackoverflow.com/questions/73365727/mounting-a-configmap-as-a-volume-in-kubernetes-how-do-i-calculate-the-value-of
#Kubernetes
#Linux
here is Stackoverflow URL:
https://stackoverflow.com/questions/73365727/mounting-a-configmap-as-a-volume-in-kubernetes-how-do-i-calculate-the-value-of
๐2
Download multiple files from a list of urls using
with
With
#curl @linuxtricks
curl
1.1 create a file with the list of urls, e.g. urls.txt:https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.2.0-amd64-netinst.isoWith
https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-edu-12.2.0-amd64-netinst.iso
https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-mac-12.2.0-amd64-netinst.iso
xargs
```xargs -n 1 curl -O < urls.txt```
with
for
```for url in $(cat urls.txt); do curl -O $url; done```
With
while
```while read url; do curl -O $url; done < urls.txt```
#curl @linuxtricks
๐3
Screenshot from 2024-02-03 00-23-08.png
659.4 KB
๐ Secure your Kubernetes!
Install kube-hunter with:
Run it with
and choose your scan.
In the attached screen shot, i selected "Interface scanning", and it detected a vulnerability on my "kind cluster"
#Kubernetes #Security
Install kube-hunter with:
pip install kube-hunter
Run it with
kube-hunter
and choose your scan.
In the attached screen shot, i selected "Interface scanning", and it detected a vulnerability on my "kind cluster"
#Kubernetes #Security
๐3
#useful_commands
bandwhich is a command-line utility that provides real-time, comprehensive insights into your network usage.
It's written in Rust and can display network usage by process, connection, or remote IP/hostname.
Here are some of the things you can do with
- Display only the remote addresses table:
- Show DNS queries:
- Show total (cumulative) usage:
- Monitor a specific network interface:
- Show DNS queries with a given DNS server:
https://github.com/imsnif/bandwhich
bandwhich is a command-line utility that provides real-time, comprehensive insights into your network usage.
It's written in Rust and can display network usage by process, connection, or remote IP/hostname.
Here are some of the things you can do with
bandwhich:- Display only the remote addresses table:
bandwhich --addresses`
- Show DNS queries:
bandwhich --show-dns
- Show total (cumulative) usage:
bandwhich --total-utilization
- Monitor a specific network interface:
bandwhich --interface eth0
- Show DNS queries with a given DNS server:
bandwhich --show-dns --dns-server dns_server_ip
https://github.com/imsnif/bandwhich
GitHub
GitHub - imsnif/bandwhich: Terminal bandwidth utilization tool
Terminal bandwidth utilization tool. Contribute to imsnif/bandwhich development by creating an account on GitHub.
๐4
Have you ever encountered an error like this when using crictl with containerd?
This error occurs because crictl is trying to connect to Docker, but Docker isnโt running or installed. If youโre using containerd, you need to tell crictl to use it instead.
Create or modify the crictl configuration file, typically located at /etc/crictl.yaml
Then add the following lines to it:
Run again crictl ps , thatโs it!
#containerd
FATA[0000] listing containers: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory"
This error occurs because crictl is trying to connect to Docker, but Docker isnโt running or installed. If youโre using containerd, you need to tell crictl to use it instead.
Create or modify the crictl configuration file, typically located at /etc/crictl.yaml
vim /etc/crictl.yaml
Then add the following lines to it:
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false
Run again crictl ps , thatโs it!
#containerd
๐1๐1
Krew is the plugin manager for the kubectl command-line tool.
With Krew, you can easily manage over 100 kubectl plugins currently distributed.
Here is a list of kubectl plugins:
https://krew.sigs.k8s.io/plugins/
Installation:
https://krew.sigs.k8s.io/docs/user-guide/setup/install/
Here is top 5 Kubectl plugins:
1. kubectx and kubens: These tools allow you to switch between contexts (clusters) and namespaces via kubectl faster.
https://github.com/ahmetb/kubectx
2. Ingress-nginx: This is the second most popular kubectl plugin.
https://kubernetes.github.io/ingress-nginx/kubectl-plugin/
3. Cert-manager: This plugin helps you automate the management and issuance of TLS certificates from various issuing sources.
https://github.com/cert-manager/cert-manager
4. Popeye: Popeye is a utility that scans live Kubernetes cluster and reports potential issues with deployed resources and configurations.
https://popeyecli.io/
5. Kyverno: Kyverno is a policy engine designed for Kubernetes.
https://github.com/kyverno/kyverno
-------------------
#kubernetes
#kubectl
With Krew, you can easily manage over 100 kubectl plugins currently distributed.
Here is a list of kubectl plugins:
https://krew.sigs.k8s.io/plugins/
Installation:
https://krew.sigs.k8s.io/docs/user-guide/setup/install/
Here is top 5 Kubectl plugins:
1. kubectx and kubens: These tools allow you to switch between contexts (clusters) and namespaces via kubectl faster.
https://github.com/ahmetb/kubectx
2. Ingress-nginx: This is the second most popular kubectl plugin.
https://kubernetes.github.io/ingress-nginx/kubectl-plugin/
3. Cert-manager: This plugin helps you automate the management and issuance of TLS certificates from various issuing sources.
https://github.com/cert-manager/cert-manager
4. Popeye: Popeye is a utility that scans live Kubernetes cluster and reports potential issues with deployed resources and configurations.
https://popeyecli.io/
5. Kyverno: Kyverno is a policy engine designed for Kubernetes.
https://github.com/kyverno/kyverno
-------------------
#kubernetes
#kubectl
GitHub
GitHub - ahmetb/kubectx: Faster way to switch between clusters and namespaces in kubectl
Faster way to switch between clusters and namespaces in kubectl - ahmetb/kubectx
๐2
Skopeo
This tool is used for working with remote image registeries.
e.g:
1. Copy an image from one registry to a private registry
2. Delete an image:
3. Inspect image details
4. List tags of an image
5. Sync all tags of an image to a USB
The above command downloads all tags of the busybox image to the /media/usb directory.
more info:
https://github.com/containers/skopeo?tab=readme-ov-file
#docker
This tool is used for working with remote image registeries.
e.g:
1. Copy an image from one registry to a private registry
skopeo copy docker://docker.io/library/nginx:latest docker://registry.example.com/nginx:latest
2. Delete an image:
skopeo delete docker://registry.example.com/nginx:latest
3. Inspect image details
skopeo inspect docker://docker.io/library/nginx:latest
4. List tags of an image
skopeo list-tags docker://docker.io/nginx
5. Sync all tags of an image to a USB
skopeo sync --src docker --dest dir registry.example.com/busybox /media/usb
The above command downloads all tags of the busybox image to the /media/usb directory.
more info:
https://github.com/containers/skopeo?tab=readme-ov-file
#docker
GitHub
GitHub - containers/skopeo: Work with remote images registries - retrieving information, images, signing content
Work with remote images registries - retrieving information, images, signing content - containers/skopeo
๐ฅ4๐2
Linux Tricks
A Simple Command to Trigger SCSI Bus Rescan and List Block Devices It's useful for detecting new hard drives in Linux for host_dir in `ls /sys/class/scsi_host/*`; do echo $host_dir;echo "- - -" > $host_dir/scan;ls /dev/sd*; done #linux #disk #vmware
Resized an already exists disk in VMware but Linux still shows the old size?
I changed the size of my disk /dev/sdb from 10G to 50G, but Linux still showed 10G. To fix it without rebooting, I ran this:
After that, the new size showed up right away!
#linux #disk #vmware
I changed the size of my disk /dev/sdb from 10G to 50G, but Linux still showed 10G. To fix it without rebooting, I ran this:
echo 1 > /sys/class/block/sdb/device/rescan
After that, the new size showed up right away!
#linux #disk #vmware
๐3โค1๐1
Deploying Leader-Worker Pods Easily with LeaderWorkerSet (LWS)
The kubernetes-sigs/lws (LeaderWorkerSet) project provides an API for Kubernetes that lets you deploy and manage a group of pods as a single unit of replication. It is especially useful for scenarios where you need to run multiple pods with different roles (such as leader and worker) in a coordinated and manageable way. The main goal is to simplify deployment and management of complex workloads in Kubernetes.
More info:
https://github.com/kubernetes-sigs/lws
Project site: https://lws.sigs.k8s.io
#kubernetes
The kubernetes-sigs/lws (LeaderWorkerSet) project provides an API for Kubernetes that lets you deploy and manage a group of pods as a single unit of replication. It is especially useful for scenarios where you need to run multiple pods with different roles (such as leader and worker) in a coordinated and manageable way. The main goal is to simplify deployment and management of complex workloads in Kubernetes.
More info:
https://github.com/kubernetes-sigs/lws
Project site: https://lws.sigs.k8s.io
#kubernetes
Linux Tricks
Deploying Leader-Worker Pods Easily with LeaderWorkerSet (LWS) The kubernetes-sigs/lws (LeaderWorkerSet) project provides an API for Kubernetes that lets you deploy and manage a group of pods as a single unit of replication. It is especially useful for scenariosโฆ
Here is an example of it's usage:
It's useful for Batch processing, that Leader coordinates task distribution and Workers execute jobs.
apiVersion: lws.sigs.k8s.io/v1alpha1
kind: LeaderWorkerSet
metadata:
name: example
spec:
replicas: 2
leaderTemplate:
spec:
containers:
- name: leader
image: busybox
command: ["sh", "-c", "echo I am the leader; sleep 3600"]
workerTemplate:
spec:
containers:
- name: worker
image: busybox
command: ["sh", "-c", "echo I am a worker; sleep 3600"]
workerCount: 3
It's useful for Batch processing, that Leader coordinates task distribution and Workers execute jobs.
๐1
Whatโs Air?
A CLI tool for Go that watches your code, rebuilds, and restart the app(Go program) automatically.
Attention: Itโs for development, not production.
Quick install:
With Go 1.25+:
Getting started:
Go to your project root:
Init default config:
Run:
Or use a config file:
Pros:
Colorful logs, customizable build/run commands
Exclude folders from watching
Docker/Podman friendly (image: cosmtrek/air)
Cons:
Dev-only, not a production hot-deploy
Rebuild time on large projects
Might need PATH/GOPATH fixes if โairโ isnโt found
GPLv3 license (FYI)
GithuB
#golang
#develop_in_linux
#go
A CLI tool for Go that watches your code, rebuilds, and restart the app(Go program) automatically.
Attention: Itโs for development, not production.
Quick install:
With Go 1.25+:
go install github.com/air-verse/air@latest
Getting started:
Go to your project root:
cd /path/to/project
Init default config:
air init
Run:
air
Or use a config file:
air -c .air.toml
Pros:
Colorful logs, customizable build/run commands
Exclude folders from watching
Docker/Podman friendly (image: cosmtrek/air)
Cons:
Dev-only, not a production hot-deploy
Rebuild time on large projects
Might need PATH/GOPATH fixes if โairโ isnโt found
GPLv3 license (FYI)
GithuB
#golang
#develop_in_linux
#go
GitHub
GitHub - air-verse/air: โ๏ธ Live reload for Go apps
โ๏ธ Live reload for Go apps. Contribute to air-verse/air development by creating an account on GitHub.
๐ฅ1
The best habit is taking notes for every fix you apply.
Not a big document.
Just an application, a short file, or a small wiki, or a markdown note.
I strongly recommend, using Joplin:
https://github.com/laurent22/joplin
It could integrate with S3 and you can have your notes, every where.
Write:
1. what broke
2. the exact command you used
3. why it worked
This prevents repeat mistakes and saves hours of debugging in the future.
This is how you grow fast.
This is how you stay sharp.
Not a big document.
Just an application, a short file, or a small wiki, or a markdown note.
I strongly recommend, using Joplin:
https://github.com/laurent22/joplin
It could integrate with S3 and you can have your notes, every where.
Write:
1. what broke
2. the exact command you used
3. why it worked
This prevents repeat mistakes and saves hours of debugging in the future.
This is how you grow fast.
This is how you stay sharp.
GitHub
GitHub - laurent22/joplin: Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Androidโฆ
Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS. - laurent22/joplin
๐2โค1
Last week my Suse Linux had a long boot time, when this problem occurred, you can see what takes so long on the boot screen by pressing ESC key or debug it using the following command:
systemd-analyze blame
๐6
Save Docker Images with Compression
Save space by compressing your Docker images.
Without compression, using
gzip (fast):
bzip2 (smaller file):
Load gzip:
Load bzip2:
Pick gzip for speed, bzip2 for smaller files.
Real example: A 17.4GB DevDocs image compressed down to just 3.4GB with bzip2. That's an 80% reduction in size!
@linuxtricks
#docker
#compress
Save space by compressing your Docker images.
Without compression, using
docker save alone creates a raw tar file that takes up the full size of all image layers combined. This can quickly eat up disk space, makes transfers slower, and wastes bandwidth when sharing images with teammates. For large images, an uncompressed tar file can be several gigabytes, making it impractical to store or send.gzip (fast):
docker save nginx:latest | gzip > nginx.tar.gz
bzip2 (smaller file):
docker save nginx:latest | bzip2 > nginx.tar.bz2
Load gzip:
gunzip -c nginx.tar.gz | docker load
Load bzip2:
bunzip2 -c nginx.tar.bz2 | docker load
Pick gzip for speed, bzip2 for smaller files.
Real example: A 17.4GB DevDocs image compressed down to just 3.4GB with bzip2. That's an 80% reduction in size!
@linuxtricks
#docker
#compress
๐2
Very important security warning
Version
The dangerous part:
This does NOT require
The package includes a malicious file named
โ-
What data can be stolen? (According to this report)
1. SSH keys
2. API keys and passwords (from environment variables)
3. AWS / Azure / GCP credentials
4. Kubernetes configs and service tokens
5. Docker and package manager configs
6. bash, zsh, MySQL, Redis histories
7. system and network information
8. CI/CD configs and secrets
9. SSL/TLS private keys
This malware aggressively scans common paths and config files to collect as much sensitive data as possible.
All collected data is encrypted (AES-256) and the key is secured using RSA, then sent to an external server:
https://models.litellm.cloud/
Note: this domain is NOT the official litellm domain.
โ-
If you have installed this version:
1. Check if this file exists:
Also check:
- virtualenvs
- user site-packages (
- system-wide Python paths
2. If found, you should IMMEDIATELY:
* rotate ALL API keys
* generate new SSH keys
* rotate cloud credentials
* revoke tokens and sessions
* review access logs and unusual outbound traffic
3. Remove the package and upgrade to a safe version
โโ
Important:
Other versions may also be affected. Do NOT assume only
โ-
This is a strong reminder:
No dependency should ever be fully trusted, even if it is popular.
โ-
Discovery date: March 24, 2026
Source: https://github.com/BerriAI/litellm/issues/24512
#security #python
Version
1.82.8 of the litellm package is compromised and is actively collecting sensitive system data without your knowledge and sending it to an external server. This is a serious Supply Chain Attack and must be treated as critical.The dangerous part:
This does NOT require
import litellmThe package includes a malicious file named
litellm_init.pth inside site-packages..pth files in site-packages are automatically executed when the Python interpreter starts (via the site module), so the payload runs silently in the background.โ-
What data can be stolen? (According to this report)
1. SSH keys
2. API keys and passwords (from environment variables)
3. AWS / Azure / GCP credentials
4. Kubernetes configs and service tokens
5. Docker and package manager configs
6. bash, zsh, MySQL, Redis histories
7. system and network information
8. CI/CD configs and secrets
9. SSL/TLS private keys
This malware aggressively scans common paths and config files to collect as much sensitive data as possible.
All collected data is encrypted (AES-256) and the key is secured using RSA, then sent to an external server:
https://models.litellm.cloud/
Note: this domain is NOT the official litellm domain.
โ-
If you have installed this version:
1. Check if this file exists:
site-packages/litellm_init.pth
Also check:
- virtualenvs
- user site-packages (
~/.local/...) - system-wide Python paths
2. If found, you should IMMEDIATELY:
* rotate ALL API keys
* generate new SSH keys
* rotate cloud credentials
* revoke tokens and sessions
* review access logs and unusual outbound traffic
3. Remove the package and upgrade to a safe version
โโ
Important:
Other versions may also be affected. Do NOT assume only
1.82.8 is impacted.โ-
This is a strong reminder:
No dependency should ever be fully trusted, even if it is popular.
โ-
Discovery date: March 24, 2026
Source: https://github.com/BerriAI/litellm/issues/24512
#security #python
GitHub
[Security]: CRITICAL: Malicious litellm_init.pth in litellm 1.82.8 โ credential stealer ยท Issue #24512 ยท BerriAI/litellm
[LITELLM TEAM] - For updates from the team, please see: #24518 [Security]: CRITICAL: Malicious litellm_init.pth in litellm 1.82.8 PyPI package โ credential stealer Summary The litellm==1.82.8 wheel...
Linux Tricks
Very important security warning Version 1.82.8 of the litellm package is compromised and is actively collecting sensitive system data without your knowledge and sending it to an external server. This is a serious Supply Chain Attack and must be treated asโฆ
If you are on Linux Or FreeBSD, these commands can help you find the malicious file:
Run this in your project directory. If needed, replace
If you have locate installed:
To check if your project uses litellm:
# Run in root of your project:
find . -type f -name 'litellm_init.pth'
# Check in user local packages:
find ~/.local/ -type f -name 'litellm_init.pth'
Run this in your project directory. If needed, replace
. with the full path.If you have locate installed:
updatedb
locate 'litellm_init.pth'
To check if your project uses litellm:
# recursive search in current directory:
grep litellm -nr ./
# check only requirements.txt:
grep litellm -n requirements.txt
๐2
AI Just Changed Security Forever
Something major happened in March 2026 that nobody saw coming.
What's happening:
AI agents are now finding 5-10 real Linux zero-day vulnerabilities EVERY DAY
They're no longer producing junk reports โ they're finding actual critical bugs
Human maintainers can't keep up with reviewing them all
The numbers:
GitHub hit 14 billion commits in 2026
Security researchers are overwhelmed
Companies like Anthropic and OpenAI have AI systems running 24/7 hunting for vulnerabilities
Why this matters:
Bad actors could use the same AI to find vulnerabilities before they're patched
Open-source maintainers are facing a "review crisis" โ too many reports to check
The race is on: who finds the bugs first?
The bottom line: AI is now better than humans at finding security holes. This is both exciting and terrifying.
Read more: https://aiforautomation.io/news/2026-04-05-ai-agents-just-cracked-open-source-security-linux-zero-days
#ai #security #zeroday #devsecops #cybersecurity #infosec
Something major happened in March 2026 that nobody saw coming.
What's happening:
AI agents are now finding 5-10 real Linux zero-day vulnerabilities EVERY DAY
They're no longer producing junk reports โ they're finding actual critical bugs
Human maintainers can't keep up with reviewing them all
The numbers:
GitHub hit 14 billion commits in 2026
Security researchers are overwhelmed
Companies like Anthropic and OpenAI have AI systems running 24/7 hunting for vulnerabilities
Why this matters:
Bad actors could use the same AI to find vulnerabilities before they're patched
Open-source maintainers are facing a "review crisis" โ too many reports to check
The race is on: who finds the bugs first?
The bottom line: AI is now better than humans at finding security holes. This is both exciting and terrifying.
Read more: https://aiforautomation.io/news/2026-04-05-ai-agents-just-cracked-open-source-security-linux-zero-days
#ai #security #zeroday #devsecops #cybersecurity #infosec
aiforautomation.io
AI Agents Find Real Linux Zero-Days: Open-Source Security
AI agents now find real Linux zero-days โ 5โ10 per day. Open-source maintainers face a review crisis as GitHub hits 14B commits in 2026.
๐3๐ฏ1
Forwarded from Akbariโs Channel
โผ๏ธ๐จ MAJOR IMPACT: AI just found an 18-year-old NGINX critical remote code execution vulnerability. It has been disclosed on GitHub including PoC code.
- Affects NGINX 0.6.27 through 1.30.0
- Triggered via the rewrite and set directives in config
- Update NGINX ASAP
- NGINX is a widely used HTTP web server, be sure to check its prevalence in other products
https://github.com/DepthFirstDisclosures/Nginx-Rift
- Affects NGINX 0.6.27 through 1.30.0
- Triggered via the rewrite and set directives in config
- Update NGINX ASAP
- NGINX is a widely used HTTP web server, be sure to check its prevalence in other products
https://github.com/DepthFirstDisclosures/Nginx-Rift
GitHub
GitHub - DepthFirstDisclosures/Nginx-Rift: NGINX RCE exploits
NGINX RCE exploits. Contribute to DepthFirstDisclosures/Nginx-Rift development by creating an account on GitHub.
โค3