Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 3513  / 3 Years ago, tue, may 4, 2021, 10:47:09

Are there any files, like in ~/.config or elsewhere, in the home directory that should be owned by root?



Will recursively changing the ownership of every file in my user's ~ to be my user be harmful?


More From » permissions

 Answers
7

Are there any files, like in ~/.config or elsewhere, in the home directory that should be owned by root?




No you should be the owner of all the files and folders under your home.




What may be the possible trouble otherwise?




In your home there exists many user level settings for various applications and system itself in the hidden files and folders. If you chown them to root you will be in trouble in the next login. At the time of login your profile could not be loaded as you have no longer access permission to the configuration files. And you will be most probably kicked out to the login screen. In the process you will lock yourself.




Will recursively changing the ownership of every file in my user's ~ to be my user be harmful?



There is no harm in doing so. But keep in mind the case as pointed out by Lekensteyn in the comment above. I am quoting it,




Beware of rare edge cases when literally executing the command in the title, $USER and $HOME can be changed. E.g. USER=nobody; HOME=/; sudo chown -R $USER $HOME is unsafe.




There is a better proposal than to recursive chown in the comment above,




you can find files not owned by you using find ~ ! -user $USER -ls (assuming a same environment where the variables have not been changed). And rename only those files.



[#27203] Thursday, May 6, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sipwing

Total Points: 245
Total Questions: 100
Total Answers: 118

Location: Aland Islands
Member since Thu, Oct 22, 2020
4 Years ago
;