Ubuntu – chown: invalid option — ‘i’ Try ‘chown –help’ for more information

chowncommand line

I have a strange issue with the following command:

# chown -R myuser:mygroup *
chown: invalid option -- 'i'
Try 'chown --help' for more information.

the command is not aliases

# type chown
chown is hashed (/bin/chown)

Where I can look further?

Best Answer

As the glob (pathname) expansion is done first by the shell before the chown runs, the glob pattern * is expanded to all files in the current directory first and chown is getting those as its options and arguments. You have a file in the current directory that starts with -i, hence chown is considering it as an option, not as an argument (filename).

You need to use -- to indicate the end of options for chown:

chown -R myuser:mygroup -- *

Or precede the glob pattern (*) with ./ to explicitly indicate it as argument:

chown -R myuser:mygroup ./*