chown all folder and subfolders in home with their own user
I have 52 directory in home folder, some files in those folders, are chown-ed to root.
I need script who chown folders and all files and folders in them to user named as folder in home. If username john then there is folder in home named as john. |
script? use chown.
Specifically, chown -R "man chown" for how to use chown. |
use the "-R" flag. it's a very common flag in file related programs.
it applies the command recursively all the sub-directories. Code:
chown -R john /home/john |
Quote:
52 times type chown -R username:username username It's lil bit hard. |
Code:
for dir in /home/*; do |
So you want to do it for every user? This wasn't clear in your original question.
Code:
/home # for i in *; do chown -R $i:$i /home/$i; done |
Thank's everyone and sorry for my bad english explaining. It's not my native lang.
|
Thanks All
Thanks guys for your replies. This helped resolve something on one of our servers.
|
The SysV/Posix chown follows symlinks by default.
Say there is a symbolic link to /etc somewhere in the target path, then /etc gets a new owner! Better run chown -hR ... Portable is Code:
chown -hR $username:$username $dir || |
Or maybe use a find command to filter files you want to change
|
All times are GMT -5. The time now is 04:09 AM. |