Reference

Commands Cheatsheet

Every useful command for NetLens — from daily operations to full recovery — collected in one place. Click the copy button on any command to copy it.

Deploy and start

sudo ./install.sh

Build the image and start the stack (first run only).

docker compose up -d

Start the stack without rebuilding.

docker compose up -d --build

Rebuild the image and start.

docker compose down

Stop the container and release the bind mounts.

docker stop netlens

Quick stop that keeps the mounts.

docker start netlens

Quick start.

docker restart netlens

Restart the container.

docker compose ps

Check container status.

docker logs --tail=50 netlens

View the last 50 lines of container logs.

NfSen daemon

docker exec netlens /var/nfsen/bin/nfsen status

Check whether the NfSen daemon is running.

docker exec netlens /var/nfsen/bin/nfsen start

Start the NfSen daemon.

docker exec netlens /var/nfsen/bin/nfsen stop

Stop the NfSen daemon.

docker exec netlens /var/nfsen/bin/nfsen restart

Restart the NfSen daemon.

docker exec netlens /var/nfsen/bin/nfsen reconfig

Apply config changes to the running daemon.

Router sources

docker exec netlens grep -A 20 '%sources' /var/nfsen/etc/nfsen.conf

List all configured sources.

docker exec netlens bash -c "sed -i \"/^);$/i\\ 'NAME' => { 'port' => '2055', 'IP' => 'IP_ADDRESS', 'col' => '#COLOR', 'type' => 'netflow' },\" /var/nfsen/etc/nfsen.conf && /var/nfsen/bin/nfsen reconfig && echo 'Done'"

Add a source with an IP (replace NAME, IP_ADDRESS, COLOR).

docker exec netlens bash -c "sed -i \"/'NAME' =>/d\" /var/nfsen/etc/nfsen.conf && /var/nfsen/bin/nfsen reconfig && echo 'Removed'"

Remove a source (replace NAME).

docker exec netlens bash -c "sed -i \"/'router1' =>/d\" /var/nfsen/etc/nfsen.conf && /var/nfsen/bin/nfsen reconfig && echo 'Removed'"

Remove the demo router1 source.

Password management

docker exec netlens htpasswd -b /var/nfsen/etc/.htpasswd admin <newpass>

Change the admin password — instant, no restart.

Data retention

docker exec netlens /var/nfsen/bin/nfsen --modify-profile live expire=30d maxsize=15G

Set retention from the command line (30 days / 15 GB example).

Disk recovery

docker system prune -f

Free Docker disk space.

docker builder prune -f

Free Docker build cache.

sudo journalctl --vacuum-time=1d

Clean system logs when the disk is full.

docker exec netlens bash -c "rm -rf /var/nfsen/profiles-data/live/* /var/nfsen/profiles-stat/live/*"

Delete all flow data and graphs (frees the most space).

docker exec netlens bash -c "truncate -s 0 /var/nfsen/var/nfsen.log"

Truncate the NfSen log file.

LibreNMS integration

sudo apt install -y nfs-kernel-server

Install the NFS server (run on the NetLens VPS).

sudo apt install -y nfs-common

Install the NFS client (run on the LibreNMS server).

sudo mount -t nfs4 <VPS_IP>:<path>/nfsen-data /var/nfsen/profiles-data

Mount the NFS data share on the LibreNMS server.

/usr/local/bin/nfdump -V

Verify the nfdump version (must be 1.6.25).

lnms config:set nfsen_enable true

Enable the Netflow tab in LibreNMS.

lnms config:set nfsen_suffix '_none'

Set the required non-empty suffix (never leave empty).

Utility

ss -lunp | grep -E '2055|2056|8070'

Check that the UDP listeners and web UI port are active.

tar czf nfsen-backup.tar.gz nfsen-data nfsen-stat nfsen-var nfsen-etc

Back up all four data folders.

docker inspect netlens

Inspect the container (see the Mounts section for bind mounts).

df -h /

Check available disk space.