Linux - Various Command Lines

Linux & Proxmox Command Line Toolbox#


1 Storage & Disk Management#

1.1 Clean Up & Space Recovery#

# Purge unused packages and clean cache
apt autoremove --purge && apt autoclean
# Reclaim journal log space (limit to 500MB)
journalctl --vacuum-size=500M

1.2 Identify Large Files & Folders#

# List all files with human-readable sizes
ls -lah
# Summary of folder sizes in current directory
du -sh *
# Identify top 10 largest folders on root
sudo du -xh / | sort -rh | head -n 10
# Disk space usage summary (filtered for MB/GB)
du -cha --max-depth=1 / | grep -E "M|G"

1.3 Hugo Project Specifics (Size Checks)#

# Find files larger than 25MB in project
find /home/marc/hugo/canada2argentina -type f -size +25M -exec ls -lh {} +
# Count total files in the public build folder
find /home/marc/hugo/canada2argentina/public -type f | wc -l
# List top 25 largest files in project
find /home/marc/hugo/canada2argentina -type f -exec du -h {} + | sort -rh | head -n 25

1.4 Disk Health & Partitions#

# Wipe all partitions/signatures from a disk (CAUTION)
sgdisk --zap-all /dev/sdX
# Detailed SMART health report
smartctl -a /dev/sda | less
# Deep scan for bad blocks (Takes a long time)
badblocks -v /dev/sda -s

2 Proxmox & Virtualization#

2.1 VM / Container Management#

# Unlock a stuck VM or Container
qm unlock <vmid>
pct unlock <ctid>
# Resize a container disk (Final size, cannot shrink)
pct resize 103 rootfs 16G
# List running LXC containers
pct list | awk 'NR>1'

2.2 High Availability (HA) Fixes#

# Disable HA for a specific VM/CT to allow manual fixes
ha-manager set vm:200 --state disabled
ha-manager set ct:103 --state disabled

2.3 Repository & Templates#

# Update and list available CT templates
pveam update
pveam available
# List all active apt sources
grep -r '' /etc/apt/sources.list*

2.4 Proxmox Boot & Kernel#

# List and pin a specific kernel
proxmox-boot-tool kernel list
proxmox-boot-tool kernel pin 6.8.8-4-pve

3 Networking & Connectivity#

3.1 Troubleshooting & Discovery#

# Check DNS resolution
nslookup google.com
nslookup pi.hole
# Check open listening ports
ss -lntu
netstat -plant
# Performance test (Client mode, 8 parallel streams)
iperf3 -c 10.1.1.11 -P8

3.2 SSH & Remote Access#

# View real-time system logs for USB/Kernel errors
dmesg -w
dmesg -T | grep usb
# Clear "Remote Host Identification Changed" error
nano ~/.ssh/known_hosts

3.3 File Transfers (SCP)#

# Copy local images from Mac to Hugo site on Server
scp -v /Users/marc/Downloads/to_convert/* root@10.1.2.202:/home/marc/hugo/canada2argentina/static/images/
# Backup and transfer a folder between servers
tar -czvf "$(date +%Y-%m-%d_%Hh%M)_PangolinBackup.tar.gz" pangolin/
scp pangolin.tar.gz root@72.11.147.220:/home/marc/docker-compose

4 System & Hardware Info#

4.1 RAM & CPU#

# Clear RAM cache (Drop caches)
sync && echo 3 | tee /proc/sys/vm/drop_caches
# Check ZFS ARC summary and free RAM
arc_summary -s arc && free -h

4.2 BIOS & Hardware#

# Get BIOS version and serial info
sudo dmidecode -t bios
# List SCSI and PCIe hardware
lsscsi -u
lspci

4.3 Legacy iLO3 Fix (Firefox)#

  1. Type about:config in address bar.
  2. Search: security.tls.version.enable-deprecated.
  3. Set to: true.

5 Miscellaneous Utilities#

5.1 Permissions & Scripts#

# Make script executable and run
chmod +x ./unifi-9.0.114.sh && ./unifi-9.0.114.sh

5.2 Scheduling & Processes#

# Instant test of cron behavior (Sends message to all terminals)
* * * * * echo "Hello from cron" | wall
# Cancel a pending shutdown
shutdown -c

5.3 Print the path of the folder you are in#

# Print the path of the folder you are in
pwd

6 SSD SMART Testing on Proxmox#

6.1 Identify the drive#

# Display the drive model, serial number, capacity, and type.
lsblk -d -o NAME,MODEL,SERIAL,SIZE,TYPE /dev/sdX

6.2 View the current SMART report#

# Display the complete SMART health report.
smartctl -x /dev/sdX

6.3 Run a short self-test#

# Start a short, read-only SSD self-test.
smartctl -t short /dev/sdX

6.4 Check the test status#

# Check whether the self-test is still running or has completed.
smartctl -c /dev/sdb
echo "===== /dev/sdb ====="; smartctl -c /dev/sdb | grep -E "Self-test execution|remaining"

6.5 Check the test status if many disks tests running#

#One disk check of test
echo "===== /dev/sdk ====="
smartctl -x /dev/sdk | grep -iE "Self-test execution status|remaining|Background long"
# Multi Check whether the self-test is still running or has completed.
for d in /dev/sdb /dev/sdc /dev/sdd /dev/sde; do
  echo "===== $d ====="
  smartctl -x "$d" | grep -iE "Self-test execution status|remaining|Background long"
done

6.6 Run an extended self-test#

# Start an extended, read-only SSD self-test.
smartctl -t long /dev/sdX
#many
for d in /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde; do
  echo "===== Starting long test on $d ====="
  smartctl -t long "$d"
done

6.7 Check the extended test status#

# Check whether the extended test is complete.
smartctl -c /dev/sdX

6.8 Abort#

# Stop the test (this will stop all test if multiple started together)
smartctl -X
#If multiple
for d in /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh; do
  echo "===== $d ====="
  smartctl -X "$d"
done

6.9 View the final report#

# Display the final SMART report, including self-test results.
smartctl -x /dev/sdX

6.10 Save the report#

# Save the SMART report to a text file.
smartctl -x /dev/sdX > sdX-smart-report.txt