Useful Linux Commands


Get the lines of code without comments and empty lines in the directory


ventoy!!!


List storage devices


Write an iso file to a device.


Send notifications on ssh login using .profile


NFTables see what ips are blocked in a set.


Get the actively used public network interface name:


https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking


sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/maddy

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:


Continue to downloading a file in wget
wget -c -t 0 --waitretry=1 <url>

https://www.cyberciti.biz/tips/wget-resume-broken-download.html


Pass environment variables to a command:

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


Install excalidraw using podman

  1. podman pull docker.io/excalidraw/excalidraw:latest
  2. podman run -p 8080:80 -d docker.io/excalidraw/excalidraw:latest
  3. rename it to excalidraw
  4. run podman start excalidraw next 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

save neovim session


v4l2-ctl --list-devices

sudo modprobe v4l2loopback video_nr=0,8

scrcpy --v4l2-sink=/dev/video8

sudo rmmod -f v4l2loopback


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

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

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 &#x2013;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