meaning of sudo chown -R `id -u` /data/db

匿名 (未验证) 提交于 2019-12-03 01:34:02

问题:

This command is actually a solution for this question about mongodb issue. But the ichiness of not knowing what exactly it is doing, command by command, is really drive me nut!

If anyone could dissect what this line does to... the /data/db directory, or even any other directory! Will be really appreciated (also those who like me, very noobie in command line)

Thanks!

回答1:

The main command is chown, which itself change the owner of the files.

-R means Recursively, means, its applied to every files in the directory

the command inside ` are execute first and then give the result to previous command

id -u is a single command seperated from chown. You can try it and see the result.

in my computer

id -u

returns

myusername

so in my computer

sudo chown -R `id -u` /data/db

is same as

sudo chown -R myusername /data/db

And now because I own that directory, I can add, edit, delete files within that folders.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!