NetBSD package manager configuration
Tags: netbsd, packagemanager, configuration
Published: 2022-03-10 04:23:54

# Summary

In this part i'm going to enable built-in package manager and install pkgin. Pkgin is the recommended package manager for NetBSD.
For more information see: [PKGIN Website](https://pkgin.net/)

This part requires active internet connection.

----------------------

# Instructions

1- Start and login to your system.

![netbsd-pkg-001](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htrau5uf1l9akbrdayoi.png)

2- Switch to **`root`** user with **`su`** command.

![netbsd-pkg-002](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwkmsj1npenhz8j2nm7h.png)

3- Go to root's **homefolder** with **`cd`** command. Check with **`ls`** command that you're in **homefolder**. Open **`.profile`** dotfile with **`vi`** program.

![netbsd-pkg-003](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5u93aupubnqkxikxlez.png)

4- In this file find and uncomment **`export PKG_PATH`** line by deleting the **#** character at the start of the line. Save it using **`:w!`** command because this file is read-only.

![netbsd-pkg-004](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2j9an3dw1ulk3qfplpi.png)

![netbsd-pkg-005](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni2ffm4cw2mg6zevmuxc.png)

5- This configuration don't require a system restart. It requires a re-login. So logout from all the logged-in users with **`exit`** command.

![netbsd-pkg-006](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt4crfx1xfh86lqrrx5j.png)

![netbsd-pkg-007](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itoypyhday173038kpk4.png)

6- Login with **`root`** user. (Installing programs requires root privileges)

![netbsd-pkg-008](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2v0l47b2yggif5lkhd6.png)

![netbsd-pkg-009](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a2096hrnw9whrj3zpsk3.png)

7- First, install **`pkgin`** package manager using command **`pkg_add -v pkgin`** .

![netbsd-pkg-010](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w48vhhovj1we32ot6mio.png)

![netbsd-pkg-011](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jitxfmnuz7snqn54ga5q.png)

![netbsd-pkg-012](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2owr4tlxplccjxqexm6y.png)

![netbsd-pkg-013](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1vivvrjo5giuyl0ftwb.png)

8- From now on we can use pkgin. Update pkgin database with command **`pkgin update`** . Always update **`pkgin`** before installing programs.

![netbsd-pkg-014](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tb5pxov2b5qlw8c4arw.png)

![netbsd-pkg-015](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pm2l569cxxuvbaauqrfh.png)

9- Let's test **`pkgin`** by installing **`vim`** program. Use command **`pkgin install vim`** to install **`vim`**. Type Y to continue install. This will download and copy all the necessary files for **`vim`** program.

![netbsd-pkg-016](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdfyyk2eulfwqlyqfaz2.png)

![netbsd-pkg-017](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p159tb4yhdxhiaaief6p.png)

10- After installation is over, test-run the program with command **`vim`**. Check if it runs or not.

![netbsd-pkg-018](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcbgsn9oij7pf5gnb5l4.png)

![netbsd-pkg-019](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11ady1hg8bkqdbfr1z33.png)

11- You can also delete installed programs. Remove **`vim`** with using **`pkgin remove vim`** command.

![netbsd-pkg-020](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2tstqhifiiztc3rylbq.png)

![netbsd-pkg-021](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38fv84b6wuhpwdrobryp.png)

![netbsd-pkg-022](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5nuqcmfsmzgw55t9ykx4.png)

12- After removal of a program you should also remove unnecessary packages by using **`pkgin autoremove`** command.

![netbsd-pkg-023](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcvkw6qht8nmn2i76pzo.png)

![netbsd-pkg-024](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbmlf632t7c3zujmsv5n.png)

![netbsd-pkg-025](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmorvf695kcejqkhb6ey.png)

13- Also use **`pkgin clean`** command to clean the cache after an install or uninstall operation.

![netbsd-pkg-026](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ckf6ykusaxkd0zkcoqcg.png)

By the way you should always think programs as potential security vulnerabilities. Especially if you are running your system as a server. So never install any unnecessary programs to a server. Best is always use the programs those come with your operating system. For example use vi instead of vim. 

This is the end of NetBSD guide. Now you have a fully functioning minimal NetBSD system. Next is up to you. You can install a Graphical User Interface or configure a Firewall. For more information about NetBSD use the official guide here: [NetBSD Guide](https://www.netbsd.org/docs/guide/en/)