Skip to content

Tips and Tricks for investigations

cintiadr edited this page Aug 31, 2024 · 7 revisions

Find which TCP ports are listening in a server

$ sudo netstat -lnpt

Find location of logs from a certain application

$ sudo lsof -p <pid> | fgrep log

Close a hung SSH connection

\n~. as in <enter> tilde dot

Running out of disk

# Find biggest folders
du -sh /*

# and search inside that folder
du -a /var | sort -n -r | head -n 10


# remove old kernels
apt autoremove

#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu


# if /snaps folder is holding a lot of storage
# https://www.linuxuprising.com/2019/04/how-to-remove-old-snap-versions-to-free.html
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
   snap remove "$snapname" --revision="$revision"
done
Clone this wiki locally