Problem with chown/chgrp: illegal option -- -

Hi everybody!

I'm running FreeBSD 9.1-RELEASE-p3 (i386), and have encountered a strange issue with the chown and chgrp commands, here are some examples:
Code:
> chown user:group some_file
chown: illegal option -- -
usage: chown [-fhvx] [-R [-H | -L | -P]] owner[:group] file ...
       chown [-fhvx] [-R [-H | -L | -P]] :group file ...

> chgrp -R group some_dir
chgrp: illegal option -- -
usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ...

The same issue appears when running above command under a regular user as well as under root.

Not sure whether this is relevant, but I'm using sudo -s to become root. I use bash as a shell.

Here is output of uname -a:
Code:
FreeBSD server.net 9.1-RELEASE-p3 FreeBSD 9.1-RELEASE-p3 #0: Mon Apr 29 18:11:52 UTC 2013     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

Any suggestions on where to look for a reason are welcome.
Thanks in advance.
 
Does some_file or some_dir contain a dash in its name? Or perhaps the username or group?

You can usually use -- as an option to force the command to stop processing options and to take everything after it as arguments verbatim.
 
SirDice said:
Does some_file or some_dir contain a dash in its name? Or perhaps the username or group?

You can usually use -- as an option to force the command to stop processing options and to take everything after it as arguments verbatim.
Thanks for the response!

I've found the reason - it's my Bash aliases file, which I had copied from my Linux desktop. In this particular case the following lines caused the mentioned errors:

Code:
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
 
Back
Top