# Reinstalling all pkgs



## balanga (Jul 24, 2018)

I want to reinstall all my existing pkgs on a new installation. I can simply create a list of pkgs using `pkg info` and then use that list as input into `pkg install`?


----------



## SirDice (Jul 24, 2018)

`pkg upgrade -f` reinstalls everything.


----------



## balanga (Jul 24, 2018)

SirDice said:


> `pkg upgrade -f` reinstalls everything.



I'm talking about a seperate new installation which doesn't have any pkgs installed yet.


----------



## Chris_H (Jul 24, 2018)

pkg(8) will need a list. In order to know _what_ it is you want to install. If you already have another FreeBSD install(ed) on another box, and want to copy that (ports) installation. On that box. You can feed pkg the following command. To export a list for pkg to process on the other (new) box:
`pkg info -oa | awk -F ' ' '{ print $2 }' >>./PKG-LIST`

HTH!

--Chris


----------



## SirDice (Jul 24, 2018)

You probably want to install the "primary" packages, and leave the dependencies as is; `pkg prime-list` should be enough. You probably don't want to force installation of dependency packages as they wouldn't be removed with pkg-autoremove(8) when you decide to remove a primary package.


----------



## ShelLuser (Jul 25, 2018)

Chris_H said:


> `pkg info -oa | awk -F ' ' '{ print $2 }' >>./PKG-LIST`


Creative command but it can be done easier: `pkg info -qoa > PKG-LIST`.


----------



## Chris_H (Jul 25, 2018)

ShelLuser 
Just like you. Always the show off. 

Thanks! I think I'll use that instead.

--Chris


----------



## rigoletto@ (Jul 25, 2018)

You can look on HERE <--- if all commands were issued it will reset all LOCALBASE.


----------



## balanga (Jul 27, 2018)

ShelLuser said:


> Creative command but it can be done easier: `pkg info -qoa > PKG-LIST`.



I've put that command line in my list of handy tips.

Now, if I want to reinstall those pkgs, is there any way of removing the ones that are dependencies that would get pulled in anyway?ie. should I pre-process that before doing a pkg install from a list?


----------



## SirDice (Jul 27, 2018)

Like I said, use `pkg prime-list` instead of a list of _all_ packages.


----------



## balanga (Jul 28, 2018)

Lots of useful info here. Just wondering where people come up with this...

pkg() does not mention `pkg prime-list` or `pkg leaf`  and I can't see any mention of parameters available to `pkg info`


----------



## cpm@ (Jul 28, 2018)

balanga said:


> Lots of useful info here. Just wondering where people come up with this...
> 
> pkg() does not mention `pkg prime-list` or `pkg leaf`  and I can't see any mention of parameters available to `pkg info`



Read pkg-alias(8) man page for further details.

```
% pkg alias prime-list
prime-list           'query -e '%a = 0' '%n''
% pkg alias leaf
leaf                 'query -e '%#r == 0' '%n-%v''
```


----------

