# Finding unmanaged files



## Hornpipe2 (Nov 24, 2009)

Is there a way I can get a list of all files NOT currently managed by ports/packages?  I installed some stuff from source tarball but later found there are ports versions, but I want to audit my system first to delete anything that's not currently managed.


----------



## renice (Nov 24, 2009)

Try pkg_cutleaves(1)

```
# pkg_cutleaves -l
```


----------



## SirDice (Nov 24, 2009)

The only way to do it would be to do a [cmd=]pkg_info -W[/cmd] on every file in /usr/local/bin (that's assuming the source installed it there).


----------



## jb_fvwm2 (Nov 24, 2009)

```
pkg_info -cIx a*
```
Un-newly-tested! but I've run that command...
probably once for each letter in
/usr/local/bin and
/usr/local/lib... 
(That command or similar)
I had files from 2004 sitting around still in 2008...
/edit/
OR, similar to a post below, it was pkg_which... something...


----------



## frank_s (Nov 25, 2009)

Not a direct answer to your question but sometimes the Makefile of your tarball will have an uninstall option. So you can go to the dir of the unpacked tarball with the Makefile in it and:

`# make uninstall`

This will then delete anything installed during the "make install".

If you've installed the same softs from ports afterwards, then you have to be careful that it doesn't wipe out your binaries etc. which were installed by the port.

In that case just rebuild the port after the "make uninstall".


----------



## expl (Nov 25, 2009)

```
find /usr/local /usr/X11R6 -type f | xargs pkg_which -v | fgrep '?'
```

Works the best.


----------



## SirDice (Nov 25, 2009)

frank_s said:
			
		

> Not a direct answer to your question but sometimes the Makefile of your tarball will have an uninstall option. So you can go to the dir of the unpacked tarball with the Makefile in it and:
> 
> `# make uninstall`
> 
> This will then delete anything installed during the "make install".


Not if you updated your ports tree in the mean time 

The new version of the port might have different files or they're stored in different locations. The best way to remove installed ports is to use pkg_delete or pkg_deinstall (part of portupgrade).



> If you've installed the same softs from ports afterwards, then you have to be careful that it doesn't wipe out your binaries etc. which were installed by the port.


pkg_delete will complain if another port/package depends on the package you're trying to remove.


----------



## frank_s (Nov 26, 2009)

> The new version of the port might have different files or they're stored in different locations. The best way to remove installed ports is to use pkg_delete or pkg_deinstall (part of portupgrade).



I was talking about the files which he installed from a tarball not a port.


----------



## paulbeard (Jan 1, 2011)

expl said:
			
		

> ```
> find /usr/local /usr/X11R6 -type f | xargs pkg_which -v | fgrep '?'
> ```
> 
> Works the best.



This looks to be doing what I just started a thread about ;-) Now: do I just delete those files or troll through every pkg-plist to see if they are mentioned there? It's almost 25k filenames (!). 

It looks like it's missing files with embedded spaces so I amended it thusly: 


```
find /usr/local /usr/X11R6 -type f | xargs -J% pkg_which -v "%" | fgrep '?' > /tmp/unmanaged
```


----------

