Linux Commands & Snippets
Type 2+ characters.
Sub-links
Interface Priority on Linux
sudo nmcli connection modify 'enter ssid here' ipv4.route-metric 50
sudo nmcli connection up 'enter ssid here'
Install sudo on Debian 12
su
apt install sudo
Add a user to sudo group:
su -l
adduser <your_username_here> sudo
logout
Change IP Addressing from DHCP to Static
sudo nano /etc/network/interfaces
auto <interface>
iface <interface> inet static
address x.x.x.x
netmask 255.255.255.0
gateway xx.xx.xx
dns-nameservers xx.xx.xx
sudo systemctl restart networking.service
sudo systemctl status networking.service
Change hostname (Debian 9/10/11/12)
hostnamectl set-hostname {name-here}
sudo hostnamectl set-hostname enkielhostsample
sudo nano /etc/hosts # replace old hostname references
Check DNS (systemd-resolved)
resolvectl status
resolvectl dns <interface> <dns address>,<dns address>
Remove folder contents
sudo rm -rf foldername/*
Missing disk space on new installation
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/ubuntu-vg/ubuntu-lv
Root file system requires manual fsck
fsck -yf /dev/sda1
“Reading package lists… Error!”
sudo apt clean
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
Setup mobile Linux/Termux storage sharing
termux-setup-storage
Kill zombied application
ps -eo pid,ppid,state,cmd | awk '$3=="Z" { print "Zombie PID:", $1, "Parent PID:", $2 }'
kill -HUP <parentPID>
Allow password auth only for a single IP (sshd_config)
# Default: key-based only for everyone
PasswordAuthentication no
PubkeyAuthentication yes
# Exception: allow password login from specific IP
Match Address 203.0.113.25
PasswordAuthentication yes
Steps:
1) Edit sshd_config and add the block above.
2) Test syntax: sudo sshd -t
3) Reload SSH: sudo systemctl reload sshd
Fix DNS configuration
sudo nano /etc/resolv.conf
# Example
nameserver 8.8.8.8
nameserver 1.1.1.1
# If systemd-resolved keeps overwriting:
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
sudo rm /etc/resolv.conf
echo -e "nameserver 8.8.8.8\nnameserver 1.1.1.1" | sudo tee /etc/resolv.conf
Codex clear session caches
cd ~/.codex/sessions
rm -rf *