# Problem with chown/chgrp: illegal option -- -



## MadAnd (Jun 5, 2013)

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:

```
> 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`:

```
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.


----------



## SirDice (Jun 5, 2013)

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.


----------



## MadAnd (Jun 5, 2013)

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:


```
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
```


----------



## SirDice (Jun 6, 2013)

Ah, yes. Those options don't exist on FreeBSD :e


----------

