# How to safely remove work files?



## phyro (Mar 6, 2011)

Hey all, I just my FreeBSD system running and I wanted to find out how to get rid of all the "work" and "trash" files that the system used to build from source and from pkg_add commands.

(I DON'T want to remove any installed packages)

It took me quite a while to get up and cooking so I really don't want to mess it up.

Thanks.


----------



## dennylin93 (Mar 6, 2011)

When you install from Ports, the "work" directories that are created can be removed after the install completes. Either use rm() or run `# make clean`

Most people just use `# make install clean` to save some typing.


----------



## sk8harddiefast (Mar 6, 2011)

I am not sure if portsclean is part of portupgrade package.
From *man portsclean*

```
PORTSCLEAN(1)           FreeBSD General Commands Manual          PORTSCLEAN(1)

NAME
     portsclean -- a tool to clean ports/packages garbage

SYNOPSIS
     portsclean [-hCDDiLnPPQQq]

DESCRIPTION
     portsclean is a tool to help users clean out the working directories of
     their ports tree, no longer referenced distfiles, outdated package files,
     and obsolete or orphaned shared libraries that were possibly left by
     pkg_deinstall(1) 's -P option.

     -C
     --workclean    Clean out all the working directories of the ports tree.
                    (cf.  WRKDIRPREFIX)

     -D
     --distclean    Clean out all the distfiles that are not referenced by any
                    port in the ports tree.  Specified twice (i.e.  -DD),
                    clean out all the distfiles that are not referenced by any
                    port that is currently installed. (cf.  DISTDIR)
```
So. The obvious 

```
portsclean -CDD
```


----------



## phyro (Mar 6, 2011)

That's awesome thank you both


----------



## SirDice (Mar 6, 2011)

Assuming you haven't set $PORTSDIR or $PACKAGES to somewhere else:
`# rm -rf /usr/ports/*/*/work`

This is usually faster then doing a 
`# cd /usr/ports && make clean`


----------

