# Permissions for root



## jj05u3 (May 19, 2013)

Hello, I'm a complete newbie to FreeBSD and I thought that being logged in as root would grant you permissions to anything in the file system; however, as I'm reading the FreeBSD handbook and it showed me how to save my current customized video settings in /etc/rc.conf, I wasn't able to due to being denied to the file.

Could you please help me?

Thanks,

JosuÃ©


----------



## ShelLuser (May 19, 2013)

jj05u3 said:
			
		

> Hello, I'm a complete newbie to FreeBSD and I thought that being logged in as root would grant you permissions to anything in the file system


That is indeed correct. There is one small exception to that rule though; if you're editing a file which is marked readonly then you'll get an error message when trying to save it. If you're using an editor like vi then you can force the editor to write to the file anyway. Note that this isn't something specific for the root user by the way, this also applies if you're editing a file as a normal user.

Alas; when it comes to /etc/rc.conf then this normally doesn't apply since its permissions are 644 (read/write permissions for the owner and read permissions for the group and the rest of the world). By default this file is owned by root and the wheel group. Therefore you should have no problems editing this file while being root.

So my advice would be to make sure you really have root permissions, and you might also want to check the permissions of this file as well.

The best (easiest) way to become root is by using the su command. A good way to determine if you're really root is by checking the prompt (that should indicate a # sign) as well as by using the id command, like so:


```
smtp2:/home/peter $ su
Password:
root@smtp2:/home/peter # id
uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
```


----------



## jj05u3 (May 19, 2013)

@ShelLuser, thank you very much for your reply, reading a little further and after trying a couple of things I realized I wasn't trying to access the file through the right command, I did check what you told me to and indeed have root privileges, it really had to do with my lack of experience; I was able to specify my video mode at boot successfully .

Kind regards,

JosuÃ©


----------



## ta0kira (May 21, 2013)

ShelLuser said:
			
		

> That is indeed correct. There is one small exception to that rule though; if you're editing a file which is marked readonly then you'll get an error message when trying to save it. If you're using an editor like vi then you can force the editor to write to the file anyway. Note that this isn't something specific for the root user by the way, this also applies if you're editing a file as a normal user.


This isn't entirely true. As root you can write to a file that doesn't have a write bit set. It's the editor that's respecting the file permissions, not the kernel. Also, you can take numerous privileges away from root using the jail and MAC systems, and by using extended file attributes in combination with securelevel, so on FreeBSD root doesn't always rule the universe.

Kevin Barry


----------



## fluca1978 (May 22, 2013)

ta0kira said:
			
		

> This isn't entirely true. As root you can write to a file that doesn't have a write bit set. It's the editor that's respecting the file permissions, not the kernel.



Correct, but as a note the kernel will honor file attributes set via chflags(1).


----------

