# Do i require root to install ports?



## triplesquarednine (Aug 13, 2009)

hi there, 

i am a noob, i am very experienced in using linux (most distro's), solaris, macOSX, windows, etc.. but i am alreadyfinding much frustration in using BSD, which i was hoping will become my main OS...as i do not like linux's poor handling of IO threads, and the lack of bug fixes from version to version(many things get overlooked pretty much forever)...

i have been trying to install packages using ports,
and i cannot. i have installed a couple, however, most times when i use ports it either says the package i am looking for  either "isn't available or i have no access to url". even though i have already found it on the site, and am positive i am using the proper name for the package...

..then the times it has connected to freeBSD.org it won't install because i do not have the right permissions to write to /bin/ or whatever other directory..

i have tried using "su" to do avail, and if i log in as "root" it will not work either.(and by my logic i shouldn't have to always log in as root to install software)...

what am i missing here?? i have read thru some of the handbook and manual pages, but they often do not answer my questions and make it sound like all i have to do is
open a terminal and type "add_pkg -r +(the port)" and it will install...

meanwhile that hasn't worked... 

any help would be great.


----------



## dennylin93 (Aug 13, 2009)

In short, you must be root to install software. Like Linux, the important system directories all belong to root, so you must have extra privileges to be able to install stuff. However, most users don't login as root (by default root cannot login over SSH). They use `$ su` or `$ sudo su` (security/sudo) to obtain root privileges.

As for using packages, the correct command is `# pkg_add`, not `# add_pkg`. If you wish to fetch packages from a remote site, then you might want to set PACKAGESITE as stated in the Handbook. This command should install sudo: `# pkg_add -r sudo`.

The documentation FreeBSD has is the best I have seen compared to other OSes such as Fedora, Ubuntu, Windows, etc. Really, just go and read the FreeBSD Handbook carefully from the beginning. The answers are there.


----------



## graudeejs (Aug 13, 2009)

You can only install software as root.
Use su or install and configure security/sudo


----------



## lme@ (Aug 13, 2009)

Which Version of FreeBSD do you use?
I guess it's 7.2, so set
PACKAGESITE to ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/ or a mirror of your choice and try again, the port should be found.
e.g.:
`# pkg_add -r lighttpd`

To be able to install to /usr/local you need to be root.
If you want to install the package to your home directory, try `# pkg_add -r -P <package>`

BTW: Please don't mix up the phrases ports and packages. You can find about 20k ports in /usr/ports which are files how to build 3rd party applications.
Packages are the pre-compiled tarballs you find on the ftp mirrors.

Usually ports are newer than packages and the main focus is on ports.


----------



## dennylin93 (Aug 13, 2009)

Usually, ports are favoured over packages, but sometimes there are some exceptions, like on old computers, desktops or laptops where compiling from source is simply too time consuming or unnecessary (imagine using ports for OpenOffice.org on a Pentium III).


----------



## triplesquarednine (Aug 14, 2009)

thanks, i didn't realize i would need to install sudo.
everytime i used su - it would reply su:sorry..

this seems to work now,
cheerz!


----------



## triplesquarednine (Aug 14, 2009)

i do realize the difference between ports and packages,
my bad for the confusion...

i use Macports all the time Vs. ubuntu or Suse .debs/.rpms in linux

thanks


----------



## triplesquarednine (Aug 14, 2009)

thank you very much, your info is quite useful.

i think FreeBSD is going to be awesome for me, once i adjust
to the interface and unix in general. first, i need to break
some of my linux habits, and get all of my hardware working, then i will be happy....only the wireless and intelHDA to go! 

thanks again


----------



## SirDice (Aug 14, 2009)

triplesquarednine said:
			
		

> thanks, i didn't realize i would need to install sudo.
> everytime i used su - it would reply su:sorry..



You don't _need_ to install sudo. Su should also work fine. But.. you have to be a member of the wheel group to be able to su.


----------



## Beastie (Aug 14, 2009)

And just like sudo, you can execute both su and the program you need to run in one single command using the -c option, e.g. `% su -m root -c some_command`.


----------



## graudeejs (Aug 14, 2009)

I still prefer sudo and use it to shutdown pc without password...
sodo have many advantages


----------



## SirDice (Aug 14, 2009)

killasmurf86 said:
			
		

> sodo have many advantages


It also has quite a few security issues you need to be aware of


----------



## graudeejs (Aug 14, 2009)

and su doesn't have same/similar problems?


----------



## SirDice (Aug 14, 2009)

killasmurf86 said:
			
		

> and su doesn't have same/similar problems?



No.

For su you need to enter root's password, sudo needs your own password. So if someone cracks your password they'll also have sudo.

Also, if you only allow vi or less for certain users you need to be aware you can use that to get a shell.

Lots of other things to worry about too :e


----------



## triplesquarednine (Aug 14, 2009)

thank you for pointing out the differences between using
su VS. sudo, i think i will stick with su...

..not that i am expecting someone to try to "jack" my OS,
but i still think it is a better solution than adding sudo to the mix
+ if i miss the sudo command(lol!) i do use linux everyday, and
all of my Os's..

PS: i would like to thank and mention how awesome the BSD forum is, and the people using it. i feel right at home and much of the info/replies from everyone have been great and very insightful.

i am glad i am using FreeBSD.  cheerz!


----------



## graudeejs (Aug 18, 2009)

SirDice said:
			
		

> No.
> 
> For su you need to enter root's password, sudo needs your own password. So if someone cracks your password they'll also have sudo.
> 
> ...



It all becomes pointless, when stacker installs sniffer.


----------



## SirDice (Aug 18, 2009)

killasmurf86 said:
			
		

> It all becomes pointless, when stacker installs sniffer.



True but the attacker would need to get root access first. If your attacker has root access you have more serious problems :e


----------



## graudeejs (Aug 18, 2009)

Attacker won't need to get root access to install sniffer.
It's enough if he can edit user files to start his sniffer, and they wait until user use su.


----------



## SirDice (Aug 18, 2009)

killasmurf86 said:
			
		

> Attacker won't need to get root access to install sniffer.
> It's enough if he can edit user files to start his sniffer, and they wait until user use su.


Not true. A network sniffer won't work. For one you need root access to open bpf. Second, the password typed for su doesn't traverse the network. If you happen to remotely use su I do hope you use ssh, in which case you won't be able to sniff anything but garbage as it is an encrypted connection.

In case you mean something like a keylogger, not likely as you would need root for that too.


----------



## graudeejs (Aug 18, 2009)

Another good reason why opensource rocks


----------

