I have some kind of service running in the background on linux that is making a folder called paradigm. How can I find the service and get rid of it? The only thing inside is a pgdata dir
Assistant
User
I have found the postgresql processes but not what launches them via any of the commands you have given
Assistant
User
pstree found this:
containerd-shim,1265140 -namespace moby -id 8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad -address /run/containerd/containerd.sock
Assistant
User
pstree found this:
containerd-shim,1265140 -namespace moby -id 8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad -address /run/containerd/containerd.sock
Assistant
The pstree output indicates that the PostgreSQL process is running inside a Docker container managed by containerd. The folder paradigm is likely a mounted volume from this container. Here's how to investigate and remove it:
To identify and remove the service creating the paradigm folder with a pgdata subdirectory, follow these steps:
1. Identify the Process Using the Directory
Use lsof to find processes accessing the paradigm directory:
bash
sudo lsof +D /path/to/paradigm
Replace /path/to/paradigm with the full path to the directory. If lsof isn't installed, use:
Safety: Ensure the service isn't critical before removal.
Ownership: If the folder is owned by a user (check with ls -l /path/to/paradigm), inspect that user’s crontab (crontab -u username -l) and startup files.
Data Loss: Removing pgdata deletes database files. Backup if needed.
By following these steps, you'll isolate and eliminate the rogue service. If the service persists, monitor directory creation in real-time with:
bash
sudo auditctl -w /path/to/paradigm -p wa -k paradigm_monitor
If you've identified PostgreSQL processes but couldn't find how they're launched through standard service commands, here's a deeper forensic approach to uncover the origin:
1. Trace the Process Parentage
Use pstree to see the full hierarchy:
bash
pstree -aps $(pgrep -f "postgres.*paradigm" | head -1)
This shows the entire parent chain of the PostgreSQL process. Look for unusual parents (e.g., scripts, user shells).
2. Inspect Process Environment
For the main PostgreSQL PID (found via pgrep -f "postgres.*paradigm"):
Check for PGDATA, PG_CLUSTER, or custom environment variables pointing to the launch method.
3. Check Non-Systemd Init Systems
If your system uses alternatives:
Upstart (older Ubuntu):
bash
grep -lR "paradigm" /etc/init/
OpenRC:
bash
grep -r "paradigm" /etc/conf.d/ /etc/init.d/
4. Investigate User-Level Launchers
Check for hidden user services:
bash
# Check all user systemd instances
for user in $(cut -d: -f1 /etc/passwd); do
sudo -u $user systemctl --user list-units 2>/dev/null | grep -i "postgres\|paradigm"
done
# Check user crontabs
for user in $(cut -d: -f1 /etc/passwd); do
sudo crontab -u $user -l | grep -i "paradigm"
done
5. Analyze Process Working Directory
Find the executable path:
bash
sudo ls -l /proc/$(pgrep -f "postgres.*paradigm" | head -1)/exe
sudo ls -l /proc/$(pgrep -f "postgres.*paradigm" | head -1)/cwd
This reveals the exact binary location and current working directory.
Watch who tries to restart it (check logs, ps aux, or systemctl status).
Cleanup Procedure
Once identified:
Stop the process:
bash
sudo kill $(pgrep -f "postgres.*paradigm")
Remove persistence:
Delete service files/scripts found during investigation
Remove cron jobs or user profiles
Purge the directory:
bash
sudo rm -rf /path/to/paradigm
If All Else Fails: Boot Analysis
Reboot and immediately check running processes:
bash
ps aux --sort=start_time | grep -i postgres
Check early boot logs:
bash
journalctl -b0 -k | grep -i "paradigm\|postgres"
This layered approach combines process forensics, filesystem analysis, and runtime monitoring to uncover hidden launch mechanisms. PostgreSQL processes tied to a specific directory are almost always managed by something—the key is finding whether it's a standard service, user-level launcher, or custom automation.
Based on the pstree output showing containerd-shim, this indicates that the PostgreSQL process is running inside a Docker container. The containerd-shim process is part of Docker's container runtime infrastructure.
Here's how to identify and remove it:
1. Find the Docker Container
Use the container ID from the pstree output:
bash
docker ps -a --filter "id=8b3098655901" --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Ports}}"
2. Identify the Container
If the container isn't running, search all containers:
Mounts (to see where the paradigm directory is mounted from)
Config.Image (to identify the Docker image)
HostConfig.Binds
4. Stop and Remove the Container
bash
# Stop the container
docker stop 8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad
# Remove the container
docker rm 8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad
5. Remove Associated Resources
Remove any Docker volumes associated with the container (especially where pgdata is stored):
bash
docker volume ls | grep paradigm
docker volume rm <volume-name>
6. Delete the Host Directory
After removing the container:
bash
sudo rm -rf /path/to/paradigm
7. Check for Docker Compose
If this was started via Docker Compose:
bash
# Search for compose files
sudo find / -name docker-compose.yml 2>/dev/null | grep -i paradigm
# If found, navigate to that directory and run:
docker compose down -v
8. Prevent Automatic Restart
If the container is set to restart automatically:
bash
# Check restart policy
docker inspect 8b309... | grep -A 3 RestartPolicy
# If set to "always" or "unless-stopped", remove the container as above
Key Notes:
The paradigm/pgdata directory is almost certainly a Docker volume bind-mount from your host system
The container was likely started with:
bash
docker run -v /host/path/paradigm:/container/path ...
After container removal, the host directory will remain unless explicitly deleted
Verification:
Confirm no PostgreSQL containers remain:
bash
docker ps -a | grep postgres
Check if the paradigm directory stops being recreated after deletion.
This approach will eliminate both the Docker container and the persistent storage it was using. Remember that deleting the pgdata directory will destroy any databases stored in that PostgreSQL instance.
Step 1: Identify the Docker Container
Use the container ID from the pstree output (8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad):
bash
docker ps -a --no-trunc | grep 8b3098655901880a173513fd0cc6b7add3cbeda72002f84a2ac6f756cfc2eaad
Step 2: Inspect the Container
Get container details (replace <container_id> with the full ID):
bash
docker inspect <container_id>
Look for:
Volume mounts under .Mounts (to confirm /path/to/paradigm is mounted)
Container name/image under .Name and .Config.Image
After removal, the service should be gone permanently. If the folder reappears, check for Docker Compose files or orchestration tools recreating the container.