Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 55428  / 1 Year ago, wed, may 31, 2023, 10:51:43

I got into a lot of trouble when changing the permission of a folder myfolder residing in /.
I issued the command



sudo chown -R luca:luca /myfolder/.*


My intention was to change ownership of all the hidden files in /myfolder.



Unfortunately I realized that also the ownership of / was changed, which of course left me with a broken system. I think this happened because .. matches .*, but still seems weird to me.



Is changing the parent directory the correct behaviour or should I file a bug report?



If it was my mistake in using chown, what are the best practices to use to prevent changing the ownership of system folders and files?


More From » permissions

 Answers
2

Remember that the command line is expanded (interpreted) by the shell before being executed



sudo chown -R luca:luca /myfolder/.*


is interpreted first as :



sudo chown -R luca:luca /myfolder/.  /myfolder/.. /myfolder/.adobe  /myfolder/.bash_history


note the /myfolder/.. in your command line



chown -R luca:luca /myfolder/.. is equivalent to chown -R luca:luca /

that makes the chown running "backwards"



Use echo /myfolder/.* when you use "*" to verify .


[#30438] Thursday, June 1, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hreadsoplet

Total Points: 220
Total Questions: 108
Total Answers: 105

Location: Serbia
Member since Fri, Jun 3, 2022
2 Years ago
;