mv, cp, and sgid on directories (was: cp -p)

Jonathan McKeown jonathan+freebsd-questions at
Sat Feb 9 10:44:26 UTC 2008

I think you may be getting too deep into the detail.

Think of the bigger picture:

when I move a file, I don't expect that to change its ownership or 
permissions - it would surprise me if it did;

when I make a copy of a file, I expect to own the copy - after all, what use 
is a private copy I can't do anything with?

FreeBSD generally tries hard not to behave in a surprising way.

The bit that still worries me in this discussion is the sgid bit (pun not 
intended, but I'm not going to delete it now!): as I understand it, creating 
a file has different behaviour on SYSV-derived systems and Berkeley-derived 

SYSV creates files group-owned by the creator's primary group.
BSD creates files which inherit the group-ownership of the directory they are 
created in.

SYSV behaviour can be changed to BSD behaviour per-directory, by using the 
sgid bit on the directory.
BSD behaviour can't be changed and the sgid bit on a directory is ignored.

Again, could someone confirm whether I'm talking nonsense here?


More information about the freebsd-questions mailing list