Useful Linux Commands
Get the lines of code without comments and empty lines in the directory
scc .
ventoy!!!
List storage devices
lsblk
Write an iso file to a device.
sudo dd if=/path/to/your.iso of=/dev/sdX bs=4M status=progress
Send notifications on ssh login using .profile
(&>/dev/null simplex -e "#status $(date) New SSH login is established in VPS" -t 10 --smp-web-port &)
NFTables see what ips are blocked in a set.
sudo nft list set inet filter mail_flood_v4- Available sets:
ssh_flood_v4, ssh_flood_v6, mail_flood_v4, mail_flood_v6, web_flood_v4, web_flood_v6
Get the actively used public network interface name:
ip -4 route ls | grep default | awk '{print $5}'
sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/maddy
- cap_net_bind_service: Allows binding to privileged ports (below 1024).
- +ep: Adds the capability (effective, permitted).
Maddy systemd service gives error and cant start because /usr/lib/maddy was not created in installation.
- It also gives permission errors and we need to change the ownership of directories to maddy user we created.
run commands with user maddy: sudo -u maddy <cmd>
vnstat: monitor network interface traffic with historical data.
Crowdsec list decisions: sudo cscli decisions list
Crowdsec remove decision: sudo cscli decisions delete -i <IP_ADDRESS>
Show CrowdSec metrics: sudo cscli metrics
check used ports
sudo netstat -tunlp
Get the password of the entry named rp_server:
secret-tool lookup Title rp_server- Example application:
SSH_PASS=$(secret-tool lookup Title rp_server) SSH_USER=tired ./scripts/update-index.sh
Continue to downloading a file in wget
wget -c -t 0 --waitretry=1 <url>
- -c continues to the download.
- -t 0 retries downloading infinitely if it fails at some point. (0 means infinite, 1 means try only for 1 more time.)
- --waitretry=1 waits for 1 seconds before retrying.
https://www.cyberciti.biz/tips/wget-resume-broken-download.html
Pass environment variables to a command:
(export $(grep -v '^#' .env | xargs) && env)
The parantheses makes it run in a sub-shell, protecting the environment variables from fetting exposed to the whole shell session.env -S $(grep -v '^#' .env) env
env command sets temporary environment variables just for the command we run. (in this case, env)
Grep command will ignore the lines starting with #
Show how many files contains a string in a directory:
rg --glob '*.md' --line-number --no-heading "/1tvynN.md" .
just list the files, to use with sed:
rg --glob '*.md' -l --color never "/1tvynN.md" .
replace the strings with sed:
rg --glob '*.md' -l --color never "/1tvynN.md" . | xargs -r sed -i 's//1tvynN.md//index.md/g'
ffmpeg -ss 00:00:30 -i orginalfile -t 00:00:05 -vcodec copy -acodec copy newfile
- -t parametresi -ss ile belirtilen dakikadan itibaren kaç dakikanın kesilen videoya dahil edileceğini ifade eder. Kaçıncı dakikaya kadar kesileceğini değil!
Install excalidraw using podman
podman pull docker.io/excalidraw/excalidraw:latestpodman run -p 8080:80 -d docker.io/excalidraw/excalidraw:latest- rename it to excalidraw
- run
podman start excalidrawnext time
start an interactive bash shell inside a container
docker exec -it <container> bash
going to 10.1.0.1 address in web browser redirects to the captive portal. A web based authentication method usually for free wifi networks.
Load neovim session
source desuna-session.nvim
save neovim session
mksession desuna-session.vim
v4l2-ctl --list-devices
sudo modprobe v4l2loopback video_nr=0,8
scrcpy --v4l2-sink=/dev/video8
sudo rmmod -f v4l2loopback
Print page
lpr -o ColorModel=Gray -o orientation-requested=4 -o fit-to-page -o media=A4 photo-name.jpg
Make some app default for xdg-open
xdg-mime default org.pwmt.zathura.desktop application/pdf
desktop names are in /usr/share/applications
Write ISO to the usb from cmd line
sudo dd if=~/downloads/debian-12.11.0-amd64-netinst.iso of=/dev/sda bs=4M status=progress
Mount Disk Without Root
udisksctl mount -b /dev/sda1
- To unmount:
udisksctl unmount -b /dev/sda1
NeoVim Show LSP Message Popup
lua vim.diagnostic.open_float(nil, {focus=false})
LINUX ONE LINER TERMINAL COMMANDS
Get all files in a directory that contains a string
rg -l "string" ./
DROIDCAMX PORT FORWARD
adb forward tcp:4747 tcp:4747
KILL ALL MANDOS PROCESSES & START ONE
ps aux | grep 'md-folder' | grep -v 'grep' | awk '{print $2}' | xargs kill -9
SIMPLEX
podman run -d \
-e "ADDR=smp.zynexis.com" \
-e "PASS=pass" \
-p 9384:5223 \
-v $HOME/drive2/simplex/smp/config:/etc/opt/simplex:z \
-v $HOME/drive2/simplex/smp/logs:/var/opt/simplex:z \
docker.io/simplexchat/smp-server:latest
podman run -d \
-e "ADDR=xftp.zynexis.com" \
-e "QUOTA=40gb" \
-p 9357:443 \
-v $HOME/drive2/simplex/xftp/config:/etc/opt/simplex-xftp:z \
-v $HOME/drive2/simplex/xftp/logs:/var/opt/simplex-xftp:z \
-v $HOME/drive2/simplex/xftp/files:/srv/xftp:z \
docker.io/simplexchat/xftp-server:latest
Clamav
Scan home folder with clamav:
sudo nice -n 15 clamscan && sudo clamscan -r -i -o -l /home/user/clamav.log –move=/home/user/infected /home/
Neovim
7,$!sort –> sort lines from 7 (included) to end of the file
lua vim.diagnostic.openfloat()) –> show diagnostic in float