Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Easy command (chown) to change owner/group to all subfolders and files
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Easy command (chown) to change owner/group to all subfolders and files

I have several folders/files under /home/site/public_html I want to change owner and group on.

Just what command is the best, can I do it in one command?

chown user:user /folder is for one folder. But I want it to apply to all sub folders and files.

Comments

  • chown -R

  • @putStrLn said:
    chown -R

    So chown -R user:group /home/site/public_html will change the user and group for all sub folders and files?

  • yes.

    Thanked by 1myhken
  • Worked like a charm. Thank you @putStrLn

  • edited January 2017

    To see all available options or flags for chown or chmod, review the man page or use the -h flag for help. Also, the option you're asking about is called"recursive".

    Thanked by 1myhken
  • user123user123 Member
    edited January 2017

    @putStrLn @rajprakash Is there any way to do this so that it also applies to all new subfolders and files created going forward, even those created by other more privileged users?

  • WilliamWilliam Member
    edited January 2017

    user123 said: Is there any way to do this so that it also applies to all new subfolders and files created going forward, even those created by other more privileged users?

    A cronjob which must have same or higher privileges as user than the highest writing user.

    Thanked by 1user123
  • WSSWSS Member

    Or, perhaps a sticky bit, depending on your operating system.

  • pikepike Veteran

    chown -R

  • @William thanks

    @WSS said:
    Or, perhaps a sticky bit, depending on your operating system.

    U wot, m8?

    Hmmm, so if I want all users to be able to modify all folders and files created within a specific folder within which I (plus background apps) am uploading, moving, and deleting files using different accounts (/some/super/hidden/buried/protected/folder/, for example), a sticky bit could work?

  • WSSWSS Member

    @user123 said:
    @William thanks

    @WSS said:
    Or, perhaps a sticky bit, depending on your operating system.

    U wot, m8?

    Hmmm, so if I want all users to be able to modify all folders and files created within a specific folder within which I (plus background apps) am uploading, moving, and deleting files using different accounts (/some/super/hidden/buried/protected/folder/, for example), a sticky bit could work?

    ``

    Well, yes, and no. If you chmod the folder 777 and set the umask appropriately for the files, there is no need.

    Here's a simple explaination of using the sticky bit for different uses: http://unix.stackexchange.com/questions/79395/how-does-the-sticky-bit-work

  • @WSS said:

    @user123 said:
    @William thanks

    @WSS said:
    Or, perhaps a sticky bit, depending on your operating system.

    U wot, m8?

    Hmmm, so if I want all users to be able to modify all folders and files created within a specific folder within which I (plus background apps) am uploading, moving, and deleting files using different accounts (/some/super/hidden/buried/protected/folder/, for example), a sticky bit could work?

    ``

    Well, yes, and no. If you chmod the folder 777 and set the umask appropriately for the files, there is no need.

    Here's a simple explaination of using the sticky bit for different uses: http://unix.stackexchange.com/questions/79395/how-does-the-sticky-bit-work

    So, it won't work for what I needed. I had googled before replying and what I was worried about was the part about "it makes a directory such that users can only delete files & directories within it that they are the owners of." As I described, I would want all non-privileged accounts to be able to modify/delete/write files created by multiple other non-privileged accounts below that directory.

  • WSSWSS Member
    edited January 2017

    @user123 said:
    So, it won't work for what I needed. I had googled before replying and what I was worried about was the part about "it makes a directory such that users can only delete files & directories within it that they are the owners of." As I described, I would want all non-privileged accounts to be able to modify/delete/write files created by multiple other non-privileged accounts below that directory.

    I politely gave you the answer in my reply. Set the umask to 0000 after before the file is written (or chmod it), and get on with life.

    Thanked by 1user123
  • WSSWSS Member

    ..until 3 minutes later when someone completely fucks over this entire "all in" ideology, at least. :

  • @WSS said:

    @user123 said:
    So, it won't work for what I needed. I had googled before replying and what I was worried about was the part about "it makes a directory such that users can only delete files & directories within it that they are the owners of." As I described, I would want all non-privileged accounts to be able to modify/delete/write files created by multiple other non-privileged accounts below that directory.

    I politely gave you the answer in my reply. Set the umask to 0000 after the file is written, and get on with life.

    Ah, thanks. I didn't see the umask part on the first read :).

    @WSS said:
    ..until 3 minutes later when someone completely fucks over this entire "all in" ideology, at least. :

    I'm the only human user, so hopefully it'll be ok.

  • WSSWSS Member

    @user123 said:
    I'm the only human user, so hopefully it'll be ok.

    I'll let you live. For now.

Sign In or Register to comment.