My (previous) NAS needed some TLC. Made extensive use of the following commands to get rid of unnecessary services.

Future me will thank me for documenting.

nmap

# scan all ports on localhost
nmap -Pn -p- localhost
 
# probe scan specific port
nmap -Pn -sV -p3456 localhost

apt

apt list --installed | grep pkg
sudo apt purge *pkg*
sudo apt autoremove

lsof

sudo lsof -i TCP:3456

ps aux

ps aux | grep <PID>

find

sudo find / -name *.log -a -name *cron*
 
# I could have just written this as the following...
# but I wanted to test the -a flag
sudo find / -name *cron*.log

misc

pkill
locate

EOF